Skip to content

Commit 5fc4943

Browse files
committed
add IS NULL and IS NOT NULL conditions
1 parent 18816d2 commit 5fc4943

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/QueryBuilder.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ private function prepareAliases($items, bool $asArray = false)
330330
*/
331331
private function prepareConditions($where): array
332332
{
333-
$result = ['sql' => '', 'values' => []];
333+
$result = [
334+
'sql' => '',
335+
'values' => [],
336+
];
334337
$sql = '';
335338

336339
if (empty($where)) {
@@ -346,7 +349,14 @@ private function prepareConditions($where): array
346349
if (count($cond) === 2) {
347350
$field = $this->prepareField($cond[0]);
348351
$value = $cond[1];
349-
if (is_array($value)) {
352+
353+
if (strtolower($value) == 'is null') {
354+
$operator = 'IS NULL';
355+
$sql .= "({$field} {$operator})";
356+
} else if (strtolower($value) == 'is not null') {
357+
$operator = 'IS NOT NULL';
358+
$sql .= "({$field} {$operator})";
359+
} else if (is_array($value)) {
350360
$operator = 'IN';
351361
$values = rtrim(str_repeat("?,", count($value)), ',');
352362
$sql .= "({$field} {$operator} ({$values}))";

0 commit comments

Comments
 (0)