|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #56784 scoping problem in db2_bind_param
Submitted: 2006-01-19 10:32 UTC Modified: 2006-03-03 15:18 UTC
From: james dot jones at firstinvestors dot com Assigned:
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.1.1 OS: Redhat Linux ES 2.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: james dot jones at firstinvestors dot com
New email:
PHP Version: OS:


 [2006-01-19 10:32 UTC] james dot jones at firstinvestors dot com
There is a problem with scope when using db2_bind_param. See code samples. Version (1) works because everything is in the same scope. Version (2) does not work because $var is in the wrong scope. We can bring $var into scope using a 'global' declaration, and there are various other ways to force it to work generally (e.g., passing an array of variable names to the function and copying them into local scope).

But should this even be necessary? I would *expect* version (2) to work without all this rigmarole. Is it possible to save scoping info when db2_bind_param is called, so that this can be used to retrieve the value of the variable when db2_execute is called?

Reproduce code:
Version 1 (works OK):

$var = 'test';
db2_bind_param($query, 1, 'var');
db2_execute($conn, $query);

Version 2 (doesn't work):

function checked_db2_execute($query, $params = NULL) {
  $rc = @db2_execute($GLOBALS['conn'], $query);
  if(!$rc) { // standard error-handling
$var = 'test';
db2_bind_param($query, 1, 'var');
checked_db2_execute($conn, $query);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-03 15:18 UTC] kfbombar at us dot ibm dot com
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

Thanks James for the bug report and working with ibm_db2.  You are correct in your thoughts that it should be more simple.  We have made the changes necessary for your test cases to work.  Let us know if we can be of any more assistance.  Thanks again James.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 21 22:03:34 2021 UTC