<legend id='VhAqK'><style id='VhAqK'><dir id='VhAqK'><q id='VhAqK'></q></dir></style></legend>
    1. <small id='VhAqK'></small><noframes id='VhAqK'>

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

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

        PDO 是执行语句期间受影响的行

        时间:2023-09-19

        <tfoot id='E5wc4'></tfoot>

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

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

                  <tbody id='E5wc4'></tbody>

                • 本文介绍了PDO 是执行语句期间受影响的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我找到了很多方法来使用 PDO 的 exec 语句,但我不确定它对我有帮助.我的理解是我必须对准备好的语句使用 execute() 函数.我正在使用来自用户输入的数据更新一行,因此我想使用准备好的语句而不是 query() 调用.

                  I have found many ways to use the exec statement for PDO, but I'm not sure it helps me. My understanding is that I have to use the execute() function for prepared statements. I am updating a row with data from user input, so I would like to use a prepared statement instead of the query() call.

                  我的代码如下:

                  $dbh = buildDBConnector(); 
                  $sql = "UPDATE tb_users 
                      SET authState=1
                      WHERE id = ? AND authPass = ?";
                  $q = $dbh->prepare($sql);
                  $f = $q->execute(array($id,$authPass));
                  if($f){
                      echo '<br />Success<br />';
                  }else{
                      echo '<br />Failure<br />';
                  }
                  

                  问题是查询本身没有错误并且执行得很好,所以没有存储在 $f 中的失败.但是,我需要知道它是否真的找到了要更新的行,然后成功更新了它.换句话说,我需要受影响的行.在谷歌搜索等时,它不断出现 exec 语句,但据我所知, exec 不是用于准备好的语句?有什么建议吗?

                  The issue is that the query itself is error free and executes fine, so there is no failure to store in $f. However, I need to know if it actually found the row to update, then successfully updated it. In other words, I need the affected rows. When googling and such, it keeps coming to the exec statement, but from my understanding, exec isn't for prepared statements? Any suggestions?

                  推荐答案

                  试试 $q->rowCount().准备好的语句将通过该方法返回受影响的行数.

                  Try $q->rowCount(). Prepared statements will return the number of affected rows via that method.

                  这篇关于PDO 是执行语句期间受影响的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 PDO 语句中转义列名 下一篇:如何传递 PDO 参数数组但仍指定它们的类型?

                  相关文章

                  最新文章

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

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

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