This article describes how to query mssql database garbled by thinkphp3. If you need it, refer
Thinkphp query mssql database garbled reason is ThinkPHP default for UTF-8, and msmsql database is a Simplified Chinese version, the storage is GB2312 encoding solution: 1: In ThinkPHP \ Lib \ Core open Db. class. php, add 2 at the end of the file: In Db. class. in php, find function select () and add a $ result = iconv2utf8 ($ result) to $ result = $ this-> query ($ SQL). The Code is as follows: public function iconv2utf8 ($ Result) {$ Row = array (); $ key1 = array_keys ($ Result ); // obtain the key value of the $ Result array in the query Result // print_r ($ key1); $ key2 = array_keys ($ Result [$ key1 [0]); // obtain the key value of the first array ($ key1 [0]) of the query Result $ Result // print_r ($ key2); for ($ I = 0; $ I <count ($ key1); $ I ++) {for ($ j = 0; $ j <count ($ key2); $ j ++) {// encode the query result to a UTF-8 and save it to $ Row, and the $ Row and $ Result keys and values are consistent. $ Row [$ key1 [$ I] [$ key2 [$ j] = iconv ('gb2312 ', 'utf-8', $ Result [$ key1 [$ I] [$ key2 [$ j]) ;}} retrun $ Row ;}