Answer the question
In order to leave comments, you need to log in
How to make an additional condition in join?
Good afternoon.
Tell me how to make an additional condition in the has one connection?
Example:
return $this->hasOne(item::className(), ['name' => 'tooster', 'type' => 'yii']
This doesn't work....
Answer the question
In order to leave comments, you need to log in
www.yiiframework.com/doc-2.0/yii-db-activequery.ht...
public function getActiveUsers()
{
return $this->hasMany(User::className(), ['id' => 'user_id'])
->onCondition(['active' => true]);
}
1. Probably not item, but Item
2.
return $this->hasOne(Item::className(), ['name' => 'tooster'])->andWhere(['type' => 'yii'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question