Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 1.74 KB

Conditional.md

File metadata and controls

64 lines (48 loc) · 1.74 KB

Used in Select, Update and Delete statements.

Used by Grouping and Join clauses.

Constructor

__construct(string $column, string $operator, $value)

All Conditional values are parameterized by default. Please use the Raw class to prevent this behavior if not desired.

Parameter Description
$column Database column to match against
$operator Operator to match against
$value One or more values to match against

Example

use FaaPz\PDO\Clause\Conditional;

// ... WHERE id BETWEEN ? AND ?
$statement->where(
    new Clause\Conditional("id", "BETWEEN", [
        110, 220
    ])
);

// ... WHERE id NOT BETWEEN ? AND ?
$statement->where(
    new Clause\Conditional("id", "NOT BETWEEN", [
        110, 220
    ])
);

// ... WHERE id IN (?, ?, ?, ?)
$statement->where(
    new Clause\Conditional("id", "IN", [
        110, 120, 130, 140
    ])
);

// ... WHERE id NOT IN (?, ?, ?, ?)
$statement->where(
    new Clause\Conditional("id", "NOT IN", [
        110, 120, 130, 140
    ])
);

// ... WHERE first_name LIKE ?
$statement->where(new Clause\Conditional("first_name", "LIKE", "Fab%"));

// ... WHERE first_name NOT LIKE ?
$statement->where(new Clause\Conditional("first_name", "NOT LIKE", "Fab%"));

// ... WHERE first_name IS NULL
$statement->where(new Clause\Conditional("first_name", "IS", null));

// ... WHERE first_name IS NOT NULL
$statement->where(new Clause\Conditional("first_name", "IS NOT", null));