mirror of
https://codeberg.org/vlw/php-mysql.git
synced 2025-09-14 08:43:40 +02:00
wip: 2023-07-14T11:38:01+0200 (1689327481)
This commit is contained in:
parent
740d61a89b
commit
93c82412d0
1 changed files with 17 additions and 0 deletions
|
@ -13,6 +13,11 @@
|
||||||
parent::__construct($host, $user, $pass, $db);
|
parent::__construct($host, $user, $pass, $db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Place value in array
|
||||||
|
private static function to_array(mixed $value): array {
|
||||||
|
return is_array($value) ? $value : [$value];
|
||||||
|
}
|
||||||
|
|
||||||
// Bind SQL statements
|
// Bind SQL statements
|
||||||
private function bind_params(\mysqli_stmt &$stmt, mixed $params) {
|
private function bind_params(\mysqli_stmt &$stmt, mixed $params) {
|
||||||
// Make single-value, non-array, param an array with length of 1
|
// Make single-value, non-array, param an array with length of 1
|
||||||
|
@ -117,4 +122,16 @@
|
||||||
|
|
||||||
return $query->num_rows > 0 ? true : false;
|
return $query->num_rows > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function select(string $table, array|string $columns = null, string $where = "") {
|
||||||
|
// SELECT all columns if $columns is empty (wildcard "*")
|
||||||
|
$columns = self::to_array($columns ? $columns : "*");
|
||||||
|
|
||||||
|
if ($where) {
|
||||||
|
$clause = preg_match_all("/[<>!=]=|<=|>=|<>|>|<|=|LIKE|IN|IS|REGEXP/", $where);
|
||||||
|
$test = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT . FROM ${table}" . $where;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue