FaaPz\PDO\AdvancedStatement extends AbstractStatement

November 6, 2021 ยท View on GitHub

Methods

join(JoinInterface $clause): self

ParameterDescription
$clauseJoin clauses to apply

Example

use FaaPz\PDO\Clause\Conditional;
use FaaPz\PDO\Clause\Join;

// ... LEFT JOIN table2 ON table2.fk = table1.id
$statement->join(new Join("table2", new Conditional('table2.fk', '=', new Raw('table1.id'))), 'LEFT');

where(ConditionalInterface $clause): self

ParameterDescription
$clauseConditional or Grouping clauses to filter by

Example

use FaaPz\PDO\Clause\Conditional;

// ... WHERE col = 1
$statement->where(new Conditional('col', '=', 1));

orderBy(string $column, string $direction = ''): self

ParameterDescription
$columnThe column to order this query by
$directionThe order the column should be sorted in

Example

// ... ORDER BY col1, col2 ASC, col3 DESC
$statement->orderBy('col1')
          ->orderBy('col2', 'ASC')
          ->orderBy('col3', 'DESC');

limit(LimitInterface $limit): self

Adds a Limit clause to this statement.

ParameterDescription
$clauseLimit clause

Example

use FaaPz\PDO\Clause\Limit;

// ... LIMIT ? OFFSET ?
$statement->limit(new Limit(10 , 30));