$type = array('i','i');
$param = array("1","1");
$stmt = $mysqli->prepare("SELECT par1, par2 FROM table WHERE par3 = ? AND par4 = ?");
$refs = array();
foreach($param as $key => $value) {
$refs[$key] = &$param[$key];
}
$result_params = array_merge($type,$refs);
call_user_func_array(array($stmt, 'bind_param'), $result_params);
$stmt->execute();
var_dump($result_params)
:
array(4) {
[0]=>
string(1) "i"
[1]=>
string(1) "i"
[2]=>
&string(1) "1"
[3]=>
&string(1) "1"
}
When we use code we are get error:
Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in ...
Why we are get this error an how to fix the problem ?