Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Question mark in laravel toSQL()

I get this output when trying to use toSQL() to debug my queries.

Laravel code:

$services = Service::latest()->where('status', '=', '0');

Output SQL:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"select * from `services` where `status` = ? order by `created_at` desc"

How can I get a proper query without ? mark? Thanks!

>Solution :

To view the data that will be substituted into the query string you can call the getBindings() function on the query like
below.

$query = User::first()->jobs();

dd($query->toSql(), $query->getBindings());

The array of bindings get substituted in the same order the ? appear in the SQL statement.

check this link

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading