Inheritance diagram for Select:Represents a SELECT query.
Protected Properties | |
| string | $alias |
| Human-readable alias. More... | |
| Closure | $fetcher |
| A callback to yield each result. More... | |
| Column[] | $refs = [] |
| Columns that can be accessed by an outer query. More... | |
| AbstractTable | $table |
| The original table given to the constructor. More... | |
Protected Properties inherited from AbstractTable | |
| DB | $db |
Public Static Methods | |
| magic static self | factory (DB $db, string|AbstractTable $table, string|array $expressions=[' *']) |
Public Methods | |
| __construct (DB $db, $table, $expressions=[' *']) | |
| Statement | __invoke (array $args=[]) |
| string | __toString () |
| Returns the alias. More... | |
| int | count (array $args=[]) |
Clones the instance and selects COUNT(*), using the given execution arguments. More... | |
| Statement | execute (array $args=[]) |
| Executes the select, preparing a statement first if arguments are used. More... | |
| array | getAll (array $args=[]) |
| Executes and fetches all results. More... | |
| Column[] | getColumns () |
| Generator | getEach (array $args=[]) |
| Executes and yields from the fetcher. More... | |
| mixed | getFirst (array $args=[]) |
| Executes and returns from the fetcher. More... | |
| Generator | getIterator () |
| Executes without arguments and yields from the fetcher. More... | |
| null mixed | getResult (array $args=[]) |
| Executes and returns the first column of the first row. More... | |
| $this | group (string $column) |
Adds a column to the GROUP BY clause. More... | |
| $this | having (string ... $conditions) |
Adds conditions to the HAVING clause. More... | |
| $this | intersect (Select $select) |
INTERSECT SELECT ... More... | |
| Predicate | isEmpty () |
NOT EXISTS (SELECT ...) More... | |
| Predicate | isNotEmpty () |
EXISTS (SELECT ...) More... | |
| $this | join ($table, string ... $conditions) |
Adds INNER JOIN $table ON $conditions More... | |
| $this | joinLeft ($table, string ... $conditions) |
Adds LEFT JOIN $table ON $conditions More... | |
| $this | limit (int $limit, int $offset=0) |
Sets the LIMIT clause. More... | |
| null Column | offsetGet ($ref) |
| Returns a reference Column for an outer query, qualified by the instance's alias. More... | |
| $this | order (string $order) |
Sets the ORDER BY clause. More... | |
| Statement | prepare () |
| $this | setAlias (string $alias) |
| $this | setColumns ($expressions=[' *']) |
| Compiles the column list and exposed reference columns. More... | |
| $this | setFetcher (Closure $fetcher) |
| string | toSql () |
SELECT ... More... | |
| string | toSubquery () |
(SELECT ...) AS ALIAS More... | |
| $this | UNION (Select $select) |
UNION SELECT ... More... | |
| $this | unionAll (Select $select) |
UNION ALL SELECT ... More... | |
| $this | where (string ... $conditions) |
Adds conditions to the WHERE clause. More... | |
Public Methods inherited from AbstractTable | |
| __construct (DB $db) | |
| bool | offsetExists ($column) |
| void | offsetSet ($offset, $value) |
| Throws. More... | |
| void | offsetUnset ($name) |
| Throws. More... | |
|
protected |
Human-readable alias.
|
protected |
A callback to yield each result.
Defaults to yielding directly from the statement.
(Statement $statement):Generator
|
protected |
Columns that can be accessed by an outer query.
|
protected |
The original table given to the constructor.
| __construct | ( | DB | $db, |
| $table, | |||
$expressions = ['*'] |
|||
| ) |
| DB | $db | |
| string | AbstractTable | $table | |
| string | string[] | $expressions |
|
final |
| int count | ( | array | $args = [] | ) |
Clones the instance and selects COUNT(*), using the given execution arguments.
| array | $args | Execution arguments. |
| Statement execute | ( | array | $args = [] | ) |
Executes the select, preparing a statement first if arguments are used.
| array | $args |
|
static |
| array getAll | ( | array | $args = [] | ) |
Executes and fetches all results.
| array | $args | Execution arguments. |
| Column [] getColumns | ( | ) |
Reimplemented from AbstractTable.
| Generator getEach | ( | array | $args = [] | ) |
Executes and yields from the fetcher.
This is preferable over fetchAll() for iterating large result sets.
| array | $args | Execution arguments. |
| mixed getFirst | ( | array | $args = [] | ) |
Executes and returns from the fetcher.
| array | $args |
| Generator getIterator | ( | ) |
Executes without arguments and yields from the fetcher.
| null mixed getResult | ( | array | $args = [] | ) |
Executes and returns the first column of the first row.
Use this for reductive queries that only have a single result.
| $this group | ( | string | $column | ) |
| $this having | ( | string ... | $conditions | ) |
| $this intersect | ( | Select | $select | ) |
| Predicate isEmpty | ( | ) |
NOT EXISTS (SELECT ...)
| Predicate isNotEmpty | ( | ) |
EXISTS (SELECT ...)
| $this join | ( | $table, | |
| string ... | $conditions | ||
| ) |
| $this joinLeft | ( | $table, | |
| string ... | $conditions | ||
| ) |
| $this limit | ( | int | $limit, |
| int | $offset = 0 |
||
| ) |
| null Column offsetGet | ( | $ref | ) |
Returns a reference Column for an outer query, qualified by the instance's alias.
| int | string | $ref | Ordinal or reference name. |
Reimplemented from AbstractTable.
| $this order | ( | string | $order | ) |
| $this setAlias | ( | string | $alias | ) |
| string | $alias |
| $this setColumns | ( | $expressions = ['*'] | ) |
Compiles the column list and exposed reference columns.
Columns may be expressions, like COUNT(*) Unless an alias is given for such expressions, they can't be referenced externally.
| string | string[] | $expressions | Keyed by alias if applicable. |
| $this setFetcher | ( | Closure | $fetcher | ) |
| Closure | $fetcher |
| string toSql | ( | ) |
SELECT ...
| string toSubquery | ( | ) |
(SELECT ...) AS ALIAS
| $this where | ( | string ... | $conditions | ) |