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

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

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

  1. <tfoot id='Mu9DC'></tfoot>

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

      使用 PDO Prepared Statement 并递增列值

      时间:2023-10-05

        <legend id='dTKAL'><style id='dTKAL'><dir id='dTKAL'><q id='dTKAL'></q></dir></style></legend>
          <tbody id='dTKAL'></tbody>

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

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

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

                <tfoot id='dTKAL'></tfoot>

              • 本文介绍了使用 PDO Prepared Statement 并递增列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我已阅读此线程:问题递增MySQL/PHP 中的一个字段,带有准备好的语句,但没有看到我的问题的答案.

                I've read this thread: Issues incrementing a field in MySQL/PHP with prepared statements but didn't see the answer to my problem.

                PDOStatement Object
                (
                
                    [queryString] => UPDATE user_alerts SET notif = ? + 2 WHERE ( user_id = ? )   
                
                )
                
                $stmt->execute( array( 'notif', '1' ) );
                

                据我所知,这一切都是正确的.

                As far as I can tell, all this is correct.

                当上面的代码执行时,不管notif列的值是什么,它都会将notif列设置为2.就好像 SQL 读起来像 SET notif = 2 而不是 SET notif = notif + 2

                When the above code executes, it sets the notif column equal to 2 irregardless of what the value of the notif column is. It's as if the SQL is reading like SET notif = 2 instead of SET notif = notif + 2

                我一直无法弄清楚,非常感谢您的帮助!

                I haven't been able to figure it out and would really appreciate help!

                推荐答案

                $sql = 'UPDATE user_alerts SET notif = notif + 2 WHERE ( user_id = :userid )';
                $prepStatement = $pdo->prepare( $sql );
                $prepStatement->execute(array(':userid' => $userid));
                

                您不能将列名绑定到准备好的语句.

                You can't bind a column name to a prepared statement.

                这篇关于使用 PDO Prepared Statement 并递增列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:PDO:找不到驱动程序 php/mysql 下一篇:为什么不能序列化 PDO 对象?

                相关文章

                最新文章

              • <tfoot id='v4v68'></tfoot>
              • <legend id='v4v68'><style id='v4v68'><dir id='v4v68'><q id='v4v68'></q></dir></style></legend>

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

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