From: Roland Häder Date: Sat, 30 Nov 2013 21:31:21 +0000 (+0000) Subject: Disallow subtraction on unsigned columns: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7770a9545292d628afd2be4f58f86da5c9139619;p=mailer.git Disallow subtraction on unsigned columns: When you use subtraction between integer values where one is of type UNSIGNED, the result is unsigned unless the NO_UNSIGNED_SUBTRACTION SQL mode is enabled. See Section 12.10, “Cast Functions and Operators”. --- diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 24fb6e42c8..fd86300e36 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -231,6 +231,9 @@ function sqlConnectToDatabase ($host, $login, $password, $file, $line) { `character_set_connection`='utf8', `character_set_database`='utf8', `character_set_server`='utf8'", $file . ':' . __FUNCTION__, $line . ':' . __LINE__); + + // Disallow subtraction for unsigned columns + sqlQuery("SET `sql_mode`='NO_UNSIGNED_SUBTRACTION'", $file . ':' . __FUNCTION__, $line . ':' . __LINE__); } // END - if // Return the resource diff --git a/inc/db/lib-mysqli.php b/inc/db/lib-mysqli.php index 27798e9bb2..9a1be87301 100644 --- a/inc/db/lib-mysqli.php +++ b/inc/db/lib-mysqli.php @@ -218,6 +218,9 @@ function sqlConnectToDatabase ($host, $login, $password, $file, $line) { `character_set_connection`='utf8', `character_set_database`='utf8', `character_set_server`='utf8'", $file . ':' . __FUNCTION__, $line . ':' . __LINE__); + + // Disallow subtraction for unsigned columns + sqlQuery("SET `sql_mode`='NO_UNSIGNED_SUBTRACTION'", $file . ':' . __FUNCTION__, $line . ':' . __LINE__); } // END - if // Any errors encountered?