- 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) { 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; throw $pdo;
} }
} }
@ -110,9 +110,6 @@ class PdoObject extends PDO {
throw $e; throw $e;
} }
catch (\Throwable $e) {
throw $e;
}
} }
protected function bindVariables(PDOStatement $statement, array &$parameters) : void protected function bindVariables(PDOStatement $statement, array &$parameters) : void
@ -123,23 +120,11 @@ class PdoObject extends PDO {
} }
else { else {
foreach ($parameters as $key => $value) { foreach ($parameters as $key => $value) {
switch (strtolower(gettype($value))) { $type = match (strtolower(gettype($value))) {
#$type = Pdo::PARAM_BOOL; "boolean", "integer" => Pdo::PARAM_INT,
#break; "null" => Pdo::PARAM_NULL,
default => Pdo::PARAM_STR,
case "boolean": };
case "integer":
$type = Pdo::PARAM_INT;
break;
case "null":
$type = Pdo::PARAM_NULL;
break;
case "string":
default:
$type = Pdo::PARAM_STR;
}
$statement->bindValue($key, $value, $type); $statement->bindValue($key, $value, $type);
} }