PHP 트레잇 yii\db\ActiveQueryTrait

부터: 2.0
저자: Qiang Xue ([email protected])
저자: Carsten Brandt ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2

공개 프로퍼티들

프로퍼티 타입 설명
$asArray whether to return each record as an array. If false (default), an object of [[modelClass]] will be created to represent each record.
$modelClass the name of the ActiveRecord class.
$with a list of relations that this query should be performed with

공개 메소드들

메소드 설명
asArray ( boolean $value = true ) Sets the [[asArray]] property.
findWith ( array $with, array | ActiveRecord[] &$models ) Finds records corresponding to one or multiple relations and populates them into the primary models.
with ( ) Specifies the relations with which this query should be performed.

보호된 메소드들

메소드 설명
createModels ( array $rows ) : array | ActiveRecord[] Converts found rows into model instances

비공개 메소드들

메소드 설명
normalizeRelations ( ActiveRecord $model, array $with ) : yii\db\ActiveQueryInterface[]

메소드 상세

asArray() 공개 메소드

Sets the [[asArray]] property.
public asArray ( boolean $value = true )
$value boolean whether to return the query results in terms of arrays instead of Active Records.

createModels() 보호된 메소드

Converts found rows into model instances
부터: 2.0.11
protected createModels ( array $rows ) : array | ActiveRecord[]
$rows array
리턴 array | ActiveRecord[]

findWith() 공개 메소드

Finds records corresponding to one or multiple relations and populates them into the primary models.
public findWith ( array $with, array | ActiveRecord[] &$models )
$with array a list of relations that this query should be performed with. Please refer to [[with()]] for details about specifying this parameter.
$models array | ActiveRecord[] the primary models (can be either AR instances or arrays)

with() 공개 메소드

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: php 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(); You can call with() multiple times. Each call will add relations to the existing ones. For example, the following two statements are equivalent: php Customer::find()->with('orders', 'country')->all(); Customer::find()->with('orders')->with('country')->all();
public with ( )

프로퍼티 상세

$asArray 공개적으로 프로퍼티

whether to return each record as an array. If false (default), an object of [[modelClass]] will be created to represent each record.
public $asArray

$modelClass 공개적으로 프로퍼티

the name of the ActiveRecord class.
public $modelClass

$with 공개적으로 프로퍼티

a list of relations that this query should be performed with
public $with