note 96770 added to mysqli-stmt.bind-param
| From: | fabio at kidopi dot com dot br | Date: | Mon, 15 Mar 2010 17:14:42 +0000 |
| Subject: | note 96770 added to mysqli-stmt.bind-param | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167065@lists.php.net to get a copy of this message | ||
I used to have problems with call_user_func_array and bind_param after migrating to php 5.3.
The problem is that 5.3 requires array values as reference while 5.2 works with real values.
so i created a secondary function to help me with this...
function refValues($arr){
if (strnatcmp(phpversion(),'5.3') >= 0) //Reference is required for PHP 5.3+
{
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
return $arr;
}
and changed my previous function from:
call_user_func_array(array($this->stmt, "bind_param"),$this->valores);
to:
call_user_func_array(array($this->stmt, "bind_param"),refValues($this->valores));
in this way my db functions keep working in php 5.2/5.3 servers.
I hope this help someone.
----
Server IP: 69.147.83.197
Probable Submitter: 201.42.162.230
----
Manual Page -- http://www.php.net/manual/en/mysqli-stmt.bind-param.php
Edit -- https://master.php.net/note/edit/96770
Del: integrated -- https://master.php.net/note/delete/96770/integrated
Del: useless -- https://master.php.net/note/delete/96770/useless
Del: bad code -- https://master.php.net/note/delete/96770/bad+code
Del: spam -- https://master.php.net/note/delete/96770/spam
Del: non-english -- https://master.php.net/note/delete/96770/non-english
Del: in docs -- https://master.php.net/note/delete/96770/in+docs
Del: other reasons-- https://master.php.net/note/delete/96770
Reject -- https://master.php.net/note/reject/96770
Search -- https://master.php.net/manage/user-notes.php