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:45:20 EDT 2005


Flavio,

Thanks for the quick reply.   That is the method for preparing statements 
for UPDATEs and INSERTs.  I'm attempting to use the prepared statement 
with a SELECT according to this example (32-2):
http://pear.php.net/manual/en/package.database.db.intro-query.php 


talk-bounces at lists.nyphp.org wrote on 04/20/2005 02:41:23 PM:

> On Wed, 2005-04-20 at 14:34 -0400, Daniel Krook wrote:
> > 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.
> >         } 
> 
> 
> $sth =& $db->prepare( $sql );
> $res =& $db->execute($sth, $catId);
> 





More information about the talk mailing list