-
幕布斯6054654
做这个插入查询$insert = DB::insert("insert into some_table (col1, col2, col3) values ('value1', 'value2', 'value3')");选择查询$results = DB::select("select * from some_table where some_col = 'some_value'");更新查询$update = DB::update("update some_table set col1 = ? , col2 = ? where col3 = ?", ['value1' , 'value2', 'value3']);删除查询$delete = DB::delete('delete from some_table where col = ?',['value']);您也可以一次删除多行。喜欢$delete = DB::delete('delete from users where id = ?',[1, 2, 3]);
-
慕的地6264312
$users = DB::select('select * from users where active = ?', [1]);
return view('user.index', ['users' => $users]);
-
慕沐林林
你可以这样做对于选择查询$users = DB::select('select * from users where active = ?', [1]);对于更新查询$affected = DB::update('update users set votes = 100 where name = ?', ['John']);对于删除查询$deleted = DB::delete('delete from users');对于插入查询DB::insert('insert into users (id, name) values (?, ?)', [1, 'Dayle']);