|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-15 06:41 UTC] tony2001@php.net
[2006-08-16 14:48 UTC] costas at meezon dot com
[2006-09-22 22:26 UTC] johnc at inkjetinc dot com
[2006-10-11 03:24 UTC] wez@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 04:00:01 2025 UTC |
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.