How to solve the problem of garbled characters in thinkphp3 query mssql database

不言
Release: 2023-04-01 14:08:01
Original
1895 people have browsed it

This article mainly introduces the solution to garbled characters in thinkphp3 query mssql database. Friends who need it can refer to it

The reason why thinkphp queries mssql database with garbled characters is that ThinkPHP defaults to UTF-8, and the msmsql database is simplified The Chinese version stores GB2312 encoding

Solution:

1: Open Db.class.php in ThinkPHP\Lib\Core and add
2 at the end: Db.class.php finds function select(), add $result=iconv2utf8($result) after $result = $this->query($sql);, and it’s OK.

The code is as follows:

public function iconv2utf8($Result) {        
 $Row=array();                   
 $key1=array_keys($Result);  //取查询结果$Result的数组的键值          
 //print_r($key1);          
 $key2=array_keys($Result[$key1[0]]);   
 //取查询结果$Result的第一个数组($key1[0])的键值           
 //print_r($key2);                  
 for($i=0;$i
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

About thinkPHP’s method of implementing batch deletion

About thinkPHP3.2’s implementation of paging custom styles Method

About thinkPHP’s built-in string interception function method

##

The above is the detailed content of How to solve the problem of garbled characters in thinkphp3 query mssql database. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!