<legend id='pQVaJ'><style id='pQVaJ'><dir id='pQVaJ'><q id='pQVaJ'></q></dir></style></legend>

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

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

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

      如何在 PDO 准备语句中使用 LIKE 子句?

      时间:2023-09-20

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

          • <bdo id='3fjof'></bdo><ul id='3fjof'></ul>

          • <small id='3fjof'></small><noframes id='3fjof'>

                <tbody id='3fjof'></tbody>
              1. 本文介绍了如何在 PDO 准备语句中使用 LIKE 子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有一个这样的 sql 查询:

                I have a sql query like this:

                SELECT * FROM tbl_name WHERE title Like "%:needle%"
                

                当我使用此语句手动查询 MySQL 数据库时,它可以工作.但是,当我将它与 PDO 一起使用并使用与我手动查询相同的 :needle 值时,它只返回一个空结果集.

                When I query the MySQL db manually with this statement it works. But when I use it with PDO and with the same values for :needle as I queried manually It just returns an empty result set.

                utf8 编码会影响它的行为吗?

                Does utf8 encoding affects the behavior of it?

                推荐答案

                使用 PDO,可以这样做:

                With PDO, this can be done like:

                $stmt = $db->prepare("SELECT * FROM tbl_name WHERE title LIKE :needle");
                $needle = '%somestring%';
                $stmt->bindValue(':needle', $needle, PDO::PARAM_STR);
                $stmt->execute();
                $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
                

                这篇关于如何在 PDO 准备语句中使用 LIKE 子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:PDO->query() 和 PDO->exec() 之间的区别 下一篇:致命错误 在 null 上调用成员函数 prepare()

                相关文章

                最新文章

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

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