In according with this useful answer mysqli bind_param() expected to be a reference, value given i can create dynamic queries.
Now, i'm learning OOP but i cannot understand the correct mode to move that function, render protect and accessible from other methods.
Function is:
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 now i'm calling it in a Class:
class MyBaseCrud {
// other stuff
$rc = call_user_func_array(array($stmt, 'bind_param'), refValues($params));
// other stuff
}
I would learn more about OOP so i would transform in method like:
protected function refValues($array) {
// body method
}
and after call correctly from
$rc = call_user_func_array(array($stmt, 'bind_param'), refValues($params));
of course i did try to move that function in body class
protected 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 leave untouched
$rc = call_user_func_array(array($stmt, 'bind_param'), refValues($params));
without success.
Please, be gently... Just learning now OOP :)