1
因爲我想重寫下面的SQL語句轉換成雄辯的格式:等效WHERE子句中使用雄辯的功能
SELECT `id`, `pushbadge`, `pushalert`, `pushsound`
FROM `devices`
WHERE `id` IN (1, 2, 3)
AND `status`='active'"
我的想法是
public function getDevicesWithIDs($ids) {
$conditions = array();
foreach($ids as $id) {
$conditions[] = ['id' => $id];
}
var_dump($conditions);
return Device::where($conditions)->get();
}
但這返回:
SQLSTATE[42S22]: Column not found: 1054
Unknown column '0' in 'where clause'
(SQL: select * from `devices` where (`0` = 1))
優秀!謝謝! – sesc360