Re: FreeTDS and PHP: empty strings and NVARCHAR

Mattia <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CA+heTbqcRSYpKqgpP4U5DeZO1y=kbxT0q9Vs_ygr_Bp5Ehd+GQ@mail.gmail.com>
2011/7/7 Frediano Ziglio <[email protected]>:
> our dblib should convert to
> SYBVARCHAR and PHP should be happy with given varchar... If this is
> not true we should fix FreeTDS dblib instead.

If a nvarchar string is passed as a simple varchar and this string
contains strange
characters (like Č), sql server will insert an empty string in that field.

Microsoft says[1] that nvarchar is type 0xE7 which is defined as
XSYBNVARCHAR in freetds.

So,
with SYBVARCHAR an empty string is inserted (in presence of strange characters);
with SYBNVARCHAR, sql server throws an error (unknown data type)
with XSYBNVARCHAR, everything works perfectly.

>> 3. The freetds092_with_nvarchar.patch (against php 5.3.6 stable) fixes a
>> redefinition of type LBYTE to work with actual Freetds cvs and adds support
>> for type SQLNVARCHAR (to use with mssql_bind function).
>>
>
> This is a PHP patch, I think you should split patch and send them.

I wanted to put all patches here to provide a fully working solution.


[1] http://download.microsoft.com/download/a/e/6/ae6e4142-aa58-45c6-8dcf-a657e5900cd3/%5BMS-TDS%5D.pdf

-- 
Mattia
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.