jeudi 1 septembre 2016

Laravel 5 Eloquent: How to get raw sql that is being executed? (with binded data)

Im trying to figure out how to get the raw sql query being executed including the binded data in it. Here is what ive got:

\DB::connection()->enableQueryLog();
$query = \DB::getQueryLog();
$lastQuery = end($query);

And here is what the result looks like:

array(3) {
  ["query"]=>
  string(57) "select * from `table_1` where `field_1` = ? limit 1"
  ["bindings"]=>
  array(1) {
    [0]=>
    string(34) "xyz"
  }
}

So how do I get a dump of a full sql query like this?

select * from `table_1` where `field_1` = 'xyz' limit 1

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire