Skip to Content.
Sympa Menu

freetds - Re: PHP's mssql_fetch_row inserting '\0' on strings ?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Andre Costa <brblueser AT uol.com.br>
  • To: "TDS Development Group" <freetds AT franklin.metalab.unc.edu>
  • Cc: LowdenJK AT bernstein.com
  • Subject: Re: PHP's mssql_fetch_row inserting '\0' on strings ?
  • Date: Wed, 19 Jun 2002 18:15:20 -0300


Hi James,

On Wed, 19 Jun 2002 14:54:50 -0400
"Lowden, James K" <LowdenJK AT bernstein.com> wrote:

> My pleasure. Several things are happening at once, so I've been more
> active here. I'm interested in rooting out anything we can find wrong
> in the code or documentation while we're preparing a new release. And
> I'm trying to fill in for Brian, who is justly distracted by Life for
> the time being.

I gotta say you're doing a hell of a job ;)

> I know the answer. See the thread on this list around June 9, Re:
> Strange data results....

Sorry for overlooking this. I did do some research yesterday, but it was
not too deep, and I was damn tired... ={

> Your query returns fields of datatype either Text or nvarchar. Change
> them to varchar and go home.

Cool =) However, I wish it were that simple.

<OT>
The XML generator we're implementing should not need to be aware of the
data types it is receiving. Unless I am missing something, I would only
have two options: [1] query the DB for the type of each field and convert
TEXT to VARCHAR or [2] convert everything to VARCHAR.

#1 would hurt performance badly (for each query, I would probably have to
extract data types, look for TEXT or NVARCHAR, change them to VARCHAR and
then make another query). #2 seems to be the best way for text output
(which is the case for XML). However, the modules responsible for DB
communication will most likely be used for other kinds of data transfer,
not only XML -- some might involve binary data transfer. In that case, #2
wouldn't be acceptable.
</OT>

Could you please point me to any docs describing the difference between
TDS 4.2 and TDS 7.0? If I don't have a real need for 7.0, I will stick to
4.2 .

> TDS 4.2 uses ASCII, one byte/character. TDS 7.0 uses UCS-2, two
> bytes/character. Someone's getting confused about the difference
> between the buffer length and the number of characters.

Yeah, I guess this would explain the behavior we're having.

> I don't know whether this is a PHP bug or a FreeTDS bug. Which API are
> you using? If ct-lib, then it's definitely a PHP error, because sqsh
> handles them correctly.

... I must confess I don't know how to answer your question ={ How do I
check that?

Thks again.

Best,

Andre




Archive powered by MHonArc 2.6.24.

Top of Page