Interface yii\db\ActiveQueryInterface

Extendsyii\db\QueryInterface
Implemented bybackend\modules\corsi\models\RisultatiInnovazionePrevalenteQuery, common\models\ItaliaComuniQuery, common\models\ItaliaProvinceQuery, common\models\ItaliaRegioniQuery, lispa\amos\chat\models\search\ConversationQuery, lispa\amos\chat\models\search\MessageQuery, lispa\amos\core\record\CachedActiveQuery, lispa\amos\cwh\models\query\CwhNodiQuery, lispa\amos\cwh\models\query\CwhRegolePubblicazioneQuery, lispa\amos\cwh\query\CwhActiveQuery, lispa\amos\inforeq\models\InforeqArgomentiQuery, lispa\amos\inforeq\models\InforeqQuery, lispa\amos\risultati\models\BisognoPerSviluppoRisultatiQuery, lispa\amos\risultati\models\ProtezioneInnovazioneRisultatiQuery, lispa\amos\risultati\models\RisultatiBisognoPerSviluppoRisultatiMmQuery, lispa\amos\risultati\models\RisultatiProtezioneInnovazioneRisultatiMmQuery, lispa\amos\risultati\models\RisultatiQuery, lispa\amos\risultati\models\RisultatiStadioSviluppoRisultatiMmQuery, lispa\amos\risultati\models\RisultatiTecnologieRisultatiMmQuery, lispa\amos\risultati\models\StadioSviluppoRisultatiQuery, lispa\amos\risultati\models\TecnologieRisultatiQuery, lispa\amos\slideshow\models\SlideshowQuery, lispa\amos\slideshow\models\SlideshowRouteQuery, lispa\amos\tag\models\search\TagQuery, yii\db\ActiveQuery
Available since version2.0
Source Code https://github.com/yiisoft/yii2/blob/master/framework/db/ActiveQueryInterface.php

ActiveQueryInterface defines the common interface to be implemented by active record query classes.

That are methods for either normal queries that return active records but also relational queries in which the query represents a relation between two active record classes and will return related records only.

A class implementing this interface should also use yii\db\ActiveQueryTrait and yii\db\ActiveRelationTrait.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
addOrderBy() Adds additional ORDER BY columns to the query. yii\db\QueryInterface
all() Executes the query and returns all results as an array. yii\db\QueryInterface
andFilterWhere() Adds an additional WHERE condition to the existing one ignoring empty parameters. yii\db\QueryInterface
andWhere() Adds an additional WHERE condition to the existing one. yii\db\QueryInterface
asArray() Sets the asArray() property. yii\db\ActiveQueryInterface
count() Returns the number of records. yii\db\QueryInterface
emulateExecution() Sets whether to emulate query execution, preventing any interaction with data storage. yii\db\QueryInterface
exists() Returns a value indicating whether the query result contains any row of data. yii\db\QueryInterface
filterWhere() Sets the WHERE part of the query ignoring empty parameters. yii\db\QueryInterface
findFor() Finds the related records for the specified primary record. yii\db\ActiveQueryInterface
indexBy() Sets the indexBy() property. yii\db\ActiveQueryInterface
limit() Sets the LIMIT part of the query. yii\db\QueryInterface
offset() Sets the OFFSET part of the query. yii\db\QueryInterface
one() Executes query and returns a single row of result. yii\db\ActiveQueryInterface
orFilterWhere() Adds an additional WHERE condition to the existing one ignoring empty parameters. yii\db\QueryInterface
orWhere() Adds an additional WHERE condition to the existing one. yii\db\QueryInterface
orderBy() Sets the ORDER BY part of the query. yii\db\QueryInterface
via() Specifies the relation associated with the junction table for use in relational query. yii\db\ActiveQueryInterface
where() Sets the WHERE part of the query. yii\db\QueryInterface
with() Specifies the relations with which this query should be performed. yii\db\ActiveQueryInterface

Method Details

asArray() public abstract method

Sets the asArray() property.

public abstract $this asArray ( $value true )
$value boolean

Whether to return the query results in terms of arrays instead of Active Records.

return $this

The query object itself

findFor() public abstract method

Finds the related records for the specified primary record.

This method is invoked when a relation of an ActiveRecord is being accessed in a lazy fashion.

public abstract mixed findFor ( $name, $model )
$name string

The relation name

$model yii\db\ActiveRecordInterface

The primary model

return mixed

The related record(s)

indexBy() public abstract method

Sets the indexBy() property.

public abstract $this indexBy ( $column )
$column string|callable

The name of the column by which the query results should be indexed by. This can also be a callable (e.g. anonymous function) that returns the index value based on the given row or model data. The signature of the callable should be:

// $model is an AR instance when `asArray` is false,
// or an array of column values when `asArray` is true.
function ($model)
{
    // return the index value corresponding to $model
}
return $this

The query object itself

one() public abstract method

Executes query and returns a single row of result.

public abstract yii\db\ActiveRecordInterface|array|null one ( $db null )
$db yii\db\Connection

The DB connection used to create the DB command. If null, the DB connection returned by modelClass will be used.

return yii\db\ActiveRecordInterface|array|null

A single row of query result. Depending on the setting of asArray(), the query result may be either an array or an ActiveRecord object. null will be returned if the query results in nothing.

via() public abstract method

Specifies the relation associated with the junction table for use in relational query.

public abstract $this via ( $relationName, callable $callable null )
$relationName string

The relation name. This refers to a relation declared in the primaryModel of the relation.

$callable callable

A PHP callback for customizing the relation associated with the junction table. Its signature should be function($query), where $query is the query to be customized.

return $this

The relation object itself.

with() public abstract method

Specifies the relations with which this query should be performed.

The parameters to this method can be either one or multiple strings, or a single array of relation names and the optional callbacks to customize the relations.

A relation name can refer to a relation defined in modelClass or a sub-relation that stands for a relation of a related record. For example, orders.address means the address relation defined in the model class corresponding to the orders relation.

The following are some usage examples:

// find customers together with their orders and country
Customer::find()->with('orders', 'country')->all();
// find customers together with their orders and the orders' shipping address
Customer::find()->with('orders.address')->all();
// find customers together with their country and orders of status 1
Customer::find()->with([
    'orders' => function (\yii\db\ActiveQuery $query) {
        $query->andWhere('status = 1');
    },
    'country',
])->all();
public abstract $this with ( )
return $this

The query object itself