db\BaseActiveRecord getRelation()

getRelation() public method

Returns the relation object with the specified name.

A relation is defined by a getter method which returns an yii\db\ActiveQueryInterface object. It can be declared in either the Active Record class itself or one of its behaviors.

public yii\db\ActiveQueryInterface|yii\db\ActiveQuery getRelation ( $name, $throwException = true )
$name string

The relation name, e.g. orders for a relation defined via getOrders() method (case-sensitive).

$throwException boolean

Whether to throw exception if the relation does not exist.

return yii\db\ActiveQueryInterface|yii\db\ActiveQuery

The relational query object. If the relation does not exist and $throwException is false, null will be returned.

throws yii\base\InvalidParamException

if the named relation does not exist.

doc_Yii
2016-10-30 16:56:48
Comments
Leave a Comment

Please login to continue.