参考阵列我有一个类似的问题,这样的问题作者:PHP 7.0的mysqli - 为call_user_func_array
MySQLI binding params using call_user_func_array
但我的问题得到重复的标签之前,该解决方案并没有为我工作了。
这实际上是我的代码:
// 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;
}
}
我仍然得到这个警告:
PHP Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given
与错误以下:
Execute failed on update: (2031) No data supplied for parameters in prepared statement
我没有使用任何框架对于PHP,我如何创建一个引用数组来解决这个问题?
我不认为我们在这里得到完整的图片...你在哪里调用' - > bind_param()'方法 –
除了@SamuelCook的建议,它将是非常有用的,看看什么'$值'是'ie和数组或字符串'以及'$ temp'是如何使用的,推测是一个bind_param调用。 – TheDude
请提供您调用bind_param()的代码。否则,我们无法帮助你。 – iquellis