• <tfoot id='iWVca'></tfoot>
      <bdo id='iWVca'></bdo><ul id='iWVca'></ul>

    1. <legend id='iWVca'><style id='iWVca'><dir id='iWVca'><q id='iWVca'></q></dir></style></legend>
      1. <i id='iWVca'><tr id='iWVca'><dt id='iWVca'><q id='iWVca'><span id='iWVca'><b id='iWVca'><form id='iWVca'><ins id='iWVca'></ins><ul id='iWVca'></ul><sub id='iWVca'></sub></form><legend id='iWVca'></legend><bdo id='iWVca'><pre id='iWVca'><center id='iWVca'></center></pre></bdo></b><th id='iWVca'></th></span></q></dt></tr></i><div id='iWVca'><tfoot id='iWVca'></tfoot><dl id='iWVca'><fieldset id='iWVca'></fieldset></dl></div>

      2. <small id='iWVca'></small><noframes id='iWVca'>

        php5.3 - mysqli_stmt:bind_params 带有 call_user_func_array 警

        时间:2023-07-30
      3. <i id='DqmCV'><tr id='DqmCV'><dt id='DqmCV'><q id='DqmCV'><span id='DqmCV'><b id='DqmCV'><form id='DqmCV'><ins id='DqmCV'></ins><ul id='DqmCV'></ul><sub id='DqmCV'></sub></form><legend id='DqmCV'></legend><bdo id='DqmCV'><pre id='DqmCV'><center id='DqmCV'></center></pre></bdo></b><th id='DqmCV'></th></span></q></dt></tr></i><div id='DqmCV'><tfoot id='DqmCV'></tfoot><dl id='DqmCV'><fieldset id='DqmCV'></fieldset></dl></div>
        • <small id='DqmCV'></small><noframes id='DqmCV'>

            <tbody id='DqmCV'></tbody>

              <tfoot id='DqmCV'></tfoot>
                <bdo id='DqmCV'></bdo><ul id='DqmCV'></ul>

                • <legend id='DqmCV'><style id='DqmCV'><dir id='DqmCV'><q id='DqmCV'></q></dir></style></legend>
                  本文介绍了php5.3 - mysqli_stmt:bind_params 带有 call_user_func_array 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  可能的重复:
                  是否可以传递参数通过引用使用 call_user_func_array()?

                  我有以下代码行在 PHP 5.1 中有效,但在 PHP 5.3 中无效.

                  I have the following line of code which worked in PHP 5.1, but isn't working in PHP 5.3.

                  $input = array('ss','john','programmer');
                  call_user_func_array(array($mysqli_stmt, 'bind_param'), $input);
                  

                  在 PHP 5.3 中,我收到以下警告消息:

                  In PHP 5.3, I get the following warning message:

                  警告:mysqli_stmt::bind_param() 的参数 2 应为参考,值在/var/www/startmission/em/class/cls.data_access_object.php 第 785 行

                  Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in /var/www/startmission/em/class/cls.data_access_object.php on line 785

                  我将代码更改为以下内容并且它起作用了:

                  I changed the code to the following and it worked:

                  $a = 'johnl';
                  $b = 'programmer';
                  $mysqli_stmt->bind_param('ss',$a,$b);
                  

                  我在 php 文档中找到了这个:

                  I found this in the php documentation:

                  在使用 mysqli_stmt_bind_param() 时必须小心与 call_user_func_array() 结合使用.注意mysqli_stmt_bind_param() 需要通过引用传递参数,而 call_user_func_array() 可以接受一个列表作为参数可以表示引用或值的变量.

                  Care must be taken when using mysqli_stmt_bind_param() in conjunction with call_user_func_array(). Note that mysqli_stmt_bind_param() requires parameters to be passed by reference, whereas call_user_func_array() can accept as a parameter a list of variables that can represent references or values.

                  所以我的问题是,如何复制 call_user_func_array + bind_params 的功能,以便我可以在运行时动态绑定变量?

                  So my question is, how do I replicate the functionality of the call_user_func_array + bind_params such that i can dynamically bind variables at run time?

                  推荐答案

                  我在 fabio at Kidopi dot com dot br3 年前mysqli_stmt::bind_param() 的 PHP 手册页(略有修改):

                  I found the answer to my problem in a user note by fabio at kidopi dot com dot br3 years ago on the PHP manual page of mysqli_stmt::bind_param() (slightly modified):

                  在迁移到 php 5.3 后,我曾经在使用 call_user_func_arraybind_param 时遇到问题.

                  I used to have problems with call_user_func_array and bind_param after migrating to php 5.3.

                  原因是 5.3 需要数组值作为引用,而 5.2 使用真实值(但也使用引用).所以我创建了一个辅助函数来帮助我解决这个问题:

                  The cause is that 5.3 requires array values as reference while 5.2 worked with real values (but also with references). So I created a secondary helper function to help me with this:

                  function refValues($arr)
                  { 
                          $refs = array();
                  
                          foreach ($arr as $key => $value)
                          {
                              $refs[$key] = &$arr[$key]; 
                          }
                  
                          return $refs; 
                  }
                  

                  并将我以前的功能从:

                  call_user_func_array(array($this->stmt, "bind_param"), $this->values); 
                  

                  到:

                  call_user_func_array(array($this->stmt, "bind_param"), refValues($this->values)); 
                  

                  这样我的 db 函数就可以在 PHP 5.2/5.3 服务器上继续工作.

                  This way my db functions keep working in PHP 5.2/5.3 servers.

                  这篇关于php5.3 - mysqli_stmt:bind_params 带有 call_user_func_array 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Mysqli多行插入,简单的多行插入查询 下一篇:mysqli_insert_id 是否有可能在高流量应用程序中返回

                  相关文章

                  最新文章

                  1. <legend id='AgbkR'><style id='AgbkR'><dir id='AgbkR'><q id='AgbkR'></q></dir></style></legend>
                    • <bdo id='AgbkR'></bdo><ul id='AgbkR'></ul>
                    <tfoot id='AgbkR'></tfoot>

                    <small id='AgbkR'></small><noframes id='AgbkR'>

                    <i id='AgbkR'><tr id='AgbkR'><dt id='AgbkR'><q id='AgbkR'><span id='AgbkR'><b id='AgbkR'><form id='AgbkR'><ins id='AgbkR'></ins><ul id='AgbkR'></ul><sub id='AgbkR'></sub></form><legend id='AgbkR'></legend><bdo id='AgbkR'><pre id='AgbkR'><center id='AgbkR'></center></pre></bdo></b><th id='AgbkR'></th></span></q></dt></tr></i><div id='AgbkR'><tfoot id='AgbkR'></tfoot><dl id='AgbkR'><fieldset id='AgbkR'></fieldset></dl></div>