Authored by 沈海生

添加提示

... ... @@ -143,11 +143,11 @@ class PDOConnection extends Root
$_serverConfig = $server->getServerConfig('database', $this->_database);
$_dbConfig = $server->getServerConfig('mysql');
if (!isset($_serverConfig[$modality]) || !in_array($modality, array('write', 'read'))) {
throw new DebugException('MySQL Not Modality ' . $modality);
throw new DebugException('MySQL db:'.$this->_database.' Not Modality ' . $modality);
}
$_server = $server->getServerMap($_serverConfig[$modality], Server::SERVER_SELECT_MODEL_RAND);
if (empty($_server)) {
throw new DebugException('Db Server is null.');
throw new DebugException('Db:'.$this->_database.' Server is null.');
}
$charset = isset($_dbConfig['charset']) ? $_dbConfig['charset'] : 'UTF8';
#如果设置了 dbname 使用 配置的
... ... @@ -158,7 +158,12 @@ class PDOConnection extends Root
\PDO::ATTR_PERSISTENT => isset($_dbConfig['persistent']) ? $_dbConfig['persistent'] : false,
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . $charset
);
try {
$_connection = new \PDO($dsn, $_serverConfig['username'], $_serverConfig['passwd'], $options);
} catch (\Exception $e) {
throw new DebugException($dsn . ' error ' . $e->getMessage());
}
foreach ($this->_attribute as $key => $val) {
$_connection->setAttribute($key, $val);
}
... ...