2014年3月3日 星期一

CentOS 6.4 PHP mssql UTF8

1. 修改 /etc/freetds.conf

[10.10.64.6]
        host = 10.10.64.6
        port = 1433
        tds version = 8.0
        client charset = UTF-8

2. 修改 /etc/php.ini

mssql.charset = "UTF-8"


3. 不確定是否必要
yum install freetds-devel  php-odbc


4.使用 /usr/bin/tsql測試 連線
tsql -H 10.10.64.6 -p 1433 -U username
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"

1> use dbname
2> GO
1> select * from tablename
2> GO

觀察是否為 UTF8 資料


5. 在 php insert db 中,要使用  mssql 的 N' ' 語法 (指定 unicode)