Answer the question
In order to leave comments, you need to log in
How to compose such a query in Yii2 via AR?
Good afternoon.
We need a tricky selection of two tables. There were no problems with the Join of the first table, but the second one needs a double condition:
...LEFT JOIN `reject` `r` ON ( `r`.`u_id` = `q`.`id` AND `r`.`processing_id` = `p`.`id` )...
public function getReject()
{
return $this->hasMany(Reject::className(), ['u_id' => 'id']);
}
Answer the question
In order to leave comments, you need to log in
public function getReject()
{
return $this->hasMany(Reject::className(), ['u_id' => 'id'])->onCondition('reject.processing_id = p.id');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question