<?PHP$Admin=NewAdmin (); //find multiple records, return two-dimensional array $Admin-FindAll (); $Admin->findall ("id = 22"); $Admin->findall (Array("Select" = "Id,name,password", "condition" = "id>2")); $Admin->findallbysql ("SELECT statement"); //finds a record, returns a one-dimensional array $Admin-find (); $Admin->find ("id = 22"); $Admin->FINDBYPK (22); $Admin->FINDBYPK (Array(22,23,24)); $Admin->findbysql ("SELECT statement"); //Add a record that returns the number of rows affected $Admin->username= "Wang"; $Admin->password= "123456"; $Admin-Save (); //deleting records, returning the number of rows affected $Admin-DeleteAll (); $Admin->deleteall ("id = 22"); $Admin->DELETEALLBYPK (22); $Admin->DELETEALLBYPK (Array(22,23,24)); //modify the record to return the number of rows affected $Admin->updateall (associative array, "id = 22"); $Admin->UPDATEALLBYPK (22,associative arrays); $Admin->UPDATEALLBYPK (Array(22,23,24),associative arrays); //returns a two-dimensional array (select) of multiple records, returning a two-dimensional array $db= Yii::app ()DB; $st=$db->createcommand ("SELECT statement"); $rs=$st-Queryall (); //returns the array (select) of a record, returning a one-dimensional array $db= Yii::app ()DB; $st=$db->createcommand ("SELECT statement"); $rs=$st-Queryrow (); //executes an INSERT, delete, UPDATE statement that returns the number of rows affected $db= Yii::app ()DB; $st=$db->createcommand ("Insert, delete, UPDATE statement"); $rs=$st-execute (); //number of records queried (typically for SELECT statements) $row=$Admin-Count(); $row=$Admin-Count("ID > 12"); ?>
Curd operations in the YII framework