note 25321 modified in function.ociexecute by sixd
| From: | sixd@php.net | Date: | Mon, 05 Oct 2009 02:02:51 +0000 |
| Subject: | note 25321 modified in function.ociexecute by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161321@lists.php.net to get a copy of this message | ||
Addition to the posting of cthrall@rocketmail.com (from 06-Sep-2000):
It's true, you can't call OCIBindByName in a loop and bind to an associative array like
this:
foreach ($array as $key => $val)
{
OCIBindByName($state, $key, $val, -1);
}
BUT: You can do it this way:
foreach ($array as $key => $val)
{
OCIBindByName($state, $key, $array[$key], -1);
}
Background: the command OCIBindByName BINDS a PHP variable to a parameter, not just its current
value. Thus, it is up to you to make sure that the variable has the correct value at the very time
when OCIExecute is called, not just when OCIBindByName was called! The PHP variable gets evaluated
at the point of OCIExecute and not earlier.
This is somewhat more legible than cthrall's solution (but it surely works, too).
--was--
Addition to the posting of cthrall@rocketmail.com (from 06-Sep-2000):
It's true, you can't call OCIBindByName in a loop and bind to an associative array like
this:
foreach ($array as $key => $val)
{
OCIBindByName($state, $key, $val, -1);
}
BUT: You can do it this way:
foreach ($array as $key => $val)
{
OCIBindByName($state, $key, $array[$key], -1);
}
Background: the command OCIBindByName BINDS a PHP variable to a parameter, not just its current
value. Thus, it is up to you to make sure that the variable has the correct value at the very time
when OCIExecute is called, not just when OCIBindByName was called! The PHP variable gets evaluated
at the point of OCIExecute and not earlier.
This is somewhat more legible than cthrall's solution (but it surely works, too).
http://php.net/manual/en/function.ociexecute.php