Answer the question
In order to leave comments, you need to log in
Yii2 left join with condition?
need a request
select news.* from news left join
news_trademark on news_trademark.news_id = news.id
and news_trademark.trademark_id = 747
left join trademark on trademark.id = news_trademark.trademark_id
and trademark.photo is null
where trademark.id is null
public function getTrademarks()
{
return $this->hasMany(Trademark::class, ['id' => 'trademark_id'])->viaTable('news_trademark', ['news_id' => 'id']);
}
Answer the question
In order to leave comments, you need to log in
something like that
public function getContent(){
return $this->hasOne(PostContent::classname(),['post_id' => 'id'])
->select(['post_content.name','post_content.post_id','post_content.language'])
->where(['post_content.language'=>Yii::$app->params['admin_lang']]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question