欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php 执行事务的时候pdo出现问题

程序员文章站 2022-05-18 18:00:04
...

新版本的pdo会有这个问题: 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 qu

新版本的pdo会有这个问题:

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.' in。。。

意思是要么使用fetchAll(),要么使用MYSQL_ATTR_USE_BUFFERED_QUERY这个属性,前者不想那样用,因为担心占用内存,后者发现没效果。

 $this->db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);

参考博客:

http://www.flashj.cn/wp/pdo-transaction-err-in-php.html