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

);


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

);