I have a similar problem like the author of this question:
MySQLI binding params using call_user_func_array
But before my question get duplicated tag, the solution didn't worked out for me.
That actually is my code:
// in classfoodao.php
function updateClassfoo(Classfoo $classfoo){
$values = array();
global $conn,$f;
$pattern = "";
/* updateFields get all defined attributes in classfoo object and then write in the $sql string
* A prepared statement only for the not null attribs,
* and also put the attribs in the same order in the $values array.
* The same are done for the $pattern string.
* $values and $pattern are passed by reference.
*/
$sql = $classfoo->updateFields($values, $pattern);
if (!empty($values) && !empty($pattern)) {
$stmt = $conn->prepare($sql);
$temp = array($pattern);
for ($i = 0, $count = count($values); $i < $count; $i++) {
$addr = &$values[$i];
array_push($temp, $addr);
}
call_user_func_array(array($stmt, "bind_param"), $temp);
} else {
return true;
}
}
And I still getting this Warning:
PHP Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given
Following with the error:
Execute failed on update: (2031) No data supplied for parameters in prepared statement
I'm not using any framework for PHP, how can I create an Array of references to solve this problem?