ARTICLE AD BOX
I encountered a situation where the connection through with() is not pulled up if there are multiple records in the selection. If there is only one record, it works correctly, but in other cases, it returns null. The query is simple:
$modelClass::find() ->with(['shopPartner']) ->where([$modelClass::tableName() . '.id' => $ids])The link is through the shop_code field of the model to the code field of the linked model, which contains a string such as "test".
public function getShopPartner(): ActiveQuery { return $this->hasOne(ShopPartner::class, ['shop_code' => 'code']); }If you remove the link from with(), the linked model is correctly retrieved when you access -\>shopPartner, but this behavior is not expected in a loop.
40k18 gold badges85 silver badges115 bronze badges
