whereIsNotNull() and orWhereIsNotNull()

The whereIsNotNull() method allows you to safely filter rows where a column is not NULL. It provides a strict and semantic way to express IS NOT NULL conditions without using raw SQL fragments.

Signature:

public function whereIsNotNull(string $field): self
public function orWhereIsNotNull(string $field): self

Basic Usage

Filter all rows where a column is not NULL:

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

OR Version

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

$db->where('type', 'guest');
$db->orWhereIsNotNull('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 NOT 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 – the method compiles IS NOT NULL natively.

See Also