Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS and PHP: empty strings and NVARCHAR

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Mattia <mattia AT p2pforum.it>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS and PHP: empty strings and NVARCHAR
  • Date: Sat, 9 Jul 2011 19:56:55 +0200

2011/7/7 Frediano Ziglio <freddy77 AT gmail.com>:
> 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




Archive powered by MHonArc 2.6.24.

Top of Page