mirror of
https://codeberg.org/vlw/php-mysql.git
synced 2025-09-13 16:23:42 +02:00
fix: array type coercion for params in driver
This commit is contained in:
parent
38fe8e5b82
commit
d5af94fded
1 changed files with 7 additions and 2 deletions
|
@ -13,9 +13,14 @@
|
|||
parent::__construct(...func_get_args());
|
||||
}
|
||||
|
||||
// Coerce input to array
|
||||
private static function to_array(mixed $input): array {
|
||||
return is_array($input) ? $input : [$input];
|
||||
}
|
||||
|
||||
// Execute SQL query with optional prepared statement and return array of affected rows
|
||||
public function exec(string $sql, mixed $params = null): array {
|
||||
$query = $this->execute_query($sql, $params);
|
||||
$query = $this->execute_query($sql, self::to_array($params));
|
||||
$res = [];
|
||||
|
||||
// Fetch rows into sequential array
|
||||
|
@ -28,7 +33,7 @@
|
|||
|
||||
// Execute SQL query with optional prepared statement and return true if query was successful
|
||||
public function exec_bool(string $sql, mixed $params = null): bool {
|
||||
$query = $this->execute_query($sql, $params);
|
||||
$query = $this->execute_query($sql, self::to_array($params));
|
||||
|
||||
return gettype($query) === "boolean"
|
||||
// Type is already a bool, so return it as is
|
||||
|
|
Loading…
Add table
Reference in a new issue