DEV Community

Mahfuz Shaikh
Mahfuz Shaikh

Posted on

Could you tell the issue?

Laravel eloquent query
Hey thank you for reading and helping me :)
The above Laravel eloquent queries giving different result. Could you tell the difference? I am one step away from pulling my hair .

Top comments (3)

Collapse
 
lito profile image
Lito

You can view the SQL query using the toSql() method instead count.

Collapse
 
mah3uz profile image
Mahfuz Shaikh

Yes I know, but why it's giving different result?

Collapse
 
moopet profile image
Ben Sinclair

The idea is that if you compare the SQL that's generated you'll be able to see what they're doing differently underneath their abstraction layer.

If the abstraction layer is giving inconsistent results then it's not a very good tool, but I've heard eloquent is supposed to be decent, so ¯_(ツ)_/¯