DB façade, Query Builder, eloquent ORM curd

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.