Akainu Lionheart Akainu Lionheart - 1 year ago 131
PHP Question

Make eloquent give only sql clause

I was trying to rip off every connection function of Laravel's eloquent to give me SQL clause without querying it with PDO ( I also cleaning off every PDO instances from the code) and make eloquent a standalone package. I just want it to give me sql clause without connect to any db when I use an eloquent model just like this :

Request : Users::with('group')->take(5)->get();
Response : Select * from users.....

Can this be done ?

Answer Source

use ->toSql() instead of ->get()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download