prepared statement with Eloquent ORM / laravel

前端 未结 1 896
悲哀的现实
悲哀的现实 2021-01-21 06:29

I\'m new to laravel and use this as a input query:

DB::table(\'user_input\')->insert(array(
                array(\'fname\' => Input::get(\'Name\'),\'lname         


        
1条回答
  •  暖寄归人
    2021-01-21 07:25

    Eloquent does the PDO style prepared statements behind the scenes to protect against things like sql injection. Eloquent models also protect against mass assignment by default. An exception will be thrown unless you specifically note the columns of the database that should be guarded or the inverse (the ones that should be fillable).

    http://laravel.com/docs/4.2/eloquent#mass-assignment

    If you want to dig further in, you can look at the class

    /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php` 
    

    to see how laravel constructs the queries in Eloquent.

    0 讨论(0)
提交回复
热议问题