$ Customer = new customer ();//Insert operation
$ Customer-> name = 'cubs ';
$ Customer-> Save ();
//Modify operation
$ Model = Customer: findone (1 );
$ Model-> name = 'xiaoyang ';
$ Model-> Save ();
/* ------------------ Modify the specified condition set --------------------*/
Customer: updateall (['age' => 24], ['age' => 18]); // change all ages to 18
//Delete
$ Model-> Delete ();
Customer::Deleteall('Age>: Age and Gender =: Gender',[': Age'=>20,': Gender'=>'M']);
//Query
/* Like query */
Customer: Find ()-> andfilterwhere (['like', 'name', 'yang']);
/* Orderby query */
Customer: Find ()-> orderby (['date' => sort_desc]);
/* Query by primary key ID */
Customer: findone ($ id );
/* Multi-condition query */
Customer: Find ()-> where (['name' => 'sanyo '])
-> Andwhere (['age' => 24])
-> All (); // query returns all
//-> One () queries one result
//-> Count ()
/*Multi-table join query*/$ Model=NewCustomer ();$ Model-> Fiind ()->Join('Left join', 'student ', 'student. cid = Customer. id')-> Where ('student. id' => \ yii ::$ App-> User->ID)-> Andwhere ('is _ OK = 1')-> One ();
Yii2.0 curd operation