I'm having an issue with Eloquent querying things different than if I'm using the raw query, despite it returning the exact same raw query when I dump it with toSql()
This should return 3 rows, but instead returns 40
$equipment = Equipment::where(["class_id" => $this->classId, "class_id2" => $this->classId, "class_id3" => $this->classId])
->orWhere(["class_id" => 0, "class_id2" => 0, "class_id3" => 0])
->where("type_id", ">", "7")
->get();
This returns 3 and works as expected
$equipment = \DB::table("equipment")
->whereRaw("(`class_id` = ".$this->classId." and `class_id2` = ".$this->classId." and `class_id3` = ".$this->classId.")
or (`class_id` = ".$this->classId." or `class_id2` = ".$this->classId." or `class_id3` = ".$this->classId.")
and `type_id` > 7")
->get();
The exact raw query Eloquent dumps is this:
select *
from `equipment`
where (`class_id` = 14 and `class_id2` = 14 and `class_id3` = 14)
or (`class_id` = 14 or `class_id2` = 14 or `class_id3` = 14)
and `type_id` > 7
When running this in Navicat, it also returns 3 rows.
What am I missing here?