Yiimodel的待条件和排序查询
$criteria=new CDbCriteria;
创新互联主要从事网站设计、做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务双流,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108
$criteria->addCondition("id=:id", "and");
$criteria->params[':id']=$_POST['book_id'];
$criteria->order = "remove_time desc";
$comments = BooksComments::model()->findAllByAttributes(
array('book_id'=>$_REQUEST["bkid"]),
$criteria
);
$readhistory = BooksHistory::model()->findAllByAttributes(
array('book_id'=>$_REQUEST["bkid"]),
new CDbCriteria(array("order"=>"borrow_time desc"))
);
$bookwaiting = BooksWaiting::model()->findAllByAttributes(
array('book_id'=>$book_id, 'status'=>array(0,1)),
new CDbCriteria(array("order"=>"id "))// ,"limit"=>"20", "offset"=>"0" // limit 0,20
);
修改:
BooksWaiting::model()->updateAll(
array("status"=>"4", "cancel_time"=>getCurTime()),
"book_id=:book_id and user_id=:user_id",
array(":book_id"=>$_REQUEST['book_id'], ":user_id"=>RoleUtil::getUser()->nsn_id)
);
本文题目:Yiimodel的待条件和排序查询
标题来源:http://azwzsj.com/article/pccdcj.html