PDO处理事务部分的报错 :Uncaught exception 'PDOException' with message There is no active transaction
2014-05-26 10:42
821 查看
###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
相关文章推荐
- PHP + mysql 遇到Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error
- Caused by: There is no result type defined for type 'json' mapped with name 'rebback'. Did you mean
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'cla
- MyBatisSystemException ReflectionException: There is no getter for property named 'userid' in 'class
- Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'Multibyte function overloading in
- Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory解决方法
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'funcSetId' in 'class java.lang.Integer'
- com.ibatis.common.beans.ProbeException: There is no READABLE property named 'value' in class 'com.ving.xzfw.vo.PaymentInfo'
- ThinkPHP v3.2.3 数据库读写分离,开启事务时报错:There is no active transaction
- com.ibatis.common.beans.ProbeException: There is no READABLE property named 'value' in class 'com.ving.xzfw.vo.PaymentInfo'
- PHPExcel的exception 'Exception' with message 'The filename is not recognised as an OLE file问题解决
- iPhone: There is no SDK with the name or path 'iphoneos3.0'
- There is no result type defined for type 'json' mapped with name 'success'.
- ProbeException解决办法:There is no WRITEABLE property named 'id' in class 'java.lang.String'
- There is no result type defined for type 'json' mapped with name 'success'.
- Struts2 错误:There is no result type defined for type 'json' mapped with name 'success'.
- Ibatis中的一个“There is no READABLE property named 'uId' in class 'useri 的解决办法
- IOS开发之Terminating app due to uncaught exception '', reason,** First throw call stack:报错处理
- 解决 C++错误 error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no
- mybatis There is no getter for property named 'xx' in 'class java.lang.String