note 72639 added to function.oci-bind-by-name

From: Date: Sat, 27 Jan 2007 12:27:12 +0000
Subject: note 72639 added to function.oci-bind-by-name
Groups: php.notes 
Request: Send a blank email to php-notes+get-122259@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 91.3.166.141 ---- Manual Page -- http://www.php.net/manual/en/function.oci-bind-by-name.php Edit -- https://master.php.net/note/edit/72639 Del: integrated -- https://master.php.net/note/delete/72639/integrated Del: useless -- https://master.php.net/note/delete/72639/useless Del: bad code -- https://master.php.net/note/delete/72639/bad+code Del: spam -- https://master.php.net/note/delete/72639/spam Del: non-english -- https://master.php.net/note/delete/72639/non-english Del: in docs -- https://master.php.net/note/delete/72639/in+docs Del: other reasons-- https://master.php.net/note/delete/72639 Reject -- https://master.php.net/note/reject/72639 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122259) next »