PEAR DB prepare function with postgresql

From: Date: Wed, 09 Jul 2003 18:20:13 +0000
Subject: PEAR DB prepare function with postgresql
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-6545@lists.php.net to get a copy of this message
I'm encountering the following behavior with PEAR DB prepare and execute functions: This code works. The prepared statement executes as expected. // create sql statement string $ins_sql = 'INSERT INTO foo VALUES (?,?,?,?,?,?)'; // prepare sql statements $ins_stmt = $dbh->prepare($ins_sql); $result = $dbh->execute($ins_stmt,$foo_values); This code does not work. $ins_stmt = User::prep_ins_stmt($dbh); $result = $dbh->execute($ins_stmt,$foo_values); Basically, if I put the prepare() function call in a separate function that returns the statement handle the execute will not work. The returned $result is like this: object(db_error)(7) { ["error_message_prefix"]=> string(0) "" ["mode"]=> int(1) ["level"]=> int(1024) ["code"]=> int(-8) ["message"]=> string(17) "DB Error: invalid" ["userinfo"]=> string(0) "" ["callback"]=> NULL } I've used gettype() and var_dump to ensure that the returned statement handle has the same value as the handle generated by the successfuly prepare() call in the sub function - int(0). However, the fact remains that I unless I call the prepare() function in the same function as the execute(), the execute() will fail. Has anyone seen this behavior before? Is this expected? Known? Thanks for you help. D

« previous php.pear.general (#6545) next »