From 5923badf0d63aa91c7600d60270e7a8f9b40f165 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 5 Aug 2015 17:00:42 +1000 Subject: [PATCH 1/2] Changed inc() and dec() methods to support float It's valid to increment a field by a float, this allows both ints and floats to be used in increments and decrements. --- MysqliDb.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MysqliDb.php b/MysqliDb.php index ce67820b..da95618a 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -1280,18 +1280,18 @@ public function now ($diff = null, $func = "NOW()") { /** * Method generates incremental function call - * @param int increment amount. 1 by default + * @param int increment by int or float. 1 by default */ public function inc($num = 1) { - return Array ("[I]" => "+" . (int)$num); + return Array ("[I]" => "+" . $num); } /** * Method generates decrimental function call - * @param int increment amount. 1 by default + * @param int increment by int or float. 1 by default */ public function dec ($num = 1) { - return Array ("[I]" => "-" . (int)$num); + return Array ("[I]" => "-" . $num); } /** From 25baa59fbf358355fad077cb4014ac26d24a2244 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 5 Aug 2015 17:28:55 +1000 Subject: [PATCH 2/2] Update MysqliDb.php --- MysqliDb.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MysqliDb.php b/MysqliDb.php index da95618a..872d327e 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -1283,6 +1283,9 @@ public function now ($diff = null, $func = "NOW()") { * @param int increment by int or float. 1 by default */ public function inc($num = 1) { + if(!is_numeric($num)){ + trigger_error('Argument supplied to inc must be a number', E_USER_ERROR); + } return Array ("[I]" => "+" . $num); } @@ -1291,6 +1294,9 @@ public function inc($num = 1) { * @param int increment by int or float. 1 by default */ public function dec ($num = 1) { + if(!is_numeric($num)){ + trigger_error('Argument supplied to dec must be a number', E_USER_ERROR); + } return Array ("[I]" => "-" . $num); }