<?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"); ?>
时间: 2024-10-25 17:00:23