插入 成功返回true,失败直接报错
$data = DB::insert('insert into student(id,name,addr,phone) values(?,?,?,?)',[4,'Leslie','香港','12993']);
$data = DB::insert('insert into student(name,addr,phone) values(:name,:addr,:phone)',['name'=>'Leslie','addr'=>'香港','phone'=>'12993']);
修改 修改成功,返回受影响行数
$data = DB::update('update student set name=?,addr=? where id=4',['孙双','东吴']);
$data = DB::update('update student set name = :name,addr = :addr where id=2',['name'=>'刘玄德','addr'=>'川蜀']);
查询
$data = DB::select('select * from student where id=?',[1]);
$data = DB::select('select * from student where name=:name',['name'=>'刘玄德']);
删除 删除成功,返回受影响行数
$data = DB::delete('delete from student where id=?',[1]);
$data = DB::delete('delete from student where id=:id1 or id=:id2',['id1'=>2,'id2'=>3]);
添加
$data = DB::table('student')->insert(['name'=>'曹操','addr'=>'魏国']);
$data = DB::table('student')->insert([['name'=>'刘备','addr'=>'川蜀'],['name'=>'诸葛亮','addr'=>'茅庐']]);
修改
$data = DB::table('student')->where('id',5)->update(['name'=>'曹操','addr'=>'大魏']);
查询
$data = DB::table('student')->select('name','addr','phone')->where('id',5)->get();
删除
$data = DB::table('student')->where('id',7)->delete();