PHP   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php – 无法在mysqli_stmt对象上使用call_user_func_array大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在为 MySQLi编写一个包装类.在那里,我正在编写一个函数来接受一个查询和可变数量的参数,我可以在其中调用@L_673_8@i_stmt :: bind_param.这是代码
<?PHP
    class DbHelper {
        ....
        public function Execute($query,$params){
            $this->open(); # Opens a connection to the database using @L_673_8@i API
            $stmt = $this->@L_673_8@i->prepare($query);
            try{
                $result = call_user_func_array(array($stmt,'bind_param'),$params);
            }
            catch(Exception $eX){
                # Handle Exception
            }
        }
        ....
    }
?>

这是我调用函数的方式:

<?PHP
    $db = new DbHelper();
    $params = array('i',$statEID);
    $result = $db->Execute('SELECT * FROM mst_cities WHERE State_ID = ?',$params);    
?>

当我运行代码时,我得到一个警告:
警告:参数2到@L_673_8@i_stmt :: bind_@R_669_1403@应该是一个引用,值在……中给出

该怎么办

docs

评论中有一些解决方法,例如see this

call_user_func_array(array($stmt,refValues($params));

function refValues($arr)
{
    if (strnatcmp(PHPversion(),'5.3') >= 0) //Reference is required for PHP 5.3+
    {
        $refs = array();
        foreach($arr as $key => $value)
            $refs[$key] = &$arr[$key];
        return $refs;
    }
    return $arr;
}

大佬总结

以上是大佬教程为你收集整理的php – 无法在mysqli_stmt对象上使用call_user_func_array全部内容,希望文章能够帮你解决php – 无法在mysqli_stmt对象上使用call_user_func_array所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。