首先引入相应的类
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
class StudentController extends Controller
插入
$bool = DB::insert('insert into student(name, age) values(?,?)',
['imooc', 18]);
var_dump($bool);
查询1
$students = DB::select('select * from student');
dd($students);
更新
$num = DB::update('update student set age = ? where name = ?',[20, 'sean'] );
var_dump($num);
查询2
$students = DB::select('select * from student where id > ?', [1]);
dd($students);
删除
$num = DB::delete('delete from student where id > ?',[1]);
dd($num);