X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fxdb.php;h=34c10e80d3caa4a72615912e35ac3e8220280ac6;hb=5bc6e9e64bbc884c4878b56d3e5cb7b514e66920;hp=d612ed8663786b8af385310c43a58e64f2ed73c2;hpb=85d3b330eaf032a22cecbf10b88447dfc6587176;p=platal.git diff --git a/classes/xdb.php b/classes/xdb.php index d612ed8..34c10e8 100644 --- a/classes/xdb.php +++ b/classes/xdb.php @@ -23,7 +23,8 @@ class XDB { var $_trace_data = array(); - public static function _prepare($args) { + public static function _prepare($args) + { $query = array_map(Array('XDB', '_db_escape'), $args); $query[0] = str_replace('{?}', '%s', str_replace('%', '%%', $args[0])); return call_user_func_array('sprintf', $query); @@ -54,7 +55,8 @@ class XDB return $res; } - public static function _query($query) { + public static function _query($query) + { global $globals; if ($globals->debug & 1) { @@ -65,12 +67,18 @@ class XDB } $trace_data = array('query' => XDB::_reformatQuery($query), 'explain' => $explain); @mysql_free_result($_res); + $time_start = microtime(); } $res = mysql_query($query); if ($globals->debug & 1) { + list($ue, $se) = explode(" ", microtime()); + list($us, $ss) = explode(" ", $time_start); + $time = intval((($ue - $us) + ($se - $ss)) * 1000); $trace_data['error'] = mysql_error(); + $trace_data['exectime'] = $time; + $trace_data['rows'] = @mysql_num_rows() ? mysql_num_rows() : mysql_affected_rows(); $GLOBALS['XDB::trace_data'][] = $trace_data; if (mysql_errno()) { $GLOBALS['XDB::error'] = true; @@ -131,7 +139,7 @@ class XDB } } - public static function trace_format(&$page, $template = 'database-debug.tpl') { + public static function trace_format(&$page, $template = 'skin/common.database-debug.tpl') { $page->assign('trace_data', @$GLOBALS['XDB::trace_data']); $page->assign('db_error', @$GLOBALS['XDB::error']); return $page->fetch($template);