Generate The Raw MySQL Query From Laravel Query Builder

后端 未结 14 1177
醉话见心
醉话见心 2021-02-02 12:04

How can i get mysql query of a laravel query

Convert:

App\\User::where(\'balance\',\'>\',0)->where(...)-         


        
14条回答
  •  借酒劲吻你
    2021-02-02 12:52

    To get mysql query in laravel you need to log your query as

    DB::enableQueryLog();
    App\User::where('balance','>',0)->where(...)->get();
    print_r(DB::getQueryLog());
    

    Check reference : https://laravel.com/docs/5.0/database#query-logging

提交回复
热议问题