+ Reply Thread
#1

A very good example is this, I want to do:

     \App\Event::
      where(['receiver'=>Auth::user()->id])
      ->orwhere(function($query) {
        $query->orWhere('cat','comment');
        $query->orWhere('cat','post');
      })
      ->count();

How do I get the actual SQL query used for debugging sake?

#2

This is a very simple problem, you need the query logger, simple.

Here is how to do it:

    \DB::enableQueryLog();
      echo \App\Event::
      where(['receiver'=>Auth::user()->id])
      ->orwhere(function($query) {
        $query->orWhere('cat','comment');
        $query->orWhere('cat','post');
      })
      ->count();

    var_dump(\DB::getQueryLog());

If there is any other problem, kindly let me know.

#3
Learnt something new today
Back to top