Class Yiisoft\Db\Query\Query
| Inheritance | Yiisoft\Db\Query\Query |
|---|---|
| Implements | Yiisoft\Db\Query\QueryInterface |
Represents a SELECT SQL statement in a way that's independent of DBMS.
Provides a set of methods to ease the specification of different clauses in a SELECT statement.
You can chain these methods together.
By calling createCommand(), you can get a Yiisoft\Db\Command\CommandInterface instance which can be further used to perform/execute the DB query in a database.
For example,
$query = new Query;
// compose the query
$query->select('id, name')->from('user')->limit(10);
// build and execute the query
$rows = $query->all();
// alternatively, you can create DB command and execute it
$command = $query->createCommand();
// $command->sql returns the actual SQL
$rows = $command->queryAll();
Query internally uses the Yiisoft\Db\QueryBuilder\AbstractQueryBuilder class to generate the SQL statement.
Protected Properties
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| index() | Yiisoft\Db\Query\Query | |
| queryScalar() | Queries a scalar value by setting select() first. | Yiisoft\Db\Query\Query |
Property Details
Method Details
| public __construct( Yiisoft\Db\Connection\ConnectionInterface $db ): mixed | ||
| $db | Yiisoft\Db\Connection\ConnectionInterface | |
public function __construct(protected ConnectionInterface $db) {}
| public addFor( string|array|null $value ): Yiisoft\Db\Query\Query | ||
| $value | string|array|null | |
public function addFor(string|array|null $value): static
{
if ($value === null) {
return $this;
}
if (is_array($value)) {
$this->for = [...$this->for, ...$value];
return $this;
}
$this->for[] = $value;
return $this;
}
| public addGroupBy( array|string|Yiisoft\Db\Expression\ExpressionInterface $columns ): Yiisoft\Db\Query\Query | ||
| $columns | array|string|Yiisoft\Db\Expression\ExpressionInterface | |
public function addGroupBy(array|string|ExpressionInterface $columns): static
{
if ($columns instanceof ExpressionInterface) {
$columns = [$columns];
} elseif (!is_array($columns)) {
/** @var string[] */
$columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY);
}
if ($this->groupBy === []) {
$this->groupBy = $columns;
} else {
$this->groupBy = array_merge($this->groupBy, $columns);
}
return $this;
}
| public addOrderBy( array|string|Yiisoft\Db\Expression\ExpressionInterface $columns ): Yiisoft\Db\Query\Query | ||
| $columns | array|string|Yiisoft\Db\Expression\ExpressionInterface | |
public function addOrderBy(array|string|ExpressionInterface $columns): static
{
$columns = $this->normalizeOrderBy($columns);
if ($this->orderBy === []) {
$this->orderBy = $columns;
} else {
$this->orderBy = array_merge($this->orderBy, $columns);
}
return $this;
}
| public addParams( array $params ): Yiisoft\Db\Query\Query | ||
| $params | array | |
public function addParams(array $params): static
{
if (empty($params)) {
return $this;
}
if (empty($this->params)) {
$this->params = $params;
return $this;
}
if (is_int(key($params))) {
array_push($this->params, ...$params);
return $this;
}
$this->params = [...$this->params, ...$params];
return $this;
}
public function addSelect(array|bool|float|int|string|ExpressionInterface $columns): static
{
if ($this->select === []) {
return $this->select($columns);
}
$this->select = array_merge($this->select, $this->normalizeSelect($columns));
return $this;
}
| public addWithQuery( Yiisoft\Db\Query\QueryInterface|string $query, Yiisoft\Db\Expression\ExpressionInterface|string $alias, boolean $recursive = false ): Yiisoft\Db\Query\Query | ||
| $query | Yiisoft\Db\Query\QueryInterface|string | |
| $alias | Yiisoft\Db\Expression\ExpressionInterface|string | |
| $recursive | boolean | |
public function addWithQuery(
QueryInterface|string $query,
ExpressionInterface|string $alias,
bool $recursive = false,
): static {
$this->withQueries[] = new WithQuery($query, $alias, $recursive);
return $this;
}
| public all( ): array |
public function all(): array
{
if ($this->emulateExecution === true) {
return [];
}
return $this->index($this->createCommand()->queryAll());
}
| public andFilterCompare( string $column, string|null $value, string $defaultOperator = '=' ): Yiisoft\Db\Query\Query | ||
| $column | string | |
| $value | string|null | |
| $defaultOperator | string | |
public function andFilterCompare(string $column, ?string $value, string $defaultOperator = '='): static
{
$operator = $defaultOperator;
if (preg_match('/^(<>|>=|>|<=|<|=)/', (string) $value, $matches)) {
$operator = $matches[1];
$value = substr((string) $value, strlen($operator));
}
return $this->andFilterWhere([$operator, $column, $value]);
}
| public andFilterHaving( array $condition ): Yiisoft\Db\Query\Query | ||
| $condition | array | |
public function andFilterHaving(array $condition): static
{
$condition = $this->filterCondition($condition);
if ($condition !== []) {
$this->andHaving($condition);
}
return $this;
}
| public andFilterWhere( array $condition ): Yiisoft\Db\Query\Query | ||
| $condition | array | |
public function andFilterWhere(array $condition): static
{
$condition = $this->filterCondition($condition);
if ($condition !== []) {
$this->andWhere($condition);
}
return $this;
}
| public andHaving( array|string|Yiisoft\Db\Expression\ExpressionInterface $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | array|string|Yiisoft\Db\Expression\ExpressionInterface | |
| $params | array | |
public function andHaving(array|string|ExpressionInterface $condition, array $params = []): static
{
if ($this->having === null) {
$this->having = $condition;
} elseif (
is_array($this->having)
&& isset($this->having[0])
&& strcasecmp((string) $this->having[0], 'and') === 0
) {
$this->having[] = $condition;
} else {
$this->having = ['and', $this->having, $condition];
}
$this->addParams($params);
return $this;
}
| public andWhere( mixed $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | mixed | |
| $params | array | |
public function andWhere($condition, array $params = []): static
{
if ($this->where === null) {
$this->where = $condition;
} elseif (
is_array($this->where)
&& isset($this->where[0])
&& strcasecmp((string) $this->where[0], 'and') === 0
) {
$this->where[] = $condition;
} else {
$this->where = ['and', $this->where, $condition];
}
$this->addParams($params);
return $this;
}
| public average( string $sql ): integer|float|string|null | ||
| $sql | string | |
public function average(string $sql): int|float|string|null
{
return match ($this->emulateExecution) {
true => null,
false => is_numeric($avg = $this->queryScalar("AVG($sql)")) ? $avg : null,
};
}
| public batch( integer $batchSize = 100 ): Yiisoft\Db\Query\BatchQueryResultInterface | ||
| $batchSize | integer | |
public function batch(int $batchSize = 100): BatchQueryResultInterface
{
return $this->db
->createBatchQueryResult($this)
->batchSize($batchSize);
}
| public column( ): array |
public function column(): array
{
if ($this->emulateExecution) {
return [];
}
if ($this->indexBy === null) {
return $this->createCommand()->queryColumn();
}
if (is_string($this->indexBy)) {
if (count($this->select) === 1) {
if (!str_contains($this->indexBy, '.') && count($tables = $this->getTablesUsedInFrom()) > 0) {
$this->select[] = key($tables) . '.' . $this->indexBy;
} else {
$this->select[] = $this->indexBy;
}
}
$rows = $this->createCommand()->queryAll();
if (empty($rows)) {
return [];
}
if (($dotPos = strpos($this->indexBy, '.')) === false) {
$column = $this->indexBy;
} else {
$column = substr($this->indexBy, $dotPos + 1);
}
return array_column($rows, key(current($rows)), $column);
}
$rows = $this->createCommand()->queryAll();
if (empty($rows)) {
return [];
}
return array_combine(array_map($this->indexBy, $rows), array_column($rows, key(current($rows))));
}
| public count( string $sql = '*' ): integer|string | ||
| $sql | string | |
public function count(string $sql = '*'): int|string
{
/** @var int|string|null $count */
$count = $this->queryScalar("COUNT($sql)");
if ($count === null) {
return 0;
}
/** @psalm-var non-negative-int|string */
return $count <= PHP_INT_MAX ? (int) $count : $count;
}
| public createCommand( ): Yiisoft\Db\Command\CommandInterface |
public function createCommand(): CommandInterface
{
[$sql, $params] = $this->db->getQueryBuilder()->build($this);
return $this->db->createCommand($sql, $params)->withPhpTypecasting($this->typecasting);
}
| public distinct( boolean $value = true ): Yiisoft\Db\Query\Query | ||
| $value | boolean | |
public function distinct(bool $value = true): static
{
$this->distinct = $value;
return $this;
}
| public each( ): Yiisoft\Db\Query\DataReaderInterface |
public function each(): DataReaderInterface
{
return $this->createCommand()
->query()
->indexBy($this->indexBy)
->resultCallback($this->resultCallback !== null ? $this->callResultCallbackOnOne(...) : null);
}
| public emulateExecution( boolean $value = true ): Yiisoft\Db\Query\Query | ||
| $value | boolean | |
public function emulateExecution(bool $value = true): static
{
$this->emulateExecution = $value;
return $this;
}
| public exists( ): boolean |
public function exists(): bool
{
if ($this->emulateExecution) {
return false;
}
$command = $this->createCommand();
$params = $command->getParams();
$command->setSql($this->db->getQueryBuilder()->selectExists($command->getSql()));
$command->bindValues($params);
return (bool) $command->queryScalar();
}
| public filterHaving( array $condition ): Yiisoft\Db\Query\Query | ||
| $condition | array | |
public function filterHaving(array $condition): static
{
$condition = $this->filterCondition($condition);
if ($condition !== []) {
$this->having($condition);
}
return $this;
}
| public filterWhere( array $condition ): Yiisoft\Db\Query\Query | ||
| $condition | array | |
public function filterWhere(array $condition): static
{
$condition = $this->filterCondition($condition);
if ($condition !== []) {
$this->where($condition);
}
return $this;
}
| public for( string|array|null $value ): Yiisoft\Db\Query\Query | ||
| $value | string|array|null | |
public function for(string|array|null $value): static
{
if ($this->for !== []) {
throw new LogicException('The `FOR` part was set earlier. Use the `setFor()` or `addFor()` method.');
}
return $this->setFor($value);
}
| public from( array|Yiisoft\Db\Expression\ExpressionInterface|string $tables ): Yiisoft\Db\Query\Query | ||
| $tables | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
public function from(array|ExpressionInterface|string $tables): static
{
$this->from = DbArrayHelper::normalizeExpressions($tables);
return $this;
}
| public getHaving( ): string|array|Yiisoft\Db\Expression\ExpressionInterface|null |
public function getHaving(): string|array|ExpressionInterface|null
{
return $this->having;
}
| public getIndexBy( ): Closure|string|null |
public function getIndexBy(): Closure|string|null
{
return $this->indexBy;
}
| public getLimit( ): Yiisoft\Db\Expression\ExpressionInterface|integer|null |
public function getLimit(): ExpressionInterface|int|null
{
return $this->limit;
}
| public getOffset( ): Yiisoft\Db\Expression\ExpressionInterface|integer|null |
public function getOffset(): ExpressionInterface|int|null
{
return $this->offset;
}
| public getResultCallback( ): Closure|null |
public function getResultCallback(): ?Closure
{
return $this->resultCallback;
}
| public getSelectOption( ): string|null |
public function getSelectOption(): ?string
{
return $this->selectOption;
}
| public getTablesUsedInFrom( ): array |
public function getTablesUsedInFrom(): array
{
return $this->db->getQuoter()->cleanUpTableNames($this->from);
}
| public getWhere( ): array|string|Yiisoft\Db\Expression\ExpressionInterface|null |
public function getWhere(): array|string|ExpressionInterface|null
{
return $this->where;
}
| public getWithQueries( ): array |
public function getWithQueries(): array
{
return $this->withQueries;
}
| public groupBy( array|string|Yiisoft\Db\Expression\ExpressionInterface $columns ): Yiisoft\Db\Query\Query | ||
| $columns | array|string|Yiisoft\Db\Expression\ExpressionInterface | |
public function groupBy(array|string|ExpressionInterface $columns): static
{
$this->groupBy = DbArrayHelper::normalizeExpressions($columns);
return $this;
}
| public having( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | array|Yiisoft\Db\Expression\ExpressionInterface|string|null | |
| $params | array | |
public function having(array|ExpressionInterface|string|null $condition, array $params = []): static
{
if ($this->having === null) {
$this->having = $condition;
} else {
throw new LogicException('The `having` condition was set earlier. Use the `setHaving()`, `andHaving()` or `orHaving()` method.');
}
$this->addParams($params);
return $this;
}
| protected index( array $rows ): array[]|object[] | ||
| $rows | array | |
protected function index(array $rows): array
{
return DbArrayHelper::index($rows, $this->indexBy, $this->resultCallback);
}
| public indexBy( Closure|string|null $column ): Yiisoft\Db\Query\Query | ||
| $column | Closure|string|null | |
public function indexBy(Closure|string|null $column): static
{
$this->indexBy = $column;
return $this;
}
| public innerJoin( array|Yiisoft\Db\Expression\ExpressionInterface|string $table, array|Yiisoft\Db\Expression\ExpressionInterface|string $on = '', array $params = [] ): Yiisoft\Db\Query\Query | ||
| $table | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $on | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $params | array | |
public function innerJoin(
array|ExpressionInterface|string $table,
array|ExpressionInterface|string $on = '',
array $params = [],
): static {
$this->joins[] = ['INNER JOIN', $table, $on];
return $this->addParams($params);
}
| public join( string $type, array|Yiisoft\Db\Expression\ExpressionInterface|string $table, array|Yiisoft\Db\Expression\ExpressionInterface|string $on = '', array $params = [] ): Yiisoft\Db\Query\Query | ||
| $type | string | |
| $table | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $on | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $params | array | |
public function join(
string $type,
array|ExpressionInterface|string $table,
array|ExpressionInterface|string $on = '',
array $params = [],
): static {
$this->joins[] = [$type, $table, $on];
return $this->addParams($params);
}
| public leftJoin( array|Yiisoft\Db\Expression\ExpressionInterface|string $table, array|Yiisoft\Db\Expression\ExpressionInterface|string $on = '', array $params = [] ): Yiisoft\Db\Query\Query | ||
| $table | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $on | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $params | array | |
public function leftJoin(
array|ExpressionInterface|string $table,
array|ExpressionInterface|string $on = '',
array $params = [],
): static {
$this->joins[] = ['LEFT JOIN', $table, $on];
return $this->addParams($params);
}
| public limit( Yiisoft\Db\Expression\ExpressionInterface|integer|null $limit ): Yiisoft\Db\Query\Query | ||
| $limit | Yiisoft\Db\Expression\ExpressionInterface|integer|null | |
public function limit(ExpressionInterface|int|null $limit): static
{
$this->limit = $limit;
return $this;
}
| public max( string $sql ): integer|float|string|null | ||
| $sql | string | |
public function max(string $sql): int|float|string|null
{
$max = $this->queryScalar("MAX($sql)");
return is_numeric($max) ? $max : null;
}
| public min( string $sql ): integer|float|string|null | ||
| $sql | string | |
public function min(string $sql): int|float|string|null
{
$min = $this->queryScalar("MIN($sql)");
return is_numeric($min) ? $min : null;
}
| public offset( Yiisoft\Db\Expression\ExpressionInterface|integer|null $offset ): Yiisoft\Db\Query\Query | ||
| $offset | Yiisoft\Db\Expression\ExpressionInterface|integer|null | |
public function offset(ExpressionInterface|int|null $offset): static
{
$this->offset = $offset;
return $this;
}
| public one( ): array|object|null |
public function one(): array|object|null
{
if ($this->emulateExecution) {
return null;
}
$row = $this->createCommand()->queryOne();
if ($this->resultCallback === null || $row === null) {
return $row;
}
return $this->callResultCallbackOnOne($row);
}
| public orFilterHaving( array $condition ): Yiisoft\Db\Query\Query | ||
| $condition | array | |
public function orFilterHaving(array $condition): static
{
$condition = $this->filterCondition($condition);
if ($condition !== []) {
$this->orHaving($condition);
}
return $this;
}
| public orFilterWhere( array $condition ): Yiisoft\Db\Query\Query | ||
| $condition | array | |
public function orFilterWhere(array $condition): static
{
$condition = $this->filterCondition($condition);
if ($condition !== []) {
$this->orWhere($condition);
}
return $this;
}
| public orHaving( array|string|Yiisoft\Db\Expression\ExpressionInterface $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | array|string|Yiisoft\Db\Expression\ExpressionInterface | |
| $params | array | |
public function orHaving(array|string|ExpressionInterface $condition, array $params = []): static
{
if ($this->having === null) {
$this->having = $condition;
} else {
$this->having = ['or', $this->having, $condition];
}
$this->addParams($params);
return $this;
}
| public orWhere( array|string|Yiisoft\Db\Expression\ExpressionInterface $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | array|string|Yiisoft\Db\Expression\ExpressionInterface | |
| $params | array | |
public function orWhere(array|string|ExpressionInterface $condition, array $params = []): static
{
if ($this->where === null) {
$this->where = $condition;
} else {
$this->where = ['or', $this->where, $condition];
}
$this->addParams($params);
return $this;
}
| public orderBy( array|string|Yiisoft\Db\Expression\ExpressionInterface $columns ): Yiisoft\Db\Query\Query | ||
| $columns | array|string|Yiisoft\Db\Expression\ExpressionInterface | |
public function orderBy(array|string|ExpressionInterface $columns): static
{
$this->orderBy = $this->normalizeOrderBy($columns);
return $this;
}
| public params( array $params ): Yiisoft\Db\Query\Query | ||
| $params | array | |
public function params(array $params): static
{
$this->params = $params;
return $this;
}
| public prepare( Yiisoft\Db\QueryBuilder\QueryBuilderInterface $builder ): Yiisoft\Db\Query\QueryInterface | ||
| $builder | Yiisoft\Db\QueryBuilder\QueryBuilderInterface | |
public function prepare(QueryBuilderInterface $builder): QueryInterface
{
return $this;
}
Queries a scalar value by setting select() first.
Restores the value of select to make this query reusable.
| protected queryScalar( string|Yiisoft\Db\Expression\ExpressionInterface $selectExpression ): boolean|integer|string|float|null | ||
| $selectExpression | string|Yiisoft\Db\Expression\ExpressionInterface | |
| throws | Yiisoft\Db\Exception\Exception | |
|---|---|---|
| throws | InvalidArgumentException | |
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
| throws | Throwable | |
protected function queryScalar(string|ExpressionInterface $selectExpression): bool|int|string|float|null
{
if ($this->emulateExecution) {
return null;
}
if (
!$this->distinct
&& empty($this->groupBy)
&& empty($this->having)
&& empty($this->union)
) {
$select = $this->select;
$order = $this->orderBy;
$limit = $this->limit;
$offset = $this->offset;
$this->select = [$selectExpression];
$this->orderBy = [];
$this->limit = null;
$this->offset = null;
$command = $this->createCommand();
$this->select = $select;
$this->orderBy = $order;
$this->limit = $limit;
$this->offset = $offset;
return $command->queryScalar();
}
$query = (new self($this->db))->select($selectExpression)->from(['c' => $this]);
[$sql, $params] = $this->db->getQueryBuilder()->build($query);
$command = $this->db->createCommand($sql, $params);
return $command->queryScalar();
}
| public resultCallback( Closure|null $resultCallback ): Yiisoft\Db\Query\Query | ||
| $resultCallback | Closure|null | |
public function resultCallback(?Closure $resultCallback): static
{
$this->resultCallback = $resultCallback;
return $this;
}
| public rightJoin( array|Yiisoft\Db\Expression\ExpressionInterface|string $table, array|Yiisoft\Db\Expression\ExpressionInterface|string $on = '', array $params = [] ): Yiisoft\Db\Query\Query | ||
| $table | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $on | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $params | array | |
public function rightJoin(
array|ExpressionInterface|string $table,
array|ExpressionInterface|string $on = '',
array $params = [],
): static {
$this->joins[] = ['RIGHT JOIN', $table, $on];
return $this->addParams($params);
}
| public scalar( ): boolean|integer|string|float|null |
public function scalar(): bool|int|string|float|null
{
return match ($this->emulateExecution) {
true => null,
false => $this->createCommand()->queryScalar(),
};
}
| public select( array|boolean|float|integer|string|Yiisoft\Db\Expression\ExpressionInterface $columns, string|null $option = null ): Yiisoft\Db\Query\Query | ||
| $columns | array|boolean|float|integer|string|Yiisoft\Db\Expression\ExpressionInterface | |
| $option | string|null | |
public function select(array|bool|float|int|string|ExpressionInterface $columns, ?string $option = null): static
{
$this->select = $this->normalizeSelect($columns);
$this->selectOption = $option;
return $this;
}
| public selectOption( string|null $value ): Yiisoft\Db\Query\Query | ||
| $value | string|null | |
public function selectOption(?string $value): static
{
$this->selectOption = $value;
return $this;
}
| public setFor( array|string|null $value ): Yiisoft\Db\Query\Query | ||
| $value | array|string|null | |
public function setFor(array|string|null $value): static
{
if ($value === null) {
$this->for = [];
return $this;
}
$this->for = (array) $value;
return $this;
}
| public setHaving( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | array|Yiisoft\Db\Expression\ExpressionInterface|string|null | |
| $params | array | |
public function setHaving(array|ExpressionInterface|string|null $condition, array $params = []): static
{
$this->having = $condition;
$this->addParams($params);
return $this;
}
| public setJoins( array $value ): Yiisoft\Db\Query\Query | ||
| $value | array | |
public function setJoins(array $value): static
{
$this->joins = $value;
return $this;
}
| public setUnions( array $value ): Yiisoft\Db\Query\Query | ||
| $value | array | |
public function setUnions(array $value): static
{
$this->union = $value;
return $this;
}
| public setWhere( array|string|Yiisoft\Db\Expression\ExpressionInterface|null $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | array|string|Yiisoft\Db\Expression\ExpressionInterface|null | |
| $params | array | |
public function setWhere(array|string|ExpressionInterface|null $condition, array $params = []): static
{
$this->where = $condition;
$this->addParams($params);
return $this;
}
| public shouldEmulateExecution( ): boolean |
public function shouldEmulateExecution(): bool
{
return $this->emulateExecution;
}
| public sum( string $sql ): integer|float|string|null | ||
| $sql | string | |
public function sum(string $sql): int|float|string|null
{
return match ($this->emulateExecution) {
true => null,
false => is_numeric($sum = $this->queryScalar("SUM($sql)")) ? $sum : null,
};
}
| public union( Yiisoft\Db\Query\QueryInterface|string $sql, boolean $all = false ): Yiisoft\Db\Query\Query | ||
| $sql | Yiisoft\Db\Query\QueryInterface|string | |
| $all | boolean | |
public function union(QueryInterface|string $sql, bool $all = false): static
{
$this->union[] = ['query' => $sql, 'all' => $all];
return $this;
}
| public where( array|string|Yiisoft\Db\Expression\ExpressionInterface|null $condition, array $params = [] ): Yiisoft\Db\Query\Query | ||
| $condition | array|string|Yiisoft\Db\Expression\ExpressionInterface|null | |
| $params | array | |
public function where(array|string|ExpressionInterface|null $condition, array $params = []): static
{
if ($this->where !== null) {
throw new LogicException(
'The `where` condition was set earlier. Use the `setWhere()`, `andWhere()` or `orWhere()` method.',
);
}
$this->where = $condition;
$this->addParams($params);
return $this;
}
| public withQueries( Yiisoft\Db\Query\WithQuery $queries ): Yiisoft\Db\Query\Query | ||
| $queries | Yiisoft\Db\Query\WithQuery | |
public function withQueries(WithQuery ...$queries): static
{
$this->withQueries = $queries;
return $this;
}
| public withQuery( Yiisoft\Db\Query\QueryInterface|string $query, Yiisoft\Db\Expression\ExpressionInterface|string $alias, boolean $recursive = false ): Yiisoft\Db\Query\Query | ||
| $query | Yiisoft\Db\Query\QueryInterface|string | |
| $alias | Yiisoft\Db\Expression\ExpressionInterface|string | |
| $recursive | boolean | |
public function withQuery(
QueryInterface|string $query,
ExpressionInterface|string $alias,
bool $recursive = false,
): static {
$this->withQueries = [new WithQuery($query, $alias, $recursive)];
return $this;
}
| public withTypecasting( boolean $typecasting = true ): Yiisoft\Db\Query\Query | ||
| $typecasting | boolean | |
public function withTypecasting(bool $typecasting = true): static
{
$new = clone $this;
$new->typecasting = $typecasting;
return $new;
}
Signup or Login in order to comment.