From 7c1f9bc226d0af798c4e83dbef4cb9e011ccc53d Mon Sep 17 00:00:00 2001 From: Sergey Tsalkov Date: Tue, 15 Jun 2021 21:44:14 -0700 Subject: [PATCH] DB::$usenull is removed, it makes no sense in a modern PHP context --- db.class.php | 7 ++----- simpletest/BasicTest.php | 10 ---------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/db.class.php b/db.class.php index be263f3..bac4438 100644 --- a/db.class.php +++ b/db.class.php @@ -37,14 +37,12 @@ class DB { public static $pre_sql_handler = false; public static $throw_exception_on_nonsql_error = false; public static $nested_transactions = false; - public static $usenull = true; public static $ssl = array('key' => '', 'cert' => '', 'ca_cert' => '', 'ca_path' => '', 'cipher' => ''); public static $connect_options = array(MYSQLI_OPT_CONNECT_TIMEOUT => 30); // internal protected static $mdb = null; - public static $variables_to_sync = array('param_char', 'named_param_seperator', 'success_handler', 'error_handler', 'throw_exception_on_error', - 'nonsql_error_handler', 'pre_sql_handler', 'throw_exception_on_nonsql_error', 'nested_transactions', 'usenull', 'ssl', 'connect_options'); + public static $variables_to_sync = array('param_char', 'named_param_seperator', 'success_handler', 'error_handler', 'throw_exception_on_error', 'nonsql_error_handler', 'pre_sql_handler', 'throw_exception_on_nonsql_error', 'nested_transactions', 'ssl', 'connect_options'); public static function getMDB() { $mdb = DB::$mdb; @@ -90,7 +88,6 @@ class MeekroDB { public $pre_sql_handler = false; public $throw_exception_on_nonsql_error = false; public $nested_transactions = false; - public $usenull = true; public $ssl = array('key' => '', 'cert' => '', 'ca_cert' => '', 'ca_path' => '', 'cipher' => ''); public $connect_options = array(MYSQLI_OPT_CONNECT_TIMEOUT => 30); @@ -501,7 +498,7 @@ class MeekroDB { else return $this->escape($value); // use __toString() value for objects, when possible } - if (is_null($value)) return $this->usenull ? 'NULL' : "''"; + if (is_null($value)) return 'NULL'; else if (is_bool($value)) return ($value ? 1 : 0); else if (is_int($value)) return $value; else if (is_float($value)) return $value; diff --git a/simpletest/BasicTest.php b/simpletest/BasicTest.php index 69c4d77..02fb98c 100644 --- a/simpletest/BasicTest.php +++ b/simpletest/BasicTest.php @@ -100,16 +100,6 @@ class BasicTest extends SimpleTest { $password = DB::queryFirstField("SELECT password FROM accounts WHERE favorite_word IS NULL"); $this->assert($password === 'goodbye'); - DB::$usenull = false; - DB::insertUpdate('accounts', array( - 'id' => 3, - 'favorite_word' => null, - )); - - $password = DB::queryFirstField("SELECT password FROM accounts WHERE favorite_word=%s AND favorite_word=%s", null, ''); - $this->assert($password === 'goodbye'); - - DB::$usenull = true; DB::insertUpdate('accounts', array( 'id' => 3, 'favorite_word' => null,