2
我正在解决一个简单的函数来执行预准备语句。现在,我得到了一个问题:关于PHP准备语句
class mysqli_extend extends \mysqli{
function pquery(){
$input = func_get_args();
if ($stmt = parent::prepare($input[0])){
$input = array_slice($input,1);
$index = count($input);
if ($index){ //non-0 == true, 0 == false
$typestr = '';
while ($ele = current($input)){
$type = gettype($ele);
switch($type) {
case "integer": $typestr .= 'i'; break;
case "double": $typestr .= 'd'; break;
case "string": $typestr .= 's'; break;
default: $typestr .= 'b'; break;
}
next($input);
}
array_unshift($input,$typestr);
//output to console checking array content
while ($ele = current($input)){
echo key($input) . ":" . $ele . "\t";
next($input);
}
call_user_func_array(array($stmt,'bind_Param'),$input);
}
$stmt->execute();
}
return true;
}
}
,这是要执行的命令:
$test = $mysqli_extend->pquery('UPDATE user_list SET upriv = ? WHERE uname =?','moderator','admin');
而echo语句给我数组的一个正确的内容为 “0:SS 1:主持人2:管理员” 我得到错误果然有: “警告:参数2 mysqli_stmt :: bind_param()预计将参考”
因为对于最新的PHP版本,它有问题 “致命错误:调用时pass-通过引用已经删除“
请问是否有任何解决此问题的解决方法?
你必须看看这个【答案】(HTTP:// stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available)? – ForguesR
我实际上预计应该有一个工作,以打败“预计会成为参考”的错误,避开&$符号...而且我不确定自己在哪里弄错了:'( – orb
)您可以发布用于准备声明? – ForguesR