php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10824 does not return more than 256 chars from a varchar
Submitted: 2001-05-11 23:40 UTC Modified: 2001-06-30 14:36 UTC
From: sysadminnospam at cheezy dot net Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.0.4pl1 OS: MS Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sysadminnospam at cheezy dot net
New email:
PHP Version: OS:

 

 [2001-05-11 23:40 UTC] sysadminnospam at cheezy dot net
Problem:
Queries and stored procedures returning varchar data do not return more than 256 chars. The rest is truncated.

Affected functions: 
  MSSQL_FETCH_OBJECT
  MSSQL_FETCH_ARRAY
  MSSQL_FETCH_ROW (didn't get opportunity to test, but seems likely)

I know there was an earlier report similar to this in regards to NCHAR, however, varchar has nothing to do with unicode. Are we looking at the same problem here anyways? Any idea on how long 'til a solution, or some sort of work-around? Using datatype TEXT is NOT an option -- it puts too much overhead on transactions.

Since this was classified as a Microsoft problem, I guess upgrading to 4.0.5 would not help, huh?

Thanks.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-30 14:36 UTC] fmk@php.net
This is not a bug in the php extension. The library used to connect to SQL Server soes not allow warchar columns to be more that 255 char.
 [2003-02-24 06:41 UTC] magne at myrtveit dot com
Here is a workaround that I have used with success. When returning a VARCHAR field F that can exceed 256 characters, I return several computed fields F1, F2, etc using the following SQL query syntax:

SELECT ("<" + SUBSTRING(F,   1, 253) + ">") AS F1
,      ("<" + SUBSTRING(F, 254, 253) + ">") AS F2
,      ("<" + SUBSTRING(F, 507, 253) + ">") AS F3
FROM ...

In my PHP code i put F1, F2, F3 together after removing the enclosing <> (which I put on in order to maintain white space at either end of each Fi):

$F = substr($F1, 1, -1)
   . substr($F2, 1, -1)
   . substr($F3, 1, -1);

Good luck!

Magne
 [2004-01-28 16:54 UTC] php at electricsurfer dot com
There's an easier workaround:
SELECT CAST(F AS TEXT) AS F FROM ...
No other changes !
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 04:01:27 2024 UTC