NYCPHP Meetup

NYPHP.org

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

Daniel Krook krook at us.ibm.com
Wed Apr 20 15:24:11 EDT 2005


> Well, perhaps I spoke too soon.  It appears that either way (array or 
> scalar) works fine for me in PHP 5.0.4 and PostgreSQL 7.4.7.  I dont
> have an install of DB2 to see if it is a DB specific error.  Have you
> tried a print_r on your $res to see if there are any better clues in
> there?


Flavio,

Indeed there were, thanks for the tip :)

The prepared statement was taking the $catId integer and surrounding it 
with quotes, to which DB2 complained:
SQL0401N  The data types of the operands for the operation "=" are not 
compatible.  SQLSTATE=42818

WHERE CB.CAT_ID = '60'

I've changed the line to the following and it works.
$res =& $db->query($sql, (int)$catId);

Thanks again.




More information about the talk mailing list