|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-11-05 02:16 UTC] kobaz at kobaz dot net
Description:
------------
Resource handle from ibase_execute becomes invalid after return
Reproduce code:
---------------
$conn = ibase_connect('localhost:db', 'SYSDBA', 'pass');
function DB_PQuery ($sql, $data) {
global $conn;
$prepare = ibase_prepare($conn, $sql);
$result = ibase_execute($prepare, $data);
// $A = ibase_fetch_assoc($result); // uncommenting this will show resource is valid here
// print_r($A);
// after this function returns, the return value is no longer a valid resource
return $result;
}
$result = DB_PQuery("SELECT * FROM testing WHERE a = ?", '1');
$A = ibase_fetch_assoc($result); // fails with: invalid statement handle
print_r($A);
Expected result:
----------------
The ibase_fetch_assoc should be successful after DB_PQuery returns.
Actual result:
--------------
Before DB_PQuery returns, $result is a valid resource handle that can be used with ibase_fetch_assoc successfully.
After DB_PQuery returns, the return value is not a valid resource handle despite that nothing in the script has modified it.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 01:00:02 2025 UTC |
I have a workaround for this bug: $PQUERY = array(); $curpquery = 0; function DB_PQuery ($sql, $data) { global $PQUERY, $conn; $PQUERY[$curpquery] = ibase_prepare($conn, $sql); $result = ibase_execute($PQUERY[$curpquery], $data); $curpquery++; return $result; } I agree with the previous poster that the result from prepare being destroyed after it goes out of scope is very inconsistant with the rest of the database interfaces for php and makes coding for interbase awkward.