Inserting a variable in a raw sql query Laravel

后端 未结 3 504
既然无缘
既然无缘 2021-01-05 01:33

I am inside a function in a controller.

So from the Form, I get a value for a variable, say:

$x = \"whatever\";

Then I need to embe

3条回答
  •  無奈伤痛
    2021-01-05 02:15

    Regarding this tutorial

    $results = DB::select( DB::raw("SELECT * FROM some_table WHERE some_col = :somevariable"), array(
       'somevariable' => $someVariable,
     ));
    

提交回复
热议问题