A relation is defined by a getter method which returns an ActiveQueryInterface object.
It can be declared in either the Active Record class itself or one of its behaviors.
public getRelation ( string $name, boolean $throwException = true ) : yii\db\ActiveQueryInterface | |
||
$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 | |
the relational query object. If the relation does not exist and `$throwException` is `false`, `null` will be returned. |
/** * {@inheritdoc} * @return ActiveQueryInterface|ActiveQuery the relational query object. If the relation does not exist * and `$throwException` is false, null will be returned. */ public function getRelation($name, $throwException = true) { return parent::getRelation($name, $throwException); }