Interface Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
| Implemented by | Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder, Yiisoft\Db\QueryBuilder\QueryBuilderInterface |
|---|
Defines methods for building SQL statements for DQL (data query language).
Public Methods
Method Details
Generates a SELECT SQL statement from a {@see Query} object.
| public abstract array build ( Yiisoft\Db\Query\QueryInterface $query, array $params = [] ) | ||
| $query | Yiisoft\Db\Query\QueryInterface |
The {@see \Yiisoft\Db\Query\Query} object from which the SQL statement will generated. |
| $params | array |
The parameters to bind to the generated SQL statement. These parameters will be included in the result, with the more parameters generated during the query building process. |
| return | array |
The generated SQL statement (the first array element) and the corresponding parameters to bind
to the SQL statement (the second array element). The parameters returned include those provided in |
|---|---|---|
| throws | InvalidArgumentException | |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function build(QueryInterface $query, array $params = []): array;
Processes columns and quotes them if necessary.
It will join all columns into a string with comma as separators.
| public abstract string buildColumns ( array|string $columns ) | ||
| $columns | array|string |
The columns to process. |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
|---|---|---|
public function buildColumns(array|string $columns): string;
Parses the condition specification and generates the corresponding SQL expression.
| public abstract string buildCondition ( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ) | ||
| $condition | array|Yiisoft\Db\Expression\ExpressionInterface|string|null |
The condition specification. Please refer to {@see \Yiisoft\Db\Query\Query::where()} on how to specify a condition. |
| $params | array |
The binding parameters to populate. |
| throws | InvalidArgumentException | |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildCondition(array|string|ExpressionInterface|null $condition, array &$params = []): string;
Builds given $expression.
See also:
| public abstract string buildExpression ( Yiisoft\Db\Expression\ExpressionInterface $expression, array &$params = [] ) | ||
| $expression | Yiisoft\Db\Expression\ExpressionInterface |
The expression to build. |
| $params | array |
The parameters to bind to the generated SQL statement. These parameters will be included in the result with the more parameters generated during the expression building process. |
| return | string |
The SQL statement that won't be neither quoted nor encoded before passing to DBMS. |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException |
When $expression building isn't supported by the {@see \Yiisoft\Db\QueryBuilder\QueryBuilderInterface} implementation. |
public function buildExpression(ExpressionInterface $expression, array &$params = []): string;
Builds a SQL for FOR clause.
| public abstract string buildFor ( array $values ) | ||
| $values | array |
The value to build. |
| return | string |
The result SQL. |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException |
When the |
public function buildFor(array $values): string;
| public abstract string buildFrom ( array $tables, array &$params ) | ||
| $tables | array |
The tables to process. |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildFrom(array $tables, array &$params): string;
| public abstract string buildGroupBy ( array $columns, array &$params = [] ) | ||
| $columns | array |
The columns to group by. Each column can be a string representing a column name or an array representing a column specification. Please refer to {@see \Yiisoft\Db\Query\Query::groupBy()} on how to specify this parameter. |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildGroupBy(array $columns, array &$params = []): string;
| public abstract string buildHaving ( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ) | ||
| $condition | array|Yiisoft\Db\Expression\ExpressionInterface|string|null |
The condition specification. |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | InvalidArgumentException | |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildHaving(array|ExpressionInterface|string|null $condition, array &$params = []): string;
| public abstract string buildJoin ( array $joins, array &$params ) | ||
| $joins | array |
The joins to process. |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | InvalidArgumentException |
If the |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildJoin(array $joins, array &$params): string;
See also:
- Yiisoft\Db\Query\Query::limit() For more details.
- Yiisoft\Db\Query\Query::offset() For more details.
| public abstract string buildLimit ( Yiisoft\Db\Expression\ExpressionInterface|integer|null $limit, Yiisoft\Db\Expression\ExpressionInterface|integer|null $offset ) | ||
| $limit | Yiisoft\Db\Expression\ExpressionInterface|integer|null |
The limit number. |
| $offset | Yiisoft\Db\Expression\ExpressionInterface|integer|null |
The offset number. |
| return | string |
The |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildLimit(ExpressionInterface|int|null $limit, ExpressionInterface|int|null $offset): string;
| public abstract string buildOrderBy ( array $columns, array &$params = [] ) | ||
| $columns | array |
The columns to order by. Each column can be a string representing a column name or an array representing a column specification. Please refer to {@see \Yiisoft\Db\Query\Query::orderBy()} on how to specify this parameter. |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildOrderBy(array $columns, array &$params = []): string;
Builds the ORDER BY and LIMIT/OFFSET clauses and appends them to the given SQL.
| public abstract string buildOrderByAndLimit ( string $sql, array $orderBy, Yiisoft\Db\Expression\ExpressionInterface|integer|null $limit, Yiisoft\Db\Expression\ExpressionInterface|integer|null $offset, array &$params = [] ) | ||
| $sql | string |
The existing SQL (without |
| $orderBy | array |
The order by columns. {@see \Yiisoft\Db\Query\Query::orderBy()} for more details on how to specify this parameter. |
| $limit | Yiisoft\Db\Expression\ExpressionInterface|integer|null |
The limit number. {@see \Yiisoft\Db\Query\Query::limit()} For more details. |
| $offset | Yiisoft\Db\Expression\ExpressionInterface|integer|null |
The offset number. {@see \Yiisoft\Db\Query\Query::offset()} For more details. |
| $params | array |
The binding parameters to populate. |
| return | string |
The SQL completed with |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildOrderByAndLimit(
string $sql,
array $orderBy,
ExpressionInterface|int|null $limit,
ExpressionInterface|int|null $offset,
array &$params = [],
): string;
| public abstract string buildSelect ( array $columns, array &$params, boolean $distinct = false, string|null $selectOption = null ) | ||
| $columns | array |
The columns to select. Each column can be a string representing a column name or an array representing a column specification. Please refer to {@see \Yiisoft\Db\Query\Query::select()} on how to specify this parameter. |
| $params | array |
The binding parameters to populate. |
| $distinct | boolean |
Whether to add |
| $selectOption | string|null |
The |
| return | string |
The |
|---|---|---|
| throws | InvalidArgumentException | |
public function buildSelect(
array $columns,
array &$params,
bool $distinct = false,
?string $selectOption = null,
): string;
| public abstract string buildUnion ( array $unions, array &$params ) | ||
| $unions | array |
The |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | InvalidArgumentException | |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildUnion(array $unions, array &$params): string;
| public abstract string buildWhere ( array|Yiisoft\Db\QueryBuilder\Condition\ConditionInterface|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ) | ||
| $condition | array|Yiisoft\Db\QueryBuilder\Condition\ConditionInterface|Yiisoft\Db\Expression\ExpressionInterface|string|null |
The condition built from {@see \Yiisoft\Db\Query\Query::where()}. |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | InvalidArgumentException | |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildWhere(
array|string|ConditionInterface|ExpressionInterface|null $condition,
array &$params = [],
): string;
| public abstract string buildWithQueries ( Yiisoft\Db\Query\WithQuery[] $withQueries, array &$params ) | ||
| $withQueries | Yiisoft\Db\Query\WithQuery[] |
The |
| $params | array |
The binding parameters to populate. |
| return | string |
The |
|---|---|---|
| throws | InvalidArgumentException | |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function buildWithQueries(array $withQueries, array &$params): string;
Transforms one condition defined in array format (as described in {@see Query::where()} to instance of {@see ConditionInterface}).
See also Yiisoft\Db\QueryBuilder\Condition\ConditionInterface According to conditions class map.
| public abstract Yiisoft\Db\QueryBuilder\Condition\ConditionInterface createConditionFromArray ( array $condition ) | ||
| $condition | array |
The condition in array format. |
| throws | InvalidArgumentException | |
|---|---|---|
public function createConditionFromArray(array $condition): ConditionInterface;
| public abstract Yiisoft\Db\Expression\ExpressionBuilderInterface getExpressionBuilder ( Yiisoft\Db\Expression\ExpressionInterface $expression ) | ||
| $expression | Yiisoft\Db\Expression\ExpressionInterface | |
| return | Yiisoft\Db\Expression\ExpressionBuilderInterface |
Instance of {@see \Yiisoft\Db\Expression\ExpressionBuilderInterface} for the given expression. |
|---|---|---|
| throws | Yiisoft\Db\Exception\NotSupportedException | |
public function getExpressionBuilder(ExpressionInterface $expression): ExpressionBuilderInterface;
Creates a SELECT EXISTS() SQL statement.
| public abstract string selectExists ( string $rawSql ) | ||
| $rawSql | string |
The sub-query in a raw form to select from. |
| return | string |
The |
|---|---|---|
public function selectExists(string $rawSql): string;
Setter for {@see AbstractDQLQueryBuilder::conditionClasses} property.
| public abstract void setConditionClasses ( string[] $classes ) | ||
| $classes | string[] |
Map of condition aliases to condition classes. For example:
|
public function setConditionClasses(array $classes): void;
Setter for {@see AbstractDQLQueryBuilder::expressionBuilders} property.
| public abstract void setExpressionBuilders ( string[] $builders ) | ||
| $builders | string[] |
Array of builders to merge with the pre-defined ones in property. |
public function setExpressionBuilders(array $builders): void;
| public abstract void setSeparator ( string $separator ) | ||
| $separator | string |
The separator between different fragments of an SQL statement. Defaults to an empty space. This is mainly used by {@see \Yiisoft\Db\QueryBuilder\build()} when generating a SQL statement. |
public function setSeparator(string $separator): void;
Signup or Login in order to comment.