我是靠谱客的博主 美好麦片,这篇文章主要介绍PDO报错:Cannot execute queries while other unbuffered queries are active.,现在分享给大家,希望可以做个参考。

错误信息:

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());
}




最后

以上就是美好麦片最近收集整理的关于PDO报错:Cannot execute queries while other unbuffered queries are active.的全部内容,更多相关PDO报错:Cannot内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(117)

评论列表共有 0 条评论

立即
投稿
返回
顶部