Laravel how to get query with bindings?

前端 未结 14 946
小蘑菇
小蘑菇 2021-01-31 15:58

I have some query that I need to pass to another query using query builder

$query = DB::table(\'table\')->whereIn(\'some_field\', [1,2,30])->toSql();

Mode         


        
14条回答
  •  名媛妹妹
    2021-01-31 16:50

    Laravel now offers debugging directly on your Builder!!!

    https://laravel.com/docs/queries#debugging

    \App\User::where('age', '18')->dump();
    \App\User::where('age', '18')->dd();
    

    Outputs

    "select * from `users` where `age` = ?"
    [
        0 => "18"
    ]
    

提交回复
热议问题