note 72639 deleted from function.oci-bind-by-name by sixd

From: Date: Sat, 14 Nov 2009 00:55:52 +0000
Subject: note 72639 deleted from function.oci-bind-by-name by sixd
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162892@lists.php.net to get a copy of this message
Note Submitter: tom at bitworks dot de ---- Referes to: Be careful that the variable argument is a reference. So, the following code does not work: foreach($some_array as $key => $value) { OCIBindByName($stmt, $key, $value); } I assume this is because the contents of $value changes, even though the reference remains the same, so all bound variables end up pointing to the last loop iteration's value. Instead use the following: foreach($some_array as $key => $value) { OCIBindByName($stmt, $key, $some_array[$key]); } This dues to the foreach statement. $some_array in foreach() is a copy of the origine array. $key would be the "reference" in the copy, but $some_array[$key] points to the original one.

« previous php.notes (#162892) next »