diff --git a/src/Common/PdoObject.php b/src/Common/PdoObject.php index b05ed96..522ceb1 100644 --- a/src/Common/PdoObject.php +++ b/src/Common/PdoObject.php @@ -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); }