php 执行事务的时候pdo出现问题
新版本的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
上一篇: Redis介绍及视频教程
推荐阅读
-
php使用mysqli和pdo扩展,测试对比mysql数据库的执行效率完整示例
-
PHP的PDO事务与自动提交
-
php下pdo的mysql事务处理用法实例
-
php使用mysqli和pdo扩展,测试对比mysql数据库的执行效率完整示例
-
mysql - php pdo对象执行预处理的时,怎么能知道影响行数?
-
PHP中使用PDO操作事务的一些小测试
-
PHP中的PDO操作学习(二)预处理语句及事务
-
php顶用mysql的START TRANSACTION和commit包围了4条插入语句,发现用事务比不用的时候插入的快这是为什么呢
-
php的pdo中对双引号做了什么处理么,为什么这个语句可以执行通过
-
php基于pdo如何实现事务处理的示例代码分享