【问题标题】:Codeigniter error with SQL ServerSQL Server 的 Codeigniter 错误
【发布时间】:2012-12-12 06:51:47
【问题描述】:

我在 codeigniter 中使用 sql server 数据库驱动程序,并且正在执行以下查询:

 select A.inst_name,Substring((Select ',' + cast(B.program_id as varchar(15))   
                               From    k12_dms_inst_programs B
                               Where B.inst_id=A.id For XML Path('')),2,8000) As EmployeeList
 From k12_dms_institution_master A
 Group by A.inst_name,A.id

SSMS 中运行良好。

但是当我尝试使用 Codeigniter 执行相同的查询时,我收到以下错误:--

使用 DB-Library(例如 ISQL)或 ODBC 3.7 或更早版本,无法将纯 Unicode 排序规则中的 Unicode 数据或 ntext 数据发送到客户端。

【问题讨论】:

    标签: sql-server-2008 codeigniter


    【解决方案1】:

    在 php.net 上找到了一些解决方案

    1. MSSQLNewbie 2011 年 9 月 19 日 06:34

      In /etc/freetds/freetds.conf add these two lines (last two):
      [global]
      ;tds version = 4.2
      tds version = 8.0  
      client charset = UTF-8
      
      You can edit "charset" in php.ini too (but you don't need if you did it previously in freetds.conf):  
      ; Specify client character set.. 
      ; If empty or not set the client charset from freetds.comf is used 
      ; This is only used when compiled with FreeTDS mssql.charset = "UTF-8"
      
      Use nchar/nvarchar/ntext column types if you need unicode support.
      
    2. dann dot farquhar 在 iteams dot org 24-Sep-2009 11:45

      I found that changing the version in /etc/freetds.conf from 4.2 to 8.0
      fixes this problem without having to make any changes to the SELECT
      statement
      
    3. huberkev11 在 hotmail dot com 12-May-2006 01:47

      This is because you are using column types of like ntext instead of
      text.  There are 2 solutions.
      
      1  Change all ntext column types to text or
      2  Your query must look like: SELECT CAST(field1 AS TEXT) AS field1 FROM table
      

    希望他们能提供帮助。

    【讨论】:

    • 非常感谢您的帮助!
    • @user1163513 告诉我们其中哪些对您有帮助!
    猜你喜欢
    • 1970-01-01
    • 2019-12-27
    • 2016-10-24
    • 2015-12-13
    • 1970-01-01
    • 2010-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多