首页 > 代码库 > Yii model的待条件和排序查询

Yii model的待条件和排序查询

$criteria=new CDbCriteria;   

$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"))

);


本文出自 “小何贝贝的技术空间” 博客,请务必保留此出处http://babyhe.blog.51cto.com/1104064/1556720

Yii model的待条件和排序查询