doumangzhen7204 2015-07-06 11:28
浏览 62

Laravel 4 + CentOS + MSSQL 2012 =错误

My laravel 4 app is retrieving data from MSSQL 2012 server. It is working fine on Windows but deployed on CentOS I got the following error:

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[HY000]: General error: 4004 General SQL Server error: Check messages from the SQL Server [4004] (severity 16) [(null)]

Checked in the MSSQL error mappings and the exact error is:

Unicode data in a Unicode-only collation or ntext data can not be sent to clients using DB-Library (z. B. isql) or ODBC version 3.7 or earlier use.

After googling the only thing I found was too low freetds version and I changed it from 4.2 to 7.0 in the etc/freetds.conf - nothing changes. Please advise what might be the problem here.

  • 写回答

2条回答 默认 最新

  • doudiandi6967 2015-07-06 15:17
    关注

    Did a quickly search and found a couple more things you can do:

    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"
    

    Hope this works.

    评论

报告相同问题?