strikt types
This commit is contained in:
14
sql.php
14
sql.php
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
class SQL {
|
||||
private $h;
|
||||
private $res = false;
|
||||
@@ -22,7 +24,7 @@ class SQL {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function get($que, $t = '', $p = array ()) {
|
||||
public function get(string $que, string $t = '', mixed $p = array ()): array|false {
|
||||
// echo $que;
|
||||
$this->cnt_get ++;
|
||||
if (SQL_LOG)
|
||||
@@ -89,14 +91,14 @@ class SQL {
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public function single($que, $t = '', $p = array ()) {
|
||||
public function single(string $que, string $t = '', mixed $p = array ()): array|false {
|
||||
$data = $this->get ( $que, $t, $p );
|
||||
if ($data) {
|
||||
return $data [0];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function list($que, $t = '', $p = array ()) {
|
||||
public function list(string $que, string $t = '', mixed $p = array ()): array|false {
|
||||
$data = $this->get ( $que, $t, $p );
|
||||
if ($data) {
|
||||
$ret = array ();
|
||||
@@ -109,7 +111,7 @@ class SQL {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function keyval($que, $k, $v, $t = '', $p = array ()) {
|
||||
public function keyval(string $que, string|int $k, string|int $v, string $t = '', mixed $p = array ()): array|false {
|
||||
$data = $this->get ( $que, $t, $p );
|
||||
if ($data) {
|
||||
$ret = array ();
|
||||
@@ -120,7 +122,7 @@ class SQL {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function set($que, $t = '', $p = array (), $id = false) {
|
||||
public function set(string $que, string $t = '', mixed $p = array (), bool $id = false): int|false {
|
||||
// echo $que;
|
||||
$this->cnt_set ++;
|
||||
$statement = $this->h->prepare ( $que );
|
||||
@@ -189,7 +191,7 @@ class SQL {
|
||||
return $statement->affected_rows;
|
||||
}
|
||||
}
|
||||
function __destruct() {
|
||||
function __destruct(): void {
|
||||
if (SQL_LOG)
|
||||
$this->h->close ();
|
||||
// echo 'DESTROY';
|
||||
|
||||
Reference in New Issue
Block a user