ロブが言ったことに基づいて、
入って、Zend_Db_Exceptionクラスを変更しました。と追加
public $_stmt = null;
次に、Zend_Db_Statement_Exceptionクラスで、__constructを次のように変更しました。
/**
* @param string $message
* @param string|int $code
* @param Exception $chainedException
* @param Statment i.e. Query String
*/
public function __construct($message = null, $code = null, Exception $chainedException=null, $_stmt = null)
{
$this->message = $message;
$this->code = $code;
$this->_chainedException = $chainedException;
$this->_stmt = $_stmt;
}
次に、Zend_Db_Statement_Pdoクラスで、すべての
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
に
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e, $this->_stmt);
次に、Zend_Controller_Plugin_ErrorHandlerアクションの横で、これを先導します。
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case "EXCEPTION_NO_ROUTE":
case "EXCEPTION_NO_CONTROLLER":
case "EXCEPTION_NO_ACTION":
// 404 error -- controller or action not found
$this->view->title = "Page Not Found";
break;
default:
$this->view->title = "Unknown Error";
break;
}
$sql = null;
$offending_query = null;
$exception = $errors->exception;
try
{
$offending_query = $exception->_stmt->queryString;
}
catch (Zend_Exception $e)
{ }
このZendDBコアの変更により、プロファイラーとは異なり、パフォーマンスへの影響をゼロにして、問題のあるSQLステートメントをすべてキャプチャできるようになりました。