thinkphp Query MSSQL database appears garbled reason is thinkphp default for UTF-8, and Msmsql database is Simplified Chinese version, storage is GB2312 code
Workaround:
1: Open the Db.class.php in Thinkphp\lib\core, at the back of it plus
2: In Db.class.php find function Select (), in $result = $this->query ($sql), followed by a $result =iconv2utf8 ($result), OK
Copy Code code as follows:
Public Function Iconv2utf8 ($Result) {
$Row =array ();
$key 1=array_keys ($Result); The key value of the array that $result the query result
Print_r ($key 1);
$key 2=array_keys ($Result [$key 1[0]]);
The key value of the first array ($key 1[0] of the query result $result)
Print_r ($key 2);
For ($i =0 $i <count ($key 1); $i + +) {
For ($j =0 $j <count ($key 2); $j + +) {
The query result encoding is changed to UTF-8 and stored in $row, and $row and $result keys are consistent with the values
$Row [$key 1[$i]][$key 2[$j]]=iconv (' gb2312 ', ' utf-8 ', $Result [$key 1[$i]][$key]]);
}
}
Retrun $Row;
}