diff --git a/db.class.php b/db.class.php index abc6e57..fdd9d1e 100644 --- a/db.class.php +++ b/db.class.php @@ -61,8 +61,9 @@ class DB { return call_user_func_array($fn, $args); } + // --- begin deprecated methods (kept for backwards compatability) static function debugMode($enable=true) { - if ($enable) self::$logfile = STDOUT; + if ($enable) self::$logfile = fopen('php://output', 'w'); else self::$logfile = null; } } @@ -281,6 +282,7 @@ class MeekroDB { $query = preg_replace('/\s+/', ' ', $query); $query = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $query); + $results[] = sprintf('[%s]', date('Y-m-d H:i:s')); $results[] = sprintf('QUERY: %s', $query); $results[] = sprintf('RUNTIME: %s ms', $args['runtime']); @@ -293,13 +295,8 @@ class MeekroDB { if (isset($args['error'])) { $results[] = 'ERROR: ' . $args['error']; } - - $is_console = (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])); - if (!$is_console && $this->logfile === STDOUT) { - $results = implode("
\n", $results) . "
\n"; - } else { - $results = implode("\n", $results) . "\n\n"; - } + + $results = implode("\n", $results) . "\n\n"; if (is_resource($this->logfile)) { fwrite($this->logfile, $results); @@ -308,11 +305,6 @@ class MeekroDB { } } - function debugMode($enable=true) { - if ($enable) $this->logfile = STDOUT; - else $this->logfile = null; - } - public function serverVersion() { $this->get(); return $this->server_info; } public function transactionDepth() { return $this->nested_transactions_count; } public function insertId() { return $this->insert_id; } @@ -915,6 +907,11 @@ class MeekroDB { } // --- begin deprecated methods (kept for backwards compatability) + public function debugMode($enable=true) { + if ($enable) $this->logfile = fopen('php://output', 'w'); + else $this->logfile = null; + } + public function queryOneList() { $args = func_get_args(); return call_user_func_array(array($this, 'queryFirstList'), $args); } public function queryOneRow() { $args = func_get_args(); return call_user_func_array(array($this, 'queryFirstRow'), $args); }