mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
fixed Database error handling
This commit is contained in:
@@ -28,10 +28,11 @@ class DB
|
||||
$options = &self::$optionsCache[$idx];
|
||||
$interface = DbSimple_Generic::connect(self::createConnectSyntax($options));
|
||||
|
||||
if (!$interface)
|
||||
$interface->setErrorHandler(array('DB', 'errorHandler'));
|
||||
|
||||
if ($interface->error)
|
||||
die('Failed to connect to database.');
|
||||
|
||||
$interface->setErrorHandler(array('DB', 'errorHandler'));
|
||||
$interface->query('SET NAMES ?', 'utf8');
|
||||
if ($options['prefix'])
|
||||
$interface->setIdentPrefix($options['prefix']);
|
||||
|
||||
@@ -38,15 +38,17 @@ class DbSimple_Mysqli extends DbSimple_Database
|
||||
$this->link->options(MYSQLI_OPT_CONNECT_TIMEOUT,
|
||||
isset($dsn['timeout']) && $dsn['timeout'] ? $dsn['timeout'] : 0);
|
||||
|
||||
$this->link->real_connect((isset($dsn['persist']) && $dsn['persist'])?'p:'.$dsn['host']:$dsn['host'],
|
||||
if (@$this->link->real_connect((isset($dsn['persist']) && $dsn['persist'])?'p:'.$dsn['host']:$dsn['host'],
|
||||
$dsn['user'], isset($dsn['pass'])?$dsn['pass']:'', $base,
|
||||
empty($dsn['port'])?NULL:$dsn['port'], NULL,
|
||||
(isset($dsn['compression']) && $dsn['compression'])
|
||||
? MYSQLI_CLIENT_COMPRESS : NULL);
|
||||
(isset($dsn['compression']) && $dsn['compression']) ? MYSQLI_CLIENT_COMPRESS : NULL))
|
||||
{
|
||||
$this->link->set_charset((isset($dsn['enc']) ? $dsn['enc'] : 'UTF8'));
|
||||
|
||||
$this->link->set_charset((isset($dsn['enc']) ? $dsn['enc'] : 'UTF8'));
|
||||
|
||||
$this->isMySQLnd = method_exists('mysqli_result', 'fetch_all');
|
||||
$this->isMySQLnd = method_exists('mysqli_result', 'fetch_all');
|
||||
}
|
||||
else
|
||||
return $this->_setDbError(null, 'mysqli_real_connect @ ' . $dsn['host']);
|
||||
}
|
||||
catch (mysqli_sql_exception $e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user