Код: Выделить всё
public function getOfferToUser() {
return $this->hasOne(OfferToUser::className(), [
'offer_id' => 'offer_id',
'user_id' => 'user_id',
'country_id' => 'country_id',
'city_id' => 'city_id', // city_id может быть null
]);
}
Код: Выделить всё
$this->offerToUser
Код: Выделить всё
SELECT * FROM offer_to_user
WHERE (offer_id,user_id,country_id,city_id) IN (('4','18','1',NULL))
Код: Выделить всё
WHERE offer_id=4 AND user_id=18 AND country_id=1 AND city_id IS NULL
В общем что я тут могу сделать? как правильно написать relation, когда одно из полей может быть null? И вообще почему haOne() не генерирует "limit 1"?