Basically want to know how to add variable to the raw insert query instead of specifying values?
Dec 7, 2019
6
Level 3
Raw SQL query and binding data?
create.blade.php
First Name Last Name SAVEcontroller >
Route::POST('/form-filled', 'PagesController@store');
& then my store function is:
DB::insert('insert into projects (title, description) values (?, ?)', ['Dynamic' 'some stuff about stuff']);
I can get my form values as follows in my store function:
$title = request('title'); $description = request('description');
How do I use the $title and $description variables into the query?
Level 70
What if you try this?
public function store(Request $request){
$title = $request->title;
$description = $request->description;
\DB::insert('insert into projects (title, description) values (?, ?)', [$title, $description]);
}
2 likes
Please or to participate in this conversation.