print query in laravel

11,199

Solution 1

DB::enableQueryLog();
DB::table('avt_channel_billing_address')->where('channel_id',$channel_id)->update($channelList)
dd(DB::getQueryLog())

Docs

Solution 2

You may have to turn it on: DB::enableQueryLog(); and than call DB::getQueryLog()

Solution 3

$query = User::select("*")->toSql();
dd($query);

Another way:

DB::enableQueryLog();
$users = User::select("*")->get();
$quries = DB::getQueryLog();
dd($quries)
Share:
11,199
Biswa
Author by

Biswa

I am a s/w devloper .I m involved in facebook apps

Updated on June 04, 2022

Comments

  • Biswa
    Biswa almost 2 years

    I want to print my query on laravel and my query is DB::table('avt_channel_billing_address')->where('channel_id',$channel_id)->update($channelList) where $channel is an array of values.

    I tried using dd(DB::getQueryLog()) and toSql .None print the query.