About PHP prepared statement

I'm working around for an easy function to execute prepared statement. Now I get a problem:

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;
}
}

and this is the command to execute:

$test = $mysqli_extend->pquery('UPDATE user_list SET upriv = ? WHERE uname =?','moderator','admin');

while echo statement gives me a correct content of array"0:ss 1:moderator 2:admin" I get error expectedly with: "Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference"

since for the newest php version, it has the problem "Fatal error: Call-time pass-by-reference has been removed"

May I ask whether there is any workaround for this problem?


感谢瑞安·文森特,继链接之后,我得到了临时工作,尽管我没有想到这将在未来工作:

foreach($input as $k => &$arg){
    $Args[$k] = &$arg;
}
链接地址: http://www.djcxy.com/p/44882.html

上一篇: 准备好的语句和SQL注入

下一篇: 关于PHP准备的声明