Skip to Content.
Sympa Menu

freetds - PHP with sybase-ct and TEXT

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brage Førland <brage AT zoo.uib.no>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: PHP with sybase-ct and TEXT
  • Date: Wed, 31 May 2000 12:07:16 +0200


When compiling PHP (4.0.0) with sybase-ct, TEXT fields is truncated to 255
chars when fetching rows.

The problem seems to be that php relies on ct_bind() to convert all fields
to type CS_CHAR_TYPE when fetching them. FreeTDS (in tds_convert_text) then
truncates the field to 255 chars (instead of the maxlenght given as argument
to ct_bind()).

The converted TEXT-field should probably also include the trailing \0 in the
length.

The patch below will fix PHP, but I'm not sure what effect it will have on
other applications.

-Brage



*** src/tds/convert.c.old Wed May 31 11:18:33 2000
--- src/tds/convert.c Wed May 31 11:07:40 2000
***************
*** 98,107 ****
case SYBCHAR:
cplen = srclen;
if (destlen<cplen) cplen = destlen;
! if (cplen>255) cplen=255;
memcpy(dest, src, cplen);
! dest[cplen]='\0';
! return cplen;
}
}
TDS_INT tds_convert_binary(int srctype,unsigned char *src,TDS_INT srclen,
--- 98,107 ----
case SYBCHAR:
cplen = srclen;
if (destlen<cplen) cplen = destlen;
! /* if (cplen>255) cplen=255; */
memcpy(dest, src, cplen);
! dest[cplen+1]='\0';
! return cplen+1;
}
}
TDS_INT tds_convert_binary(int srctype,unsigned char *src,TDS_INT srclen,




  • PHP with sybase-ct and TEXT, Brage Førland, 05/31/2000

Archive powered by MHonArc 2.6.24.

Top of Page