0 follower

Interface Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface

Implemented byYiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder, Yiisoft\Db\QueryBuilder\QueryBuilderInterface

Defines methods for building SQL statements for DQL (data query language).

Public Methods

Hide inherited methods

Method Description Defined By
build() Generates a SELECT SQL statement from a {@see Query} object. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildColumns() Processes columns and quotes them if necessary. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildCondition() Parses the condition specification and generates the corresponding SQL expression. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildExpression() Builds given $expression. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildFor() Builds a SQL for FOR clause. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildFrom() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildGroupBy() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildHaving() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildJoin() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildLimit() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildOrderBy() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildOrderByAndLimit() Builds the ORDER BY and LIMIT/OFFSET clauses and appends them to the given SQL. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildSelect() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildUnion() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildWhere() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
buildWithQueries() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
createConditionFromArray() Transforms one condition defined in array format (as described in {@see Query::where()} to instance of {@see ConditionInterface}). Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
getExpressionBuilder() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
selectExists() Creates a SELECT EXISTS() SQL statement. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
setConditionClasses() Setter for {@see AbstractDQLQueryBuilder::conditionClasses} property. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
setExpressionBuilders() Setter for {@see AbstractDQLQueryBuilder::expressionBuilders} property. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
setSeparator() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface

Method Details

Hide inherited methods

build() public abstract method

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 $params.

throws InvalidArgumentException
throws Yiisoft\Db\Exception\NotSupportedException

                public function build(QueryInterface $query, array $params = []): array;

            
buildColumns() public abstract method

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;

            
buildCondition() public abstract method

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;

            
buildExpression() public abstract method
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;

            
buildFor() public abstract method

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 FOR clause is not supported.

                public function buildFor(array $values): string;

            
buildFrom() public abstract method

public abstract string buildFrom ( array $tables, array &$params )
$tables array

The tables to process.

$params array

The binding parameters to populate.

return string

The FROM clause built from {@see \Yiisoft\Db\Query\Query::from()}.

throws Yiisoft\Db\Exception\NotSupportedException

                public function buildFrom(array $tables, array &$params): string;

            
buildGroupBy() public abstract method

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 GROUP BY clause

throws Yiisoft\Db\Exception\NotSupportedException

                public function buildGroupBy(array $columns, array &$params = []): string;

            
buildHaving() public abstract method

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 HAVING clause built from {@see \Yiisoft\Db\Query\Query::having()}.

throws InvalidArgumentException
throws Yiisoft\Db\Exception\NotSupportedException

                public function buildHaving(array|ExpressionInterface|string|null $condition, array &$params = []): string;

            
buildJoin() public abstract method

public abstract string buildJoin ( array $joins, array &$params )
$joins array

The joins to process.

$params array

The binding parameters to populate.

return string

The JOIN clause built from {@see \Yiisoft\Db\Query\Query::join()}.

throws InvalidArgumentException

If the $joins parameter isn't in proper format.

throws Yiisoft\Db\Exception\NotSupportedException

                public function buildJoin(array $joins, array &$params): string;

            
buildLimit() public abstract method

See also:

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 LIMIT and OFFSET clauses.

throws Yiisoft\Db\Exception\NotSupportedException

                public function buildLimit(ExpressionInterface|int|null $limit, ExpressionInterface|int|null $offset): string;

            
buildOrderBy() public abstract method

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 ORDER BY clause built from {@see \Yiisoft\Db\Query\Query::orderBy()}.

throws Yiisoft\Db\Exception\NotSupportedException

                public function buildOrderBy(array $columns, array &$params = []): string;

            
buildOrderByAndLimit() public abstract method

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 ORDER BY/LIMIT/OFFSET).

$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 ORDER BY/LIMIT/OFFSET (if any).

throws Yiisoft\Db\Exception\NotSupportedException

                public function buildOrderByAndLimit(
    string $sql,
    array $orderBy,
    ExpressionInterface|int|null $limit,
    ExpressionInterface|int|null $offset,
    array &$params = [],
): string;

            
buildSelect() public abstract method

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 DISTINCT or not.

$selectOption string|null

The SELECT option to use (for example, SQL_CALC_FOUND_ROWS).

return string

The SELECT clause built from {@see \Yiisoft\Db\Query\Query::select()}.

throws InvalidArgumentException

                public function buildSelect(
    array $columns,
    array &$params,
    bool $distinct = false,
    ?string $selectOption = null,
): string;

            
buildUnion() public abstract method

public abstract string buildUnion ( array $unions, array &$params )
$unions array

The UNION queries to process.

$params array

The binding parameters to populate.

return string

The UNION clause built from {@see \Yiisoft\Db\Query\Query::union()}.

throws InvalidArgumentException
throws Yiisoft\Db\Exception\NotSupportedException

                public function buildUnion(array $unions, array &$params): string;

            
buildWhere() public abstract method

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 WHERE clause built from {@see \Yiisoft\Db\Query\Query::where()}.

throws InvalidArgumentException
throws Yiisoft\Db\Exception\NotSupportedException

                public function buildWhere(
    array|string|ConditionInterface|ExpressionInterface|null $condition,
    array &$params = [],
): string;

            
buildWithQueries() public abstract method

public abstract string buildWithQueries ( Yiisoft\Db\Query\WithQuery[] $withQueries, array &$params )
$withQueries Yiisoft\Db\Query\WithQuery[]

The WITH queries to process.

$params array

The binding parameters to populate.

return string

The WITH clause built from {@see \Yiisoft\Db\Query\Query::withQuery()}.

throws InvalidArgumentException
throws Yiisoft\Db\Exception\NotSupportedException

                public function buildWithQueries(array $withQueries, array &$params): string;

            
createConditionFromArray() public abstract method

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;

            
getExpressionBuilder() public abstract method

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;

            
selectExists() public abstract method

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 SELECT EXISTS() SQL statement.

                public function selectExists(string $rawSql): string;

            
setConditionClasses() public abstract method

Setter for {@see AbstractDQLQueryBuilder::conditionClasses} property.

public abstract void setConditionClasses ( string[] $classes )
$classes string[]

Map of condition aliases to condition classes. For example:

['LIKE' => \Yiisoft\Db\Condition\LikeCondition::class]

                public function setConditionClasses(array $classes): void;

            
setExpressionBuilders() public abstract method

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;

            
setSeparator() public abstract method

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;