DB::debugMode() is now deprecated (but still works)

recommended debug system will use $logfile to log SQL to a file
This commit is contained in:
Sergey Tsalkov
2021-06-23 21:23:20 +00:00
parent dc21f646af
commit 30f3d9454a

View File

@@ -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']);
@@ -294,12 +296,7 @@ class MeekroDB {
$results[] = 'ERROR: ' . $args['error'];
}
$is_console = (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']));
if (!$is_console && $this->logfile === STDOUT) {
$results = implode("<br>\n", $results) . "<br>\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); }