Laravel 5 Eloquent: How to get raw sql that is being executed? (with binded data)

前端 未结 5 1697
栀梦
栀梦 2021-02-06 01:13

Im trying to figure out how to get the raw sql query being executed including the binded data in it. Here is what ive got:

\\DB::connection()->enableQueryLog(         


        
5条回答
  •  轮回少年
    2021-02-06 01:22

    Try to add event listener for query :

    Event::listen('illuminate.query', function($query)
    {
        var_dump($query);
    });
    

    or

    $results = User::where('id',$id)->toSql();
    dd($results)
    

提交回复
热议问题