How To Print Or Debug Query In Laravel?
Hi Guys,
In this example,i will learn you how to debug query in laravel.you can eay and simply debug query in laravel.
we need to print the queries which are large in nature. Laravel provides built-in functions to do our job. So let’s see how to print or debug query In Laravel.
The dd method will print the query information and then stop executing the request.
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function index()
{
$users = DB::table('users')->where('id', '=', 1)->dd();
}
The dump method is similar like a dd. The dd means die & dump while we are using dump only here.
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function index()
{
$users = DB::table('users')->where('id', '=', 1)->dump();
}
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function index()
{
$users = DB::table('users')->where('id', '=',1)->toSql();
}
Output:
It will help you..
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial