Skip to content

Instantly share code, notes, and snippets.

@rstriquer
Last active June 16, 2022 18:40
Show Gist options
  • Save rstriquer/e9ef677a859e553a21db68ea84f40f73 to your computer and use it in GitHub Desktop.
Save rstriquer/e9ef677a859e553a21db68ea84f40f73 to your computer and use it in GitHub Desktop.
dump sql no laravel
<?php
/**
* Return (Laravel) Eloquent Query Builder object as an SQLs with switched values.
* - add the function to app/helpers/database.php file and the file to autoload.
* files in the composer.json, the dquery will be available to all code over
* debug env
* @param \Illuminate\Database\Query\Builder $builder
*/
function dquery(Builder $builder) : string
{
return vsprintf(
str_replace(array('?'), array('\'%s\''), $builder->toSql()),
$builder->getBindings()
);
}
@rstriquer
Copy link
Author

rstriquer commented Mar 17, 2021

easy string to copy-past into debug console:
vsprintf(str_replace(array('?'),array(''%s''), $query->toSql()),$query->getBindings());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment