Derive data type for bindValue call
Remove debugging in document list
This commit is contained in:
@@ -26,7 +26,13 @@ class Custom
|
||||
$stmt = $pdo->prepare($query);
|
||||
foreach ($parameters as $key => $value) {
|
||||
if ($debug) echo "<pre>Binding $value to $key\n</pre>";
|
||||
$stmt->bindValue($key, $value);
|
||||
$dataType = match (true) {
|
||||
is_bool($value) => PDO::PARAM_BOOL,
|
||||
is_int($value) => PDO::PARAM_INT,
|
||||
is_null($value) => PDO::PARAM_NULL,
|
||||
default => PDO::PARAM_STR
|
||||
};
|
||||
$stmt->bindValue($key, $value, $dataType);
|
||||
}
|
||||
if ($debug) echo '<pre>SQL: ' . $stmt->queryString . '</pre>';
|
||||
if ($stmt->execute()) return $stmt;
|
||||
|
||||
Reference in New Issue
Block a user