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

        <tfoot id='yQ3pQ'></tfoot>

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

        <legend id='yQ3pQ'><style id='yQ3pQ'><dir id='yQ3pQ'><q id='yQ3pQ'></q></dir></style></legend>
      2. PDO 和 MySQL '之间'

        时间:2023-09-20

          <tbody id='jNkXz'></tbody>

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

          • <legend id='jNkXz'><style id='jNkXz'><dir id='jNkXz'><q id='jNkXz'></q></dir></style></legend>
              <bdo id='jNkXz'></bdo><ul id='jNkXz'></ul>
              <tfoot id='jNkXz'></tfoot>

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

                  本文介绍了PDO 和 MySQL '之间'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试让 PDO 与 MySQL 的之间"一起工作.下面是我的代码:

                  I'm trying to get PDO to work with a MySQL 'between'. Below is my code:

                  $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);  
                  
                  $start_date = date('Y-m-d H:i:s', mktime(0, 0, 0, 11, 1, 2009));
                  $end_date = date('Y-m-d H:i:s', mktime(23, 59, 59, 11, 30, 2009));
                  
                  $STH = $DBH->prepare("SELECT * FROM `table` WHERE `start_date` BETWEEN ':start_date' AND ':end_date'");
                  $STH->bindParam(':start_date', $start_date, PDO::PARAM_STR);
                  $STH->bindParam(':end_date', $end_date, PDO::PARAM_STR);
                  $STH->execute();
                  var_dump($row);
                  

                  返回的是一个带有0"或NULL"值的数组.当我硬编码结束日期时,它就像 start_date 设置为 -1,重新调整 end_date 之前的所有行.那么,我在这里做错了什么?

                  What gets returned is an array with '0' or 'NULL' for values. When I hard code the end date, it acts as if start_date is set to -1, retuning me all rows before the end_date. So, what am I doing wrong here?

                  推荐答案

                  不要用单引号将值括起来.

                  Don't wrap the values with single quote.

                  $STH = $DBH->prepare("SELECT * FROM `table` WHERE `start_date` BETWEEN :start_date AND :end_date");
                  

                  这篇关于PDO 和 MySQL '之间'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:mysql 服务器在安装迁移过程中消失了错误 (larav 下一篇:PDO 多次获取同一查询

                  相关文章

                  最新文章

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

                  1. <tfoot id='n5eDq'></tfoot>
                      <bdo id='n5eDq'></bdo><ul id='n5eDq'></ul>

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