View Single Post
  #5 (permalink)  
Old 07-19-2007, 05:51 AM
jmut jmut is offline
Junior Member
 
Join Date: Jul 2007
Posts: 2
Default

Quote:
Originally Posted by santouras View Post
My final solution to this turned out quite nicely, and I hope this will be of some use to other people. I extended the DB adaptor for the db object I was using to contain automatic try/catch error reporting. Here's snippets of the relevant code

PHP Code:
class NC_Db_Adaptor extends Zend_Db_Adapter_Pdo_Mysql  {
        
/**
 * Wrapper function for query function to allow for nicer debugging
 *
 * @param string|Zend_Db_Select $sql The SQL statement with placeholders.
 * @param array $bind An array of data to bind to the placeholders.
 * @return Zend_Db_Pdo_Statement
 * @throws Exception To re-throw PDOException.
 */
public function query($sql$bind = array()) {
  try {
    return 
parent::query($sql$bind);
  } catch (
Exception $e) {
    
//check if website is live or local. if live, email and supress error, if
    //local then spit out error message including the sql and bind params

    
throw new Exception($e);
  }
}

Hope some people find this useful
Last line better be
PHP Code:
throw   $e
//not    throw new Exception ($e); 
as in your case you loose whole exception trace and there is little to now use of such exception.
Reply With Quote