diff --git a/includes/database.class.php b/includes/database.class.php index 8edbc780..e1c0e92e 100644 --- a/includes/database.class.php +++ b/includes/database.class.php @@ -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:

\n\n
".print_r($data, true)."
"; echo CLI ? strip_tags($error) : $error; - exit; + + if ($isError) + exit; } public static function logger($self, $query, $trace) diff --git a/includes/libs/DbSimple/Mysqli.php b/includes/libs/DbSimple/Mysqli.php index 82b17279..dd674248 100644 --- a/includes/libs/DbSimple/Mysqli.php +++ b/includes/libs/DbSimple/Mysqli.php @@ -163,6 +163,17 @@ class DbSimple_Mysqli extends DbSimple_Database $result = mysqli_query($this->link, $queryMain[0]); if ($result === false) return $this->_setDbError($queryMain[0]); + + if ($this->link->warning_count) { + if ($warn = $this->link->query("SHOW WARNINGS")) { + while ($warnRow = $warn->fetch_row()) + if ($warnRow[0] !== 'Note') + $this->_setLastError(-$warnRow[1], $warnRow[2], $queryMain[0]); + + $warn->close(); + } + } + if (!is_object($result)) { if (preg_match('/^\s* INSERT \s+/six', $queryMain[0])) {