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: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS and PHP: empty strings and NVARCHAR
  • Date: Mon, 11 Jul 2011 09:53:58 +0200

2011/7/9 Mattia <mattia AT p2pforum.it>:
> 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.
>

Yes, but not in dblib documentation. The document you refer is
protocol documentation.

> 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.
>

Could you provide a simple PHP code which demonstrate the problem?
Have you the problem inserting data or fetching them? Did you setup
correctly client charset?

>>> 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

Frediano




Archive powered by MHonArc 2.6.24.

Top of Page