PDO报错:Cannot execute queries while other unbuffered queries are active.

来源:互联网 发布:云计算技术与应用课程 编辑:程序博客网 时间:2024/06/06 02:20

错误信息:

Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run agains
t mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

也就是说,未结束之前的查询而再次查询,这样是会出错地,所以要释放掉之前的查询。

解决方法:

$configs = $this->config;// 解决方法就是增加这句$configs['params'][constant('PDO::MYSQL_ATTR_USE_BUFFERED_QUERY')] = true;if ($this->pconnect) {$configs ['params'] [constant ( 'PDO::ATTR_PERSISTENT' )] = true;}try {$this->link = new PDO ( $configs ['dsn'], $configs ['username'], $configs ['password'], $configs ['params'] );} catch ( PDOException $e ) {throw new exception ( $e->getMessage () );//exit('连接失败:'.$e->getMessage()); }




原创粉丝点击