<?php $Admin = new Admin(); //查找多條記錄,返回二維數組 $Admin->findAll(); $Admin->findAll("id = 22"); $Admin->findAll(array("select"=>"id,name,password","condition"=>"id>2")); $Admin->findAllBySql("select語句"); //查找一條記錄,返回一維數組 $Admin->find(); $Admin->find("id = 22"); $Admin->findByPK(22); $Admin->findByPK(array(22,23,24)); $Admin->findBySql("select語句"); //添加記錄,返回影響行數 $Admin->userName="wang"; $Admin->password="123456"; $Admin->save(); //刪除記錄,返回影響行數 $Admin->deleteAll(); $Admin->deleteAll("id = 22"); $Admin->deleteAllByPK(22); $Admin->deleteAllByPK(array(22,23,24)); //修改記錄,返回影響行數 $Admin->updateAll(關聯數組,"id = 22"); $Admin->updateAllByPK(22,關聯數組); $Admin->updateAllByPK(array(22,23,24),關聯數組); //返回多條記錄的二維數組(select),返回二維數組 $db = Yii::app()->db; $st = $db->createCommand("select語句"); $rs = $st->queryAll(); //返回一條記錄的覺得數組(select),返回一維數組 $db = Yii::app()->db; $st = $db->createCommand("select語句"); $rs = $st->queryRow(); //執行insert、delete、update語句,返回受影響行數 $db = Yii::app()->db; $st = $db->createCommand("insert、delete、update語句"); $rs = $st->execute(); //查詢的記錄數(通常用於select語句) $row = $Admin->count(); $row = $Admin->count("id > 12"); ?>