Skip to content

Is Null Or Not

Gilberto Junior edited this page Nov 29, 2019 · 3 revisions

Operators

Is Null

A operator that represents the field's value is null.

Syntax

public function isNull(string $column): self;

Alias

public function null(string $column): self;

Example 1

PHP's way:

$repository->isNull('deleted_at');

SQL's Representation:

WHERE deleted_at IS NULL;

Example 2

PHP's way:

$repository->null('canceled_at');

SQL's Representation:

WHERE canceled_at IS NULL;

Example 3

PHP's way:

$repository->isNull('email')
    ->orIsNull('status');

SQL's Representation:

WHERE email IS NULL OR status IS NULL;

Example 4

PHP's way:

$repository->null('created_at')
    ->orNull('user_id');

SQL's Representation:

WHERE created_at IS NULL OR user_id IS NULL;

Is Not Null

A operator that represents field's value is not null.

Syntax

public function isNotNull(string $column): self;

Alias

public function notNull(string $column): self;

Example 1

PHP's way:

$repository->isNotNull('name');

SQL's Representation:

WHERE name IS NOT NULL;

Example 2

PHP's way:

$repository->notNull('paid_at');

SQL's Representation:

WHERE paid_at IS NOT NULL;

Example 3

PHP's way:

$repository->isNotNull('delivery_at')
    ->orIsNotNull('email');

SQL's Representation:

WHERE delivery_at IS NOT NULL OR email IS NOT NULL;

Example 4

PHP's way:

$repository->notNull('address')
    ->orNotNull('city');

SQL's Representation:

WHERE address IS NOT NULL OR city IS NOT NULL;

🡄 Is Less Than Equal To | Grouped Conditions 🡆