- Refactored PdoObject class a bit

This commit is contained in:
Dave M. 2025-06-10 14:46:37 +00:00
parent fb644b0b0a
commit b53327a6ed

View File

@ -51,7 +51,7 @@ class PdoObject extends PDO {
}
}
catch(\PDOException $pdo) {
if ( substr($pdo->getMessage(), 0, 30) !== 'There is no active transaction' ) {
if (!str_starts_with($pdo->getMessage(), 'There is no active transaction')) {
throw $pdo;
}
}
@ -110,9 +110,6 @@ class PdoObject extends PDO {
throw $e;
}
catch (\Throwable $e) {
throw $e;
}
}
protected function bindVariables(PDOStatement $statement, array &$parameters) : void
@ -123,23 +120,11 @@ class PdoObject extends PDO {
}
else {
foreach ($parameters as $key => $value) {
switch (strtolower(gettype($value))) {
#$type = Pdo::PARAM_BOOL;
#break;
case "boolean":
case "integer":
$type = Pdo::PARAM_INT;
break;
case "null":
$type = Pdo::PARAM_NULL;
break;
case "string":
default:
$type = Pdo::PARAM_STR;
}
$type = match (strtolower(gettype($value))) {
"boolean", "integer" => Pdo::PARAM_INT,
"null" => Pdo::PARAM_NULL,
default => Pdo::PARAM_STR,
};
$statement->bindValue($key, $value, $type);
}