note 96770 modified in mysqli-stmt.bind-param by danbrown
| From: | danbrown@php.net | Date: | Mon, 15 Mar 2010 17:46:47 +0000 |
| Subject: | note 96770 modified in mysqli-stmt.bind-param by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167066@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...
<?php
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:
<?php
call_user_func_array(array($this->stmt, "bind_param"),$this->valores);
?>
to:
<?php
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.
--was--
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.
http://php.net/manual/en/mysqli-stmt.bind-param.php