mysqli - About PHP prepared statement -
I am working for an easy function to execute a prepared statement. Now I get a problem:
expand mysqli_extend class \ mysqli {function pquery () {$ input = func_get_args (); If ($ stmt = parent :: ready ($ input [0])) {$ input = array_slice ($ input, 1); $ Index = count ($ input); If ($ index) {// non-0 == true, 0 == wrong $ typed star = ''; 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, $ typewriter); // Console to check out the output content ($ ele = current ($ input)) {echo key ($ input) ":". $ Ele "\ T"; Next ($ input); } Call_user_func_array (array ($ stmt, 'bind_Param'), $ input); } $ Stmt- & gt; carry about (); } Back true; }} And the command to execute it is:
$ test = $ mysqli_extend-> Pquery ('UPDATE user_list SET upriv =? WHERE uname? =', 'Moderator', 'administrator'); While the echo statement gives me the right content of the array "0: ss 1: Moderator 2: Administrator" I expect error: "Warning: parameter 2 to mysqli_stmt :: bind_param ( ) Expected to be a reference "
Because for the latest PHP version, the problem is a fatal error:" Call-time pass-by-reference has been removed "
Do I Can I have an alternative solution for this problem? Thanks for Ryan vincent, after the link I work around to get temporary, though I will be in the future This was not expected to work: foreach (input as $ c = & gt; & amp; $ arg) {$ Args [$ k] = & amp; $ Arg; }
Comments
Post a Comment