Skip to content

Commit 3e25076

Browse files
committed
add isNull() & isNotNull() methods, notNull() as a synonym
1 parent 5fc4943 commit 3e25076

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/QueryBuilder.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,43 @@ public function notLike($cond = []): QueryBuilder
591591
return $this;
592592
}
593593

594+
/**
595+
* @param string $field
596+
* @return $this
597+
*/
598+
public function isNull(string $field) {
599+
if (empty($field)) {
600+
$this->setError('Empty $field in ' . __METHOD__);
601+
return $this;
602+
}
603+
604+
$this->where([[$field, 'IS NULL']]);
605+
return $this;
606+
}
607+
608+
/**
609+
* @param string $field
610+
* @return $this
611+
*/
612+
public function isNotNull(string $field) {
613+
if (empty($field)) {
614+
$this->setError('Empty $field in ' . __METHOD__);
615+
return $this;
616+
}
617+
618+
$this->where([[$field, 'IS NOT NULL']]);
619+
return $this;
620+
}
621+
622+
/**
623+
* @param string $field
624+
* @return $this
625+
*/
626+
public function notNull(string $field) {
627+
$this->isNotNull($field);
628+
return $this;
629+
}
630+
594631
/**
595632
* @param int $limit
596633
* @return $this

0 commit comments

Comments
 (0)