aqiang 2011-08-15 14:08:03 4654次浏览 4条回复 0 0 0
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.

是什么原因?

您需要登录后才可以回复。登录 | 立即注册