1. $ admin = Admin: model ()-> findAll ($ condition, $ params ); This method queries a set based on a condition, such: FindAll ("username =: name", array (": name" => $ username )); 2. $ admin = Admin: model ()-> findAllByPk ($ postIDs, $ condition, $ params ); FindAllByPk ($ id, "name like ': name' and age =: age", array (': name' => $ name, 'age' => $ age )); This method queries a set based on the primary key. Multiple primary keys can be used, for example: FindAllByPk (array (1, 2 )); 3. $ admin = Admin: model ()-> findAllByAttributes ($ attributes, $ condition, $ params ); This method is used to query a set based on conditions. Multiple conditions can be used to put conditions in an array, for example: FindAllByAttributes (array ('username' => 'admin ')); 4. $ admin = Admin: model ()-> findAllBySql ($ SQL, $ params ); This method queries an array based on SQL statements, such: FindAllBySql ("select * from admin whereusername =: name", array (': name' => 'admin ')); 2. insert)
$ Con = Yii: app ()-> db; $ Datas ['title'] = Yii: app ()-> request-> getParam ('title '); $ Datas ['content'] = Yii: app ()-> request-> getParam ('content ');; $ Datas ['add _ time'] = time (); // Warehouse receiving $ Res = $ con-> createCommand ()-> insert ('note', $ datas ); $ Admin = newAdmin; $ Admin-> username = $ username; $ Admin-> password = $ password; If ($ admin-> save ()> 0 ){ Echo "added successfully "; } Else { Echo "failed to add "; } $ UserLimit = new UserLimit (); $ UserLimit-> item = 0.30000; If ($ userLimit-> insert (){ } |