Last active
June 16, 2022 18:40
-
-
Save rstriquer/e9ef677a859e553a21db68ea84f40f73 to your computer and use it in GitHub Desktop.
dump sql no laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
easy string to copy-past into debug console:
vsprintf(str_replace(array('?'),array(''%s''), $query->toSql()),$query->getBindings());