thinkphp icon indicating copy to clipboard operation
thinkphp copied to clipboard

mysql驱动 - 解析pdo连接的dsn信息 方法错误

Open lizhong43403 opened this issue 9 years ago • 0 comments

如果用一下这种方式连接数据库,DB_CONFIG2 为配置中数据库连接(数组格式)

'DB_CONFIG2' => array(
    'db_type'  => 'mysql',
    'db_user'  => 'root',
    'db_pwd'   => '1234',
    'db_host'  => 'localhost',
    'db_port'  => '3306',
    'db_name'  => 'thinkphp',
    'db_charset'=>    'utf8',
)

$User = M('User','other_','DB_CONFIG2'); 

// 会出一下结果 SQLSTATE[HY000] [2002] No such file or directory。
Think\Db\Driver\Mysql::parseDsn($config) `=>` mysql:dbname=thinkphp;host=localhost;port=3306;charset=utf8

// 与文档中的`mysql://root:1234@localhost:3306/thinkphp#utf8`格式不一致

lizhong43403 avatar Jan 05 '17 13:01 lizhong43403