php - Make eloquent give only sql clause

526

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 ?

684

Answer

Solution:

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

People are also looking for solutions to the problem: php - Create a individual custom post type taxonomy Archive Page

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.