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 Yiisoft\Db\Query\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 Yiisoft\Db\Query\Query::where() to instance of Yiisoft\Db\QueryBuilder\Condition\ConditionInterface). Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
getExpressionBuilder() Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
selectExists() Creates a SELECT EXISTS() SQL statement. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
setConditionClasses() Setter for Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder::$conditionClasses property. Yiisoft\Db\QueryBuilder\DQLQueryBuilderInterface
setExpressionBuilders() Setter for Yiisoft\Db\QueryBuilder\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 Yiisoft\Db\Query\Query object.

public abstract build( Yiisoft\Db\Query\QueryInterface $query, array $params = [] ): array
$query Yiisoft\Db\Query\QueryInterface

The 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 buildColumns( array|string $columns ): string
$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 buildCondition( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ): string
$condition array|Yiisoft\Db\Expression\ExpressionInterface|string|null

The condition specification. Please refer to 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 buildExpression( Yiisoft\Db\Expression\ExpressionInterface $expression, array &$params = [] ): string
$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 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 buildFor( array $values ): string
$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 buildFrom( array $tables, array &$params ): string
$tables array

The tables to process.

$params array

The binding parameters to populate.

return string

The FROM clause built from Yiisoft\Db\Query\Query::from().

throws Yiisoft\Db\Exception\NotSupportedException

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

            
buildGroupBy() public abstract method

public abstract buildGroupBy( array $columns, array &$params = [] ): string
$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 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 buildHaving( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ): string
$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 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 buildJoin( array $joins, array &$params ): string
$joins array

The joins to process.

$params array

The binding parameters to populate.

return string

The JOIN clause built from 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 buildLimit( Yiisoft\Db\Expression\ExpressionInterface|integer|null $limit, Yiisoft\Db\Expression\ExpressionInterface|integer|null $offset ): string
$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 buildOrderBy( array $columns, array &$params = [] ): string
$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 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 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 buildOrderByAndLimit( string $sql, array $orderBy, Yiisoft\Db\Expression\ExpressionInterface|integer|null $limit, Yiisoft\Db\Expression\ExpressionInterface|integer|null $offset, array &$params = [] ): string
$sql string

The existing SQL (without ORDER BY/LIMIT/OFFSET).

$orderBy array

The order by columns. Yiisoft\Db\Query\Query::orderBy() for more details on how to specify this parameter.

$limit Yiisoft\Db\Expression\ExpressionInterface|integer|null

The limit number. Yiisoft\Db\Query\Query::limit() For more details.

$offset Yiisoft\Db\Expression\ExpressionInterface|integer|null

The offset number. 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 buildSelect( array $columns, array &$params, boolean $distinct false, string|null $selectOption null ): string
$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 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 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 buildUnion( array $unions, array &$params ): string
$unions array

The UNION queries to process.

$params array

The binding parameters to populate.

return string

The UNION clause built from 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 buildWhere( array|Yiisoft\Db\QueryBuilder\Condition\ConditionInterface|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ): string
$condition array|Yiisoft\Db\QueryBuilder\Condition\ConditionInterface|Yiisoft\Db\Expression\ExpressionInterface|string|null

The condition built from Yiisoft\Db\Query\Query::where().

$params array

The binding parameters to populate.

return string

The WHERE clause built from 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 buildWithQueries( Yiisoft\Db\Query\WithQuery[] $withQueries, array &$params ): string
$withQueries Yiisoft\Db\Query\WithQuery[]

The WITH queries to process.

$params array

The binding parameters to populate.

return string

The WITH clause built from 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 Yiisoft\Db\Query\Query::where() to instance of Yiisoft\Db\QueryBuilder\Condition\ConditionInterface).

See also Yiisoft\Db\QueryBuilder\Condition\ConditionInterface According to conditions class map.

public abstract createConditionFromArray( array $condition ): Yiisoft\Db\QueryBuilder\Condition\ConditionInterface
$condition array

The condition in array format.

throws InvalidArgumentException

                public function createConditionFromArray(array $condition): ConditionInterface;

            
getExpressionBuilder() public abstract method

public abstract getExpressionBuilder( Yiisoft\Db\Expression\ExpressionInterface $expression ): Yiisoft\Db\Expression\ExpressionBuilderInterface
$expression Yiisoft\Db\Expression\ExpressionInterface
return Yiisoft\Db\Expression\ExpressionBuilderInterface

Instance of 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 selectExists( string $rawSql ): string
$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
public abstract setConditionClasses( string[] $classes ): void
$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
public abstract setExpressionBuilders( string[] $builders ): void
$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 setSeparator( string $separator ): void
$separator string

The separator between different fragments of an SQL statement.

Defaults to an empty space. This is mainly used by build() when generating a SQL statement.

                public function setSeparator(string $separator): void;