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

  • <small id='jkIll'></small><noframes id='jkIll'>

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

        在 pdo 中绑定多个值

        时间:2023-09-21
        • <i id='zciqa'><tr id='zciqa'><dt id='zciqa'><q id='zciqa'><span id='zciqa'><b id='zciqa'><form id='zciqa'><ins id='zciqa'></ins><ul id='zciqa'></ul><sub id='zciqa'></sub></form><legend id='zciqa'></legend><bdo id='zciqa'><pre id='zciqa'><center id='zciqa'></center></pre></bdo></b><th id='zciqa'></th></span></q></dt></tr></i><div id='zciqa'><tfoot id='zciqa'></tfoot><dl id='zciqa'><fieldset id='zciqa'></fieldset></dl></div>
          • <bdo id='zciqa'></bdo><ul id='zciqa'></ul>

          • <small id='zciqa'></small><noframes id='zciqa'>

            <tfoot id='zciqa'></tfoot>
            <legend id='zciqa'><style id='zciqa'><dir id='zciqa'><q id='zciqa'></q></dir></style></legend>

                <tbody id='zciqa'></tbody>

                  本文介绍了在 pdo 中绑定多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否有一种无需重复就可以在 PDO 中绑定多个值的简单方法?看看下面的代码:

                  Is there's an easy way of binding multiple values in PDO without repitition ? Take a look at the following code :

                  $result_set = $pdo->prepare("INSERT INTO `users` (`username`, `password`, `first_name`, `last_name`) VALUES (:username, :password, :first_name, :last_name)");
                  
                  $result_set->bindValue(':username', '~user');
                  $result_set->bindValue(':password', '~pass');
                  $result_set->bindValue(':first_name', '~John');
                  $result_set->bindValue(':last_name', '~Doe');
                  
                  $result_set->execute();
                  

                  在这里,我以 4 次重复的方式绑定值.那么是否有一种简单的方法可以在 PDO 中绑定多个值?

                  Here, I binded values in a repepeated way which is 4 times. So is there's an easy way of binding multiple values in PDO ?

                  推荐答案

                  你总是可以在 execute() 的参数中绑定值,只要你觉得值被视为 <代码>PDO::PARAM_STR(字符串).

                  You can always bind values within the arguments of execute() as long as you're fine with the values being treated as PDO::PARAM_STR (string).

                  $result_set = $pdo->prepare("INSERT INTO `users` (`username`, `password`, `first_name`, `last_name`) VALUES (:username, :password, :first_name, :last_name)");
                  $result_set->execute(array(
                      ':username' => '~user',
                      ':password' => '~pass',
                      ':first_name' => '~John',
                      ':last_name' => '~Doe'
                  ));
                  

                  您可以像使用任何数组一样使用传递的数组:

                  You can use the array passed just like any array:

                  $user = "Nile";
                  $pdo->execute(array(":user" => $user));
                  

                  这篇关于在 pdo 中绑定多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:pdo - 在非对象上调用成员函数 prepare() 下一篇:是否有关于如何使用 PDO 的好教程?

                  相关文章

                  最新文章

                  <tfoot id='PmxnH'></tfoot>

                  1. <small id='PmxnH'></small><noframes id='PmxnH'>

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

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