php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38458 Fails to get values of fields following a MEMO type field in MS Access
Submitted: 2006-08-15 00:11 UTC Modified: 2006-10-11 03:24 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:3 (100.0%)
From: costas at meezon dot com Assigned: wez (profile)
Status: Closed Package: PDO related
PHP Version: 5.1.4 OS: Windows XP Prof
Private report: No CVE-ID: None
 [2006-08-15 00:11 UTC] costas at meezon dot com
Description:
------------
I have an MS Access database and use PDO/ODBC. There are 2 MEMO type columns (notes and notes2) in one table 'tblNotes'. 

tblNotes structure
-------------------
LastName - text,
notes - memo,
addr - text,
notes2 - memo
zip - text 

I added 2 rows and manually populated all the columns with data. The notes and notes2 have just a couple of characters each.

Problem:
---------
When I use 'SELECT * from tblNotes' all rows are retrieved, but the values for all non-MEMO type columns (which follow MEMO columns) are null.  This means addr and zip are NULL but LastName is correct.

If I explicitly name the columns in the SELECT I get the same result (E.g. SELECT LastName, notes, addr, notes2, zip from tblNotes order by LastName). This means addr and zip are NULL but LastName is correct.

Workaround:
------------
If I move the notes and notes2 columns to the end, then all the values are retrieved (E.g. SELECT LastName, addr, zip, notes, notes2 from tblNotes order by LastName)

This is OK if you have just a few columns. Otherwise you have to type them all in. 

I am not sure if this is a PDO problem or ODBC.

Reproduce code:
---------------
<?php
$tbl='tblNotes';

$user='';
$pass='';
$conn = "DSN=mailing;Driver=Microsoft Access Driver";
try {
    $dbh = new PDO("odbc:$conn", $user, $pass);
    $cursor=$dbh->query("SELECT * from $tbl order by LastName");
    foreach ($cursor as $row) {
        $row=array_change_key_case($row, CASE_UPPER);
	echo $row['LASTNAME'] . '|';
	echo $row['NOTES'] . '|';
	echo $row['ADDR'] . '|';
	echo $row['NOTES2'] . '|';
    	echo $row['ZIP'] . '|';
	echo "\n";
    }
    echo "\n";

    $cursor1=$dbh->query("SELECT LastName, notes, addr, notes2, zip from $tbl order by LastName");
    foreach ($cursor1 as $row) {
        $row=array_change_key_case($row, CASE_UPPER);
	echo $row['LASTNAME'] . '|';
	echo $row['NOTES'] . '|';
	echo $row['ADDR'] . '|';
	echo $row['NOTES2'] . '|';
	echo $row['ZIP'] . '|';
	echo "\n";
    }
    echo "\n";
    
    $cursor2=$dbh->query("SELECT LastName, addr, zip, notes, notes2 from $tbl order by LastName");
    foreach ($cursor2 as $row) {
        $row=array_change_key_case($row, CASE_UPPER);
	echo $row['LASTNAME'] . '|';
	echo $row['NOTES'] . '|';
	echo $row['ADDR'] . '|';
	echo $row['NOTES2'] . '|';
	echo $row['ZIP'] . '|';
	echo "\n";
    }

} catch (PDOException $e) {

echo $e->getMessage();

}
$dbh = null;
?>

Expected result:
----------------
For $cursor -- wrong result
doe|mm||nn||
smith|xx||yy||

For $cursor1 -- wrong result
doe|mm||nn||
smith|xx||yy||

For $cursor2  --- Correct result
doe|mm|120 main street|nn|10006|
smith|xx|320 bway|yy|10007|

Actual result:
--------------
See expected results above.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-15 06:41 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-08-16 14:48 UTC] costas at meezon dot com
I have teste with snapshot as suggested and get the exact same results (version PHP Version 5.2.0RC2-dev)

Results:
doe|mm||nn2||
smith|xx||yy2||

doe|mm||nn2||
smith|xx||yy2||

doe|mm|120 main street|nn2|10006|
smith|xx|320 bway|yy2|10007|
 [2006-09-22 22:26 UTC] johnc at inkjetinc dot com
I am seeing the same problem accessing MEMO fields in Visual FoxPro using pdo/odbc in php 5.1.6. I was previusly using php 5.1.1 and did not encounter this issue in that version (in php 5.1.1 I addeded pdo maually from the pecl compiled sources).
 [2006-10-11 03:24 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.

Fix will show up in the next PHP 5.2 snapshot at snaps.php.net.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC