Make CPHP deal properly with non-integer numeric values

develop
Sven Slootweg 11 years ago
parent 4aa82d0a86
commit 7db7d5a60a

@ -59,7 +59,7 @@ class CachedPDO extends PDO
{
$type = $this->GuessType($value);
if(is_numeric($value) && $type == PDO::PARAM_STR)
if(preg_match("/^[0-9]+$/", $value) && $type == PDO::PARAM_STR)
{
/* PDO library apparently thinks it's part of a strongly typed language and doesn't do any typecasting.
* We'll do it ourselves then. */
@ -67,6 +67,11 @@ class CachedPDO extends PDO
$type = PDO::PARAM_INT;
}
if($type == PDO::PARAM_STR)
{
$value = strval($value);
}
$statement->bindValue($key, $value, $type);
}
}

Loading…
Cancel
Save