A. db façade 1.insertdb::insert (' INSERT into table (' name ') ' Value (?) ', [' Test ']); 2.updatedb::update (' Update to table set Name=? Where id=? ', [' Test ', ten]); 3.deleteDB::d elete (' delete from TB where id=? ', [1]); 4.selectdb:select (' SELECT * from TB '); Consult the builder 1.insertdb::table (' TB ')->insert ([' name ' = ' = ' test ']), 2.updatedb::table (' TB ')->where (' id ', 1), Update ([' name ' = ' Test ']), 3.deletedb::table (' TB ')->where (' id ', 1)->delete () 4.select# multiple db::table (' TB ')- >where (' Cat ', 1)->orwhere (function ($query) {return $query->where (' vote ', ' > ', 1);}) ->orderby (' id ', ' DESC ')->select (' name ')->skip (5)->take ()->get (); #一条DB:: Table (' TB ')->where (' Cat ', 1)->first (); #一列DB:: Table (' TB ')->where (' Cat ', 1)->value (' col '); eloquent ORM (itself a query builder) 1.insert$ model = new Tbmodel; $model->name = ' test '; $model->save (); Use Create, but models are required to qualify fillable or guardedtbmodel::create ([' Name ' = = ' Test '); 2.update$model = Tbmodel::first (1); $model->name = ' test '; $model->save ();And only the specified field is updated, as with the query builder $model = Tbmodel::first (1), $model->where (' Time ', today ())->update ([' delayed ' =>1]); 3. Deletetbmodel::first (1)->delete (); Tbmodel::d estory (1); Flight::where (' id ', 1)->delete (); 4.select# multiple tbmodel::all (); Tbmodel::get (); #单条TbModel:: Find (1); Use the primary key to retrieve the Firsttbmodel::where (' Time ', today ())->first () If the query condition takes where and is not a primary key;
DB façade, Query Builder, eloquent ORM curd