Libs/DBSimple

* also collect sql warnings for error handling
 * urlescape user/password on the db connection url (mysqli://)
This commit is contained in:
Sarjuuk
2024-01-31 22:20:35 +01:00
parent d8a6f67688
commit a14b5e2be1
2 changed files with 21 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ class DB
private static function createConnectSyntax(&$options)
{
return 'mysqli://'.$options['user'].':'.$options['pass'].'@'.$options['host'].'/'.$options['db'];
return 'mysqli://'.urlencode($options['user']).':'.urlencode($options['pass']).'@'.$options['host'].'/'.$options['db'];
}
public static function connect($idx)
@@ -72,10 +72,18 @@ class DB
if (!error_reporting())
return;
// continue on warning, end on error
$isError = $data['code'] > 0;
// make number sensible again
$data['code'] = abs($data['code']);
$error = "DB ERROR:<br /><br />\n\n<pre>".print_r($data, true)."</pre>";
echo CLI ? strip_tags($error) : $error;
exit;
if ($isError)
exit;
}
public static function logger($self, $query, $trace)