Created
April 2, 2018 19:24
-
-
Save jtnix/46cdae01ba03b96d1dbe047e192784d8 to your computer and use it in GitHub Desktop.
Improved PDO Exception messaging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: library/Zend/Db/Statement/Pdo.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- library/Zend/Db/Statement/Pdo.php (revision 4524) | |
+++ library/Zend/Db/Statement/Pdo.php (revision ) | |
@@ -231,7 +231,12 @@ | |
} | |
} catch (PDOException $e) { | |
require_once 'Zend/Db/Statement/Exception.php'; | |
- throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e); | |
+ $msg = "SQL ERROR: ". $e->getMessage() . "\n"; | |
+ $msg .= "SQL QUERY:" . $this->_stmt->queryString."\n"; | |
+ if(!empty($params)) { | |
+ $msg .= "SQL PARAMS: ('". implode("','", $params) ."')\n"; | |
+ } | |
+ throw new Zend_Db_Statement_Exception($msg, (int) $e->getCode(), $e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment