Class yii\elasticsearch\QueryBuilder

Inheritanceyii\elasticsearch\QueryBuilder » yii\base\BaseObject
Available since version2.0

QueryBuilder builds an elasticsearch query based on the specification given as a yii\elasticsearch\Query object.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$db yii\elasticsearch\Connection The database connection. yii\elasticsearch\QueryBuilder

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. yii\elasticsearch\QueryBuilder
build() Generates query from a yii\elasticsearch\Query object. yii\elasticsearch\QueryBuilder
buildCondition() Parses the condition specification and generates the corresponding SQL expression. yii\elasticsearch\QueryBuilder
buildOrderBy() Adds order by condition to the query yii\elasticsearch\QueryBuilder
buildQueryFromWhere() yii\elasticsearch\QueryBuilder

Property Details

$db public property

The database connection.

Method Details

__construct() public method

Constructor.

public void __construct ( $connection, $config = [] )
$connection yii\elasticsearch\Connection

The database connection.

$config array

Name-value pairs that will be used to initialize the object properties

build() public method

Generates query from a yii\elasticsearch\Query object.

public array build ( $query )
$query yii\elasticsearch\Query

The yii\elasticsearch\Query object from which the query will be generated

return array

The generated SQL statement (the first array element) and the corresponding parameters to be bound to the SQL statement (the second array element).

buildCompositeInCondition() protected method

protected void buildCompositeInCondition ( $operator, $columns, $values )
$operator
$columns
$values
buildCondition() public method

Parses the condition specification and generates the corresponding SQL expression.

public string buildCondition ( $condition )
$condition string|array

The condition specification. Please refer to yii\elasticsearch\Query::where() on how to specify a condition.

return string

The generated SQL expression

throws \yii\base\InvalidParamException

if unknown operator is used in query

throws \yii\base\NotSupportedException

if string conditions are used in where

buildOrderBy() public method

Adds order by condition to the query

public void buildOrderBy ( $columns )
$columns
buildQueryFromWhere() public method

public void buildQueryFromWhere ( $condition )
$condition