error)
die('Failed to connect to database.');
$interface->setErrorHandler(['DB', 'errorHandler']);
$interface->query('SET NAMES ?', 'utf8mb4');
if ($options['prefix'])
$interface->setIdentPrefix($options['prefix']);
// disable STRICT_TRANS_TABLES and STRICT_ALL_TABLES off. It prevents usage of implicit default values.
if ($idx == DB_AOWOW)
$interface->query("SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION'");
// disable ONLY_FULL_GROUP_BY (Allows for non-aggregated selects in a group-by query)
else
$interface->query("SET SESSION sql_mode = ''");
self::$interfaceCache[$idx] = &$interface;
self::$connectionCache[$idx] = true;
}
public static function errorHandler($message, $data)
{
if (!error_reporting())
return;
$error = "DB ERROR:
\n\n
".print_r($data, true).""; echo CLI ? strip_tags($error) : $error; exit; } public static function logger($self, $query, $trace) { if ($trace) // actual query self::$logs[] = [substr(str_replace("\n", ' ', $query), 0, 200)]; else // the statistics { end(self::$logs); self::$logs[key(self::$logs)][] = substr(explode(';', $query)[0], 5); } } public static function getLogs() { $out = '
| Time | Query | |
|---|---|---|
| '.$i.'. | '.$t.' | '.$l.' |