分页错误 [ 新手入门 ]
public function actionMy()
{
$sql = 'SELECT bid FROM {{book_user}} WHERE uid='. Yii::app()->user->getid();
$criteria=new CDbCriteria();
$result = Yii::app()->db->createCommand($sql)->query();
$pages=new CPagination($result->rowCount);
$pages->pageSize=8;
$pages->applyLimit($criteria);
$result=Yii::app()->db->createCommand($sql." LIMIT :offset,:limit");
$result->bindValue(':offset', $pages->currentPage*$pages->pageSize);
$result->bindValue(':limit', $pages->pageSize);
$books=$result->query();
$this->render('mybook',array(
'books'=>$books,
'pages'=>$pages,
));
}
返回错误信息: CDbException Description
CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
是什么原因?
共 4 条回复
aqiang
注册时间:2011-03-07
最后登录:2021-02-25
在线时长:56小时28分
最后登录:2021-02-25
在线时长:56小时28分
- 粉丝9
- 金钱11045
- 威望20
- 积分11805