THINKPHP3 Query MSSQL Database garbled solution method

Source: Internet
Author: User
Tags mssql php and

  This article mainly introduces the THINKPHP3 query MSSQL database garbled solution, the need for friends can refer to the following

thinkphp Query MSSQL database appears garbled reason is thinkphp default for UTF-8, and Msmsql database is Simplified Chinese version, storage is GB2312 coding   Solution:   1: In Thinkphplibcore Open the Db.class.php and add 2 at the end: Db.class.php to find the function select (), in $result = $this->query ($sql), followed by a $result =iconv2utf8 ($result), OK   Code as follows: Public function Iconv2utf8 ($Result) {          $Row =array ();   & nbsp                  $key 1=array_keys ($Result);  //$result The value of the array of query results            //print_r ($key 1);             $key 2=array_keys ($Result [$key 1[0]]);     //Query Results $result the first array ($key 1[0]) of the key value             //print_r ($key 2);                    for ($i =0 $i <count ($key 1) $i + +) {    &NB Sp For ($j =0 $j <count ($key 2); $j + +) {                        &N Bsp  //query result encoding to utf-8, and deposited in $row, and $row with $result key and value consistent                           $Ro w[$key 1[$i]][$key 2[$j]]=iconv (' gb2312 ', ' utf-8 ', $Result [$key 1[$i]][$key 2[$j]]);   }          &nbsp         retrun $Row;  }    
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.