测试环境: thinkphp3.1.3  +oracle 11g

(1)

DbOracle.class.php  找到构造函数

 public function __construct($config=''){
       putenv("NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1");


确保putenv 里面填写的是  oracle 的编码,可以自己去查询


(2)  控制器层  读取 数据模块:

$db=M('tqa_metarialcheck');


$list= $db->where($whereS)->limit($first,$pagesize)->order($sorter)->select();


 for($i=0;$i<count($list);$i++)
             foreach($list[$i] as $k=>$v)
             {
                 $list[$i][$k]=mb_convert_encoding($v,'utf-8','gbk');   //此处要确保开启: php_mbString 的扩展
                 //$list[$i][$k]=iconv('gbk','utf-8',$v);
                 }
                
                
             $Json = json_encode($list);

(3) 服务器的环境变量设置:(注意这里一定是服务器的环境变量)

THINKPHP 读取oracle乱码问题解决方案


相关文章:

  • 2021-08-03
  • 2022-02-22
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2021-06-25
  • 2021-09-01
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2021-03-26
  • 2021-10-04
  • 2022-12-23
  • 2021-06-13
  • 2021-12-05
  • 2021-11-06
相关资源
相似解决方案