public function real_connect($host, $user, $password, $name, $charset = '', $engine = '')
{
if (strpos($host, ':') !== FALSE) {
list($host, $port) = explode(':', $host);
} else {
$port = 3306;
}
try {
$link = new PDO("mysql:host={$host};port={$port};dbname={$name}", $user, $password);
//$link->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
} catch (Exception $e) {
$this->error(-10000, '连接数据库服务器失败:' . $e->getMessage());
return FALSE;
}
//$link->setFetchMode(PDO::FETCH_ASSOC);
$charset and $link->query("SET names {$charset}, sql_mode=''");
//$link->query('SET NAMES '.($charset ? $charset.',' : '').', sql_mode=""');
return $link;
}