From 7db7d5a60af8ff250813771793542042e842af24 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 2 Mar 2013 05:52:33 +0100 Subject: [PATCH] Make CPHP deal properly with non-integer numeric values --- include.mysql.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include.mysql.php b/include.mysql.php index e84a556..b5939a9 100644 --- a/include.mysql.php +++ b/include.mysql.php @@ -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); } }