Если я вас правильно понимаю тогда ваш запрос будет выглядеть как-то так:
$data = Product::find()
->joinWith('table')
->where(['table.value_id' => [1, 2, 3]])
->asArray()
->all();
Сам не понимаю почему такие sql сгенерировало :(
SELECT `product`.* FROM `product` LEFT JOIN `table` ON `product`.`id` = `table`.`product_id` WHERE `table`.`value_id` IN (1, 2, 3);
SELECT * FROM `table` WHERE `product_id` IN ('1', '2');
Но я бы сделал вот так:
$data = Product::find()
->with([
'table' => function(Query $q) {
$q->where(['value_id' => [1, 2, 3]]);
}
])
->asArray()
->all();
SELECT * FROM `product`;
SELECT * FROM `table` WHERE (`value_id` IN (1, 2, 3)) AND (`product_id` IN ('1', '2'));
// print_r($data);
Array
(
[0] => Array
(
[id] => 1
[manufacturer_id] => 2
[category_id] => 13
[status] => 10
[name] => фотокамера Canon SX 150 IS black
[created_at] => 1395167522
[updated_at] => 1395167679
[table] => Array
(
[product_id] => 1
[value_id] => 1
)
)
[1] => Array
(
[id] => 2
[manufacturer_id] => 2
[category_id] => 29
[status] => 10
[name] => сумка
[created_at] => 1395170865
[updated_at] => 1395170865
[medium_delivery] => 0
[table] => Array
(
[product_id] => 2
[value_id] => 1
)
)
)