我想准备一个未知数量的参数的SQL语句!这些参数在数组中已经过去了。该函数的语法正常会是:传递数组作为参数在PHP
$stmt->bind_param("string of types",param1,param2,...,paramN)
问题是我不知道如何在功能$ stmt-> bind_param参数添加了一个数组
我有这样的代码,但它不工作:
$stmt= $conn->prepare($request['query']);
if(isset($request['params'])){
call_user_func_array('$stmt->bind_param',$request['params']);
}
$stmt->execute();
$result = $stmt->get_result();
$ request ['params']包含需要在函数中添加的正确参数。
但call_user_func_array给了我这个错误:
call_user_func_array() expects parameter 1 to be a valid callback, function '$stmt->bind_param' not found or invalid function.
我想call_user_func_array可能不使用正确的功能! 我搜索了几个小时,但找不到解决这个小问题的方法。
请阅读[文档](http://php.net/call_user_func_array)关于您正在使用的功能。请注意,这些示例显示了如何通过此函数正确调用对象方法。 –