diff --git a/src/Libs/Model.php b/src/Libs/Model.php index d6d8c8f..d9cfc96 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -157,17 +157,13 @@ class Model try { $prepared = $db->prepare($query); foreach (static::$dbQueryVariables as $key => $value) { - // Detectar el tipo de dato para elegir la constante de PDO - $type = PDO::PARAM_STR; // Por defecto string - if (is_int($value)) { - $type = PDO::PARAM_INT; - } - if (is_bool($value)) { - $type = PDO::PARAM_BOOL; - } - if (is_null($value)) { - $type = PDO::PARAM_NULL; - } + // Detect data type to choose the PDO constant + $type = match (gettype($value)) { + 'integer' => PDO::PARAM_INT, + 'boolean' => PDO::PARAM_BOOL, + 'NULL' => PDO::PARAM_NULL, + default => PDO::PARAM_STR, + }; $prepared->bindValue($key, $value, $type); }