Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r939 -r944 --- trunk/core/kernel/application.php (.../application.php) (revision 939) +++ trunk/core/kernel/application.php (.../application.php) (revision 944) @@ -150,7 +150,7 @@ */ function Init() { - $this->DB = new DBConnection(SQL_TYPE); + $this->DB = new DBConnection(SQL_TYPE, Array(&$this,'handleSQLError') ); $this->DB->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB); $this->DB->debugMode = $this->isDebugMode(); @@ -773,6 +773,35 @@ $event_manager =& $this->recallObject('EventManager'); $event_manager->setEvent($prefix_special,$event_name); } + + + /** + * SQL Error Handler + * + * @param int $code + * @param string $msg + * @param string $sql + * @return bool + * @access private + */ + function handleSQLError($code,$msg,$sql) + { + global $debugger; + if($debugger) + { + $errorLevel=defined('DBG_SQL_FAILURE')&&DBG_SQL_FAILURE?E_USER_ERROR:E_USER_WARNING; + $debugger->dumpVars($_REQUEST); + $debugger->appendTrace(); + trigger_error(''.$msg.' ('.$code.')
SQL: '.$debugger->highlightString($sql),$errorLevel); + return true; + } + else + { + echo 'xProcessing SQL: '.$sql.'
'; + echo 'Error ('.$code.'): '.$msg.'
'; + return false; + } + } } ?> \ No newline at end of file Index: trunk/core/kernel/db/db_connection.php =================================================================== diff -u -N -r932 -r944 --- trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 932) +++ trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 944) @@ -83,6 +83,10 @@ { $this->errorHandler = Array(&$this,'handleError'); } + else + { + $this->errorHandler=$errorHandler; + } } /** @@ -357,8 +361,29 @@ function debugQuery($sql, $key_field = null) { + global $debugger; $query_func = $this->getMetaFunction('query'); + + // set 1st checkpoint: begin + $isSkipTable=true; + $profileSQLs=defined('DBG_SQL_PROFILE')&&DBG_SQL_PROFILE; + if($profileSQLs) + { + $isSkipTable=isSkipTable($sql); + if(!$isSkipTable) + { + $queryID=$debugger->generateID(); + $debugger->profileStart('sql_'.$queryID, $debugger->formatSQL($sql) ); + } + } + // set 1st checkpoint: end + $this->queryID = $query_func($sql,$this->connectionID); + + // set 2nd checkpoint: begin + if(!$isSkipTable) $debugger->profileFinish('sql_'.$queryID); + // set 2nd checkpoint: end + if( is_resource($this->queryID) ) { $ret = Array();