Reputation: 3
I have this code in yii 1
$criteria->join = 'left join item_attr_val v ON i.item_id=t.id';
$values = array();
foreach ($feature as $key => $value) {
if ($value == '1')
$values [] = $key;
}
$criteria->compare('i.attr_value_id', $values);
how can I use in yii2
Upvotes: 0
Views: 407
Reputation: 4261
You Try this One...
$query = Model::find();
$query->join('LEFT JOIN', 'item_attr_val', "item_id = id");
Upvotes: 1
Reputation: 3818
You can use leftjoin
.
e.g
$query = ModelName::find();
$query->leftJoin('item_attr_val', "tableName.item_id = tableName2.id");
Upvotes: 1