NYCPHP Meetup

NYPHP.org

[nycphp-talk] PEAR DB prepared statements. PHP 5 / DB2 8

Daniel Krook krook at us.ibm.com
Wed Apr 20 14:34:53 EDT 2005


Hey folks,

I'm having a little trouble with PEAR DB prepared statements using PHP 
5.0.4 and DB2 UDB 8.2.

This particular snippet which does not a use prepared statement works and 
gets me the values I need:

        $sql = 'SELECT CB.BREED_ID, B.BREED 
                FROM CAT_BREED CB, BREEDS B 
                WHERE CB.CAT_ID = ' . $catId . ' AND CB.BREED_ID = 
B.BREED_ID';
 
        $res =& $db->query($sql);
 
        while ($row =& $res->fetchRow()) {
            // Populate a Cat object and set its breeds property to the 
array.
        }

Whereas this snippet which uses a prepared statement gives me "DB Error: 
unknown error":

        $sql = 'SELECT CB.BREED_ID, B.BREED 
                FROM CAT_BREED CB, BREEDS B 
                WHERE CB.CAT_ID = ? AND CB.BREED_ID = B.BREED_ID';
 
        $res =& $db->query($sql, $catId);

        while ($row =& $res->fetchRow()) {
           // Populate a Cat object and set its breeds property to the 
array.
        }
 
 
Any tips on where I might be going wrong?

Thanks in advance.



Daniel Krook, Advisory IT Specialist 
Application Development, Production Services - Tools, ibm.com

Personal: http://info.krook.org/
BluePages: http://w3.ibm.com/bluepages?searchcnum=9A9796897





More information about the talk mailing list