From cc8dbe47eb546d9b24a939269126656bdec0c41e Mon Sep 17 00:00:00 2001 From: Sergey Tsalkov Date: Thu, 6 Jun 2013 23:47:09 -0700 Subject: [PATCH] %i should allow big ints on 32 bit systems --- db.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db.class.php b/db.class.php index f07c204..4619d3a 100644 --- a/db.class.php +++ b/db.class.php @@ -506,6 +506,11 @@ class MeekroDB { else if (is_object($ts) && ($ts instanceof DateTime)) return $ts->format('Y-m-d H:i:s'); } + protected function intval($var) { + if (PHP_INT_SIZE == 8) return intval($var); + return floor(doubleval($var)); + } + protected function parseQueryParams() { $args = func_get_args(); $chunkyQuery = call_user_func_array(array($this, 'preparseQueryParams'), $args); @@ -530,7 +535,7 @@ class MeekroDB { } if ($type == 's') $result = $this->escape($arg); - else if ($type == 'i') $result = intval($arg); + else if ($type == 'i') $result = $this->intval($arg); else if ($type == 'd') $result = doubleval($arg); else if ($type == 'b') $result = $this->formatTableName($arg); else if ($type == 'l') $result = $arg; @@ -538,7 +543,7 @@ class MeekroDB { else if ($type == 't') $result = $this->escape($this->parseTS($arg)); else if ($type == 'ls') $result = array_map(array($this, 'escape'), $arg); - else if ($type == 'li') $result = array_map('intval', $arg); + else if ($type == 'li') $result = array_map(array($this, 'intval'), $arg); else if ($type == 'ld') $result = array_map('doubleval', $arg); else if ($type == 'lb') $result = array_map(array($this, 'formatTableName'), $arg); else if ($type == 'll') $result = $arg;