whereIsNull() and orWhereIsNull()

The whereIsNull() method allows you to safely filter rows where a column contains a NULL value. It provides a strict and semantic way to express IS NULL conditions without using raw strings or ambiguous comparisons.

Signature:

public function whereIsNull(string $field): self
public function orWhereIsNull(string $field): self

Basic Usage

Filter all rows where a column is NULL:

$db->whereIsNull('deleted_at');
$users = $db->get('users');

OR Version

orWhereIsNull() behaves the same but adds the clause using OR logic:

$db->where('type', 'guest');
$db->orWhereIsNull('last_seen');

Allowed Input

  • $field must be a valid column name (alphanumeric with optional dot notation).
  • No second argument is allowed – the check is hardcoded as IS NULL.

Security

Column names are validated for safety. Any invalid or dangerous input will throw an InvalidArgumentException. No value is bound or passed to the SQL engine in this case – the method compiles IS NULL natively.

See Also