PDO处理事务部分的报错 :Uncaught exception 'PDOException' with message There is no active transaction
来源:互联网 发布:恐怖悬疑电影 知乎 编辑:程序博客网 时间:2024/05/20 01:08
###Transaction function transaction($sqlQueue) { //$this->connection(); if(count($sqlQueue)>0) { /* * Manual says: * If you do not fetch all of the data in a result set before issuing your next call to PDO::query(), your call may fail. Call PDOStatement::closeCursor() to release the database resources associated with the PDOStatement object before issuing your next call to PDO::query(). * */ $this->result->closeCursor(); if($this->charset !== NULL) { $this->db->exec("SET NAMES ".$this->charset); }else{ $this->db->exec("SET NAMES utf8"); } try { $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); $this->db->beginTransaction(); foreach ($sqlQueue as $sql) { $this->db->exec($sql); } $this->db->commit(); return true; } catch (Exception $e) { $this->logWriter->writeLog("事务处理出错:".$e->getMessage()."\nSQL语句:".Utils::arrToString($sqlQueue)); $this->db->rollBack(); return false; } }else{ return false; } }
转自:http://www.flashj.cn/wp/pdo-transaction-err-in-php.html
0 0
- PDO处理事务部分的报错 :Uncaught exception 'PDOException' with message There is no active transaction
- Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory解决方法
- ThinkPHP v3.2.3 数据库读写分离,开启事务时报错:There is no active transaction
- SQLite的 cannot commit - no transaction is active报错
- PHP + mysql 遇到Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error
- BUG排查:PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1040] Too ma
- php连接zookeeper 报Uncaught exception 'ZookeeperNoNodeException' with message 'no node'
- Fatal error: Uncaught exception 'PDOException'
- drupal drush exception 'PDOException' with message 'SQLSTATE[HY000] [2002]
- Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to
- SSH 报 There is no result type defined for type 'json' mapped with name 'success'. 错
- weblogic The transaction is no longer active
- No transaction is currently active问题
- 报错 Exception 'yii\db\Exception' with message 'SQLSTATE[HY000]
- birt报表报错, There is no report design object available.org.eclipse.birt.report.exception.ViewerExcepti
- message There is no Action mapped for namespace [/] and action name [user1_execute] associated with
- message There is no Action mapped for namespace [/] and action name [login] associated with context
- robotium的There is no XXX with index 错误
- [转]通过32bit Winpe 安装64bit windows2008
- Linux 编译OpenJDK
- C++11 中的线程、锁和条件变量
- C或C++编程中使用头文件的顺序
- 项目学习主题七:读取xml
- PDO处理事务部分的报错 :Uncaught exception 'PDOException' with message There is no active transaction
- Iperf 源代码分析(一)
- Android解析json
- IT招聘量超越房地产 聚焦未来三大热门领域
- jquery grid
- 让人爱不释手的13套精美 Web 应用程序图标素材
- MFC 里的 CFile 类的一个函数 CreateFile
- 大家好 新人报道
- 获取模拟电压值(第三篇)