preloader
軟體工程

The quick way to validate you ORM query to SQL

Refer from link: http://laragems.com/post/a-quick-way-to-display-a-sql-query-in-tinker

Please enter tinker command: php artisan tinker

Type below code:

DB::listen(function ($query) {
  dump($query->sql);
  dump($query->bindings);
  dump($query->time); 
});

And from above line on, every ORM manipulation you type will show what transformed SQL is.