Skip to content

Commit 51965be

Browse files
committedFeb 6, 2015
Update Mysql.class.php
当php大于5.3.6,但编译的pdo_mysql是低版本时会出问题; 很多扩展都是这样,虽然文档中说是按PHP版本判断,实际应该按扩展版本来判断
1 parent 0747fee commit 51965be

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed
 

‎ThinkPHP/Library/Think/Db/Driver/Mysql.class.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ protected function parseDsn($config){
3232
}
3333

3434
if(!empty($config['charset'])){
35-
if(version_compare(PHP_VERSION,'5.3.6','<')){
36-
// PHP5.3.6以下不支持charset设置
37-
$this->options[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES '.$config['charset'];
38-
}else{
39-
$dsn .= ';charset='.$config['charset'];
40-
}
35+
//为兼容各版本PHP,用两种方式设置编码
36+
$this->options[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES '.$config['charset'];
37+
$dsn .= ';charset='.$config['charset'];
4138
}
4239
return $dsn;
4340
}

0 commit comments

Comments
 (0)
Please sign in to comment.