note 25321 modified in function.oci-execute by sixd

From: Date: Tue, 10 Nov 2009 23:41:08 +0000
Subject: note 25321 modified in function.oci-execute by sixd
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162726@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.oci-execute.php

« previous php.notes (#162726) next »