ID:               38458
 Comment by:       johnc at inkjetinc dot com
 Reported By:      costas at meezon dot com
 Status:           Assigned
 Bug Type:         PDO related
 Operating System: Windows XP Prof
 PHP Version:      5.1.4
 Assigned To:      wez
 New Comment:

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).


Previous Comments:
------------------------------------------------------------------------

[2006-08-16 14:48:48] 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-08-15 06:41:12] [EMAIL PROTECTED]

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-15 00:11:36] 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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38458&edit=1

Reply via email to