I have ran into a weird issue with Laravel where the equals sign does not return any values within a where clause. But the weirdest part is that if I use a != instead I get results!
Widgets Table
+----+-------------+-------------+
| id | title | widget_data |
+----+-------------+-------------+
| 1 | my widget | xyz |
+----+-------------+-------------+
| 2 | the widget | xyz |
+----+-------------+-------------+
| 3 | da widget | xyz |
+----+-------------+-------------+
| 4 | our widget | xyz... |
+----+-------------+-------------+
| 5 | etc... | etc... |
+----+-------------+-------------+
$array_of_ids
array(
[0] => 2,
[1] => 3
)
Heres my code. Returns an empty array (but should return rows 2 and 3)
$q = Widgets::where(function($query) use ($array_of_ids){
foreach ($array_of_ids as $key => $value){
$query->where('id', '=', $value);
}
})->get()->toArray();
Same code but with != instead, returns rows 1, 4 and 5... (as it should)
$q = Widgets::where(function($query) use ($array_of_ids){
foreach ($array_of_ids as $key => $value){
$query->where('id', '!=', $value);
}
})->get()->toArray();
What is going on?? Is this a bug? Has anyone ran into this issue before?