DB::$usenull param can be used to decide whether insert()-like commands insert NULL or empty string for NULL

This commit is contained in:
Sergey Tsalkov
2013-06-02 19:22:14 -07:00
parent 9e4cbc28c1
commit e9a55de0b4
2 changed files with 19 additions and 1 deletions

View File

@@ -95,6 +95,21 @@ 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,
));
DB::$param_char = '###';
$bart = DB::queryFirstRow("SELECT * FROM accounts WHERE age IN ###li AND height IN ###ld AND username IN ###ls",
array(15, 25), array(10.371, 150.123), array('Bart', 'Barts'));