4

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.

3
  • 1
    both should work. I just tried and worked for me. Commented Nov 3, 2016 at 12:37
  • @imrealashu i tried this DB::table('avt_channel_billing_address')->where('channel_id',$channel_id)->update($channelList)->toSql(); Didnt work Commented Nov 3, 2016 at 12:41
  • I've posted a answer. Try that once. I've tried locally it worked fine for me. Commented Nov 3, 2016 at 12:42

3 Answers 3

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

Docs

Sign up to request clarification or add additional context in comments.

Comments

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

Another way:

DB::enableQueryLog();
$users = User::select("*")->get();
$quries = DB::getQueryLog();
dd($quries)

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.