Skip to content

Instantly share code, notes, and snippets.

@jonathonbyrdziak
Created April 20, 2016 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathonbyrdziak/16d9e112d865913f393f9d081764bb7c to your computer and use it in GitHub Desktop.
Save jonathonbyrdziak/16d9e112d865913f393f9d081764bb7c to your computer and use it in GitHub Desktop.
enhance the Magento sql debugging.
<?php // <-- this line is just to color the code for you. Do not include it
// comment out the current exception throw.
//throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
// Modified the next line and added the subequent lines to show the full SQL query and params:
$msg = "SQL ERROR: ". $e->getMessage() . "\n";
$msg .= "SQL QUERY: <span style='color: maroon;'>" . $this->_stmt->queryString."</span>\n";
if(!empty($params)) {
$msg .= "SQL PARAMS: ('". implode("','", $params) ."')\n";
}
$dbsEx = new Zend_Db_Statement_Exception($msg, (int) $e->getCode(), $e);
throw $dbsEx;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment