note 90669 added to book.mssql
| From: | thanhha dot phan at yahoo dot com | Date: | Mon, 04 May 2009 02:03:01 +0000 |
| Subject: | note 90669 added to book.mssql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154170@lists.php.net to get a copy of this message | ||
I got a serious problem with Unicode data when working with PHP and MSSQL. I have to say the PHP and
MSSQL doesn't seem to be a good combination.
MSSQL is really complicated to work with since the whole server uses a single character
encoding[ucs-2]. In order to store unicode information, the column data types must be specified as
one of the national character types, NVARCHAR, NCHAR or NTEXT.
In order to retrieve data saved in unicode format, M$ suggest users to cast columns to binary
data.Unfortunately php_mssql extension doesn't support binary data to be returned in string
columns.
My advice is to use FreeTDS driver [it's just an php extension]. This driver seems to handle
unicode data better. I can put and receive unicode with casting or change encoding.
A good tutorial "Using freeTDS" can be found here
http://docs.moodle.org/en/Installing_MSSQL_for_PHP
However, freeTDS is not a perfect solution for unicode data. I'm not able to execute stored
procedures with mssql_bind, mssql_bind without having my text changed.
----
Server IP: 118.69.205.71
Probable Submitter: 115.74.112.44
----
Manual Page -- http://www.php.net/manual/en/book.mssql.php
Edit -- https://master.php.net/note/edit/90669
Del: integrated -- https://master.php.net/note/delete/90669/integrated
Del: useless -- https://master.php.net/note/delete/90669/useless
Del: bad code -- https://master.php.net/note/delete/90669/bad+code
Del: spam -- https://master.php.net/note/delete/90669/spam
Del: non-english -- https://master.php.net/note/delete/90669/non-english
Del: in docs -- https://master.php.net/note/delete/90669/in+docs
Del: other reasons-- https://master.php.net/note/delete/90669
Reject -- https://master.php.net/note/reject/90669
Search -- https://master.php.net/manage/user-notes.php