php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36342 missing values on recordset with a very simple request
Submitted: 2006-02-09 15:27 UTC Modified: 2006-03-27 23:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: teissierb at hotmail dot com Assigned: wez (profile)
Status: Closed Package: PDO related
PHP Version: 5.1.2 OS: WIN32
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: teissierb at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-02-09 15:27 UTC] teissierb at hotmail dot com
Description:
------------
On SQL Server 2005 Express (free), using Windows XP, Wamp 1.6.0 (php 5.1.1) and PDO ODBC:

With a simple table PDO doesn't return what I expect him to. Might be dued to the mix of varchar and (small, tiny)int.

Reproduce code:
---------------
create table T (
	[A]      	varchar(80) NOT NULL,
	[B]         tinyint NOT NULL,
	[C]       	varchar(100) NOT NULL,
	[D]         smallint NOT NULL,
	[E]       	varchar(1024) NOT NULL,
	[F]       	varchar(255) NOT NULL,
	[G]        	varchar(255) NOT NULL,
	[H]       	varchar(1000) NOT NULL,
	[I]         varchar(100) NOT NULL,
	[J]        	tinyint NOT NULL,
	[K]       	varchar(255) NULL 
)

insert into T values ('A', '1', 'C', '2', 'E', 'F', 'G', 'H', 'I', '3', 'K')
//////////////////////////////////////////////////////////////
try {
	$db = new PDO('odbc:Driver={SQL Server};Server=HOST\INSTANCENAME;Database=XXXX;', "user", "pass");
} catch( PDOException $e ){
    die( $e->getMessage() );
}

foreach( $db->query("SELECT * FROM T ", PDO::FETCH_NUM)	as $row ) {
     echo "<pre>"; print_r( $row );echo "</pre>";
}

Expected result:
----------------
[0] => A
[1] => 1
[2] => C
[3] => 2
[4] => E
[5] => F
[6] => G
[7] => H
[8] => I
[9] => 3
[10] => K

Actual result:
--------------
[0] => A
[1] => 1
[2] => C
[3] => 2
[4] => 
[5] => F
[6] => G
[7] => 
[8] => I
[9] => 3
[10] => K

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-10 15:18 UTC] tony2001@php.net
Assigned to the maintainer.
 [2006-02-23 01:07 UTC] travis at raybold dot com
i've got a simpler test case...
ON Windows XP, IIS6, PHP 5.1.2 (With the 5.1.0 php_pdo.dll and php_pdo_odbc.dll to avoid bug #35671), SQL Server 2000 accessed through PDO_ODBC.

creating a simple table and inserting one row as follows:

----------------------
CREATE TABLE zTest_TBL (
	Test varchar (256), 
	TestID int 
)
INSERT INTO zTest_TBL ( Test ) VALUES ('test')
----------------------

then try to query with:
----------------------
$oConnection = new PDO($sDSN);
foreach($oConnection->query('SELECT * FROM zTest_TBL ') as $aRow) {
  print_r($aRow);
}
----------------------

returns:
----------------------
Array ( [Test] => [0] => [TestID] => [1] => )
----------------------

expected:
----------------------
Array ( [Test] => test [0] => test [TestID] => [1] => )
----------------------

Note: reducing the size to 255 makes it work as expected. it also works as expected if there is just the one field, regardless of the size. adding another field, be it integer or varchar kills the long field. I tested with the 5.1.2 php_pdo.dll and php_pdo_odbc.dll with the same results.
 [2006-03-08 00:04 UTC] marshmallow007 at hotmail dot com
I'have the same bug for the 1 row with Firebird but not with MySQL!

Firebird:
Array ( [INDEX] => [DATE] => [TEXTE] => )

MySQL:
Array ( [INDEX] => 1 [DATE] => 1969-05-07 [TEXTE] => marshmallow)
 [2006-03-15 16:03 UTC] wez@php.net
This is actually a limitation of ODBC; "long" columns must be the last columns bound in a query.  It is possible for PDO to workaround this by using an alternate, slower, approach to fetching the data.  In the long run, you are better off making sure you query the big columns out last.
 [2006-03-27 23:04 UTC] wez@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in CVS; try the next snapshot.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Nov 30 23:03:37 2021 UTC