Method | Description | |
---|---|---|
asArray ( boolean $value = true ) | Sets the [[asArray]] property. | |
findFor ( string $name, yii\db\ActiveRecordInterface $model ) : mixed | Finds the related records for the specified primary record. | |
indexBy ( string | callable $column ) | Sets the [[indexBy]] property. | |
one ( |
Executes query and returns a single row of result. | |
via ( string $relationName, callable $callable = null ) | Specifies the relation associated with the junction table for use in relational query. | |
with ( ) | Specifies the relations with which this query should be performed. |
public indexBy ( string | callable $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: ```php // $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 } ``` |
public one ( |
||
$db | the DB connection used to create the DB command. If `null`, the DB connection returned by [[ActiveQueryTrait::$modelClass|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. |
public via ( string $relationName, callable $callable = null ) | ||
$relationName | string | the relation name. This refers to a relation declared in the [[ActiveRelationTrait::primaryModel|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. |
public with ( ) |