private ?string $order = null; // ORDER BY clause
private ?int $limit = null; // LIMIT for pagination
private int $offset = 0; // OFFSET for pagination, internal only
+ private string $OPEP="gessql.php:class_probe";
/**
* Constructor
- */
- public function __construct(string $table,int $limit,int $offset)
- {
- $this->db = sql_connect();
- $this->table = $table;
- $this->limit = $limit;
- $this->offset = $offset;
+ **/
+ public function __construct(string $table,int $limit,int $offset) {
+ $this->db = sql_connect();
+ $this->table = $table;
+ $this->limit = $limit;
+ $this->offset = $offset;
}
/**
- * Add a CLOSE condition
- */
- public function close(): void
- {
- $this->db->connection=NULL;
- }
+ * Add the release function
+ **/
+ public function release(): void {
+ if ($this->db !== NULL) {
+ sql_close($this->db);
+ }
+ }
/**
* Add a WHERE condition
- */
- public function where(string $datawhere): self
- {
- $this->where = $datawhere;
- return $this;
- }
+ **/
+ public function where(string $datawhere): self {
+
+ $this->where = $datawhere;
+ return $this;
+ }
/**
* Set ORDER BY clause
- */
- public function order(string $order): self
- {
- $this->order = $order;
- return $this;
- }
+ **/
+ public function order(string $order): self {
+
+ $this->order = $order;
+ return $this;
+ }
/**
* Set LIMIT for pagination
- */
- public function limit(int $n): self
- {
- $this->limit = $n;
- return $this;
- }
+ **/
+ public function limit(int $n): self {
+
+ $this->limit = $n;
+ return $this;
+ }
/**
* Execute the query and return results
*/
- public function get(): array
- {
- rou_alert(0,"JMPDBG starting GET");
- $sql = "SELECT * FROM {$this->table}";
+ public function get(): array {
- if ($this->where) {
- $sql .= " WHERE {$this->where}";
- }
+ $sql = "SELECT * FROM {$this->table}";
+ if ($this->where) {
+ $sql .= " WHERE {$this->where}";
+ }
- if ($this->order) {
- $sql .= " ORDER BY {$this->order}";
- }
+ if ($this->order) {
+ $sql .= " ORDER BY {$this->order}";
+ }
- if ($this->limit !== null) {
- $sql .= " LIMIT {$this->limit}";
- }
+ if ($this->limit !== null) {
+ $sql .= " LIMIT {$this->limit}";
+ }
- if ($this->offset > 0) {
- $sql .= " OFFSET {$this->offset}";
- }
+ if ($this->offset > 0) {
+ $sql .= " OFFSET {$this->offset}";
+ }
- rou_alert(0,"JMPDBG rqst sql=<$sql>");
- $stmt = $this->db->Select($sql);
- return $stmt->fetchAll();
+ rou_alert(0,"$this->OPEP, JMPDBG rqst sql=<$sql>");
+ $stmt = $this->db->Select($sql);
+ return $stmt->fetchAll();
}
/**
* Count total number of items matching the current WHERE conditions
*/
- public function getnumrec(): int
- {
- $sql = "SELECT COUNT(*) AS cnt FROM {$this->table}";
+ public function getnumrec(): int {
- if ($this->where) {
- $sql .= " WHERE {$this->where}";
- }
+ $sql = "SELECT COUNT(*) AS cnt FROM {$this->table}";
+
+ if ($this->where) {
+ $sql .= " WHERE {$this->where}";
+ }
- $stmt = $this->db->Select($sql);
- $row = $stmt->fetch();
- return (int) $row['cnt'];
+ $stmt = $this->db->Select($sql);
+ $row = $stmt->fetch();
+ return (int) $row['cnt'];
}
/** ----------------------------- **/
* Move offset to next page
* Does NOT fetch data
*/
- public function goNext(): int
- {
- if ($this->limit !== null) {
- $last=max($this->getnumrec(),$this->limit);
- $this->offset = min($last-$this->limit,$this->offset+$this->limit);
- }
- return $this->offset;
+ public function goNext(): int {
+
+ if ($this->limit !== null) {
+ $last=max($this->getnumrec(),$this->limit);
+ $this->offset = min($last-$this->limit,$this->offset+$this->limit);
+ }
+ return $this->offset;
}
/**
* Move offset to previous page
* Does NOT fetch data
*/
- public function goPrevious(): int
- {
- if ($this->limit !== null) {
- $this->offset = max(0, $this->offset - $this->limit);
- }
- return $this->offset;
+ public function goPrevious(): int {
+
+ if ($this->limit !== null) {
+ $this->offset = max(0, $this->offset - $this->limit);
+ }
+ return $this->offset;
}
/**
* Move offset to first page
* Does NOT fetch data
*/
- public function goFirst(): int
- {
- $this->offset = 0;
- return $this->offset;
+ public function goFirst(): int {
+
+ $this->offset = 0;
+ return $this->offset;
}
/**
* Move offset to last page
* Does NOT fetch data
*/
- public function goLast(): int
- {
- if ($this->limit !== null) {
- $total = $this->getnumrec();
- $this->offset = max(0, $total - $this->limit);
- }
- return $this->offset;
+ public function goLast(): int {
+
+ if ($this->limit !== null) {
+ $total = $this->getnumrec();
+ $this->offset = max(0, $total - $this->limit);
+ }
+ return $this->offset;
}
/**
* Get current offset value
*/
- public function getOffset(): int
- {
- return $this->offset;
+ public function getOffset(): int {
+
+ return $this->offset;
}
}
$logname=NULL;
$phase=999;
}
- else {
- $userlang=lng::en;
- $language=$stmt->fetch(PDO::FETCH_ASSOC)['lang'];
- rou_alert(0,"$OPEP, JMPDBG langage=$language");
- if ($language!=NULL) {
- switch ($language) {
- case "FRA" :
- $userlang=lng::fr;
- break;
- case "ENG" :
- default : //NO BREAK
- $userlang=lng::en;
- break;
- }
+ break;
+ case 5 : //getting user working language
+ $userlang=lng::en;
+ $language=$stmt->fetch(PDO::FETCH_ASSOC)['lang'];
+ rou_alert(0,"$OPEP, JMPDBG langage=$language");
+ if ($language!=NULL) {
+ switch ($language) {
+ case "FRA" :
+ $userlang=lng::fr;
+ break;
+ case "ENG" :
+ default : //NO BREAK
+ $userlang=lng::en;
+ break;
}
}
break;
- case 5 : //checking if logname is an admin
+ case 6 : //checking if logname is an admin
$stmt=$dbsql->Select("Select * from admins where email='$logname'");
$id=$stmt->fetch(PDO::FETCH_ASSOC)['email'];
if ($id!=NULL)