新版本的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