<tfoot id='EdKsh'></tfoot>

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

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

      1. PDO 和 MySQL IN/NOT IN 查询的正确格式

        时间:2023-10-05
        1. <legend id='lkRiV'><style id='lkRiV'><dir id='lkRiV'><q id='lkRiV'></q></dir></style></legend>
          • <i id='lkRiV'><tr id='lkRiV'><dt id='lkRiV'><q id='lkRiV'><span id='lkRiV'><b id='lkRiV'><form id='lkRiV'><ins id='lkRiV'></ins><ul id='lkRiV'></ul><sub id='lkRiV'></sub></form><legend id='lkRiV'></legend><bdo id='lkRiV'><pre id='lkRiV'><center id='lkRiV'></center></pre></bdo></b><th id='lkRiV'></th></span></q></dt></tr></i><div id='lkRiV'><tfoot id='lkRiV'></tfoot><dl id='lkRiV'><fieldset id='lkRiV'></fieldset></dl></div>

              <bdo id='lkRiV'></bdo><ul id='lkRiV'></ul>

                <tbody id='lkRiV'></tbody>
              <tfoot id='lkRiV'></tfoot>

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

                  本文介绍了PDO 和 MySQL IN/NOT IN 查询的正确格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  出于显而易见的原因,这是要寻找的谋杀...

                  For reasons that should be obvious, this is murder to search for...

                  我如何在 PDO 中执行此操作:

                  How do I do this in PDO:

                  SELECT thing FROM things WHERE thing_uid IN ( ... )
                  

                  我的特殊用例是一个字符串,它是通过分解从具有几十个复选框的表单中获取的数组构建的.在标准 MySQL 中,这很容易...

                  My particular use case is a string built by exploding an array taken from a form with several dozen checkboxes. In standard MySQL this is very easy...

                  $thingString = implode("', '", $thingArray);
                  $q = "SELECT thing FROM things WHERE thing_uid IN ('$thingString')";
                  

                  但我希望它能够从 PDO 的反注入保护中受益……绑定参数等等.那么我该怎么做呢?

                  but I want that to benefit from PDO's anti-injection protection... bound params and all that. So how can I do it?

                  推荐答案

                  创建一个包含与您拥有的值一样多的 ? 的数组,并将其放入查询中.

                  Create an array of as many ? as you have values, and throw that into the query.

                  $placeholders = array_fill(0, count($thingArray), '?');
                  $sql = "SELECT thing FROM things WHERE thing_uid IN (" . implode(',', $placeholders) . ")";
                  

                  这篇关于PDO 和 MySQL IN/NOT IN 查询的正确格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法通过 php PDO 中的引用错误传递参数 2 下一篇:未定义变量:pdo,在 null 上调用成员函数 prepare(

                  相关文章

                  最新文章

                1. <legend id='Z4TKl'><style id='Z4TKl'><dir id='Z4TKl'><q id='Z4TKl'></q></dir></style></legend>

                2. <tfoot id='Z4TKl'></tfoot>

                      <bdo id='Z4TKl'></bdo><ul id='Z4TKl'></ul>
                  1. <small id='Z4TKl'></small><noframes id='Z4TKl'>

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