• <tfoot id='39siu'></tfoot>

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

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

        如何判断 MySQL UPDATE 何时成功与实际更新的数据?

        How do I tell when a MySQL UPDATE was successful versus actually updated data?(如何判断 MySQL UPDATE 何时成功与实际更新的数据?)
      1. <tfoot id='T6jyh'></tfoot>
      2. <legend id='T6jyh'><style id='T6jyh'><dir id='T6jyh'><q id='T6jyh'></q></dir></style></legend>
        • <bdo id='T6jyh'></bdo><ul id='T6jyh'></ul>

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

                    <tbody id='T6jyh'></tbody>
                  <i id='T6jyh'><tr id='T6jyh'><dt id='T6jyh'><q id='T6jyh'><span id='T6jyh'><b id='T6jyh'><form id='T6jyh'><ins id='T6jyh'></ins><ul id='T6jyh'></ul><sub id='T6jyh'></sub></form><legend id='T6jyh'></legend><bdo id='T6jyh'><pre id='T6jyh'><center id='T6jyh'></center></pre></bdo></b><th id='T6jyh'></th></span></q></dt></tr></i><div id='T6jyh'><tfoot id='T6jyh'></tfoot><dl id='T6jyh'><fieldset id='T6jyh'></fieldset></dl></div>
                  本文介绍了如何判断 MySQL UPDATE 何时成功与实际更新的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何判断 MySQL UPDATE 何时成功与实际更新的数据?

                  How do I tell when a MySQL UPDATE was successful versus actually updated data?

                  示例:

                  TABLE
                  id    city_name
                  1     Union
                  2     Marthasville
                  

                  如果我运行以下命令:

                  $data = array('city_name', 'Marthasville');
                  
                  //update record 2 from Marthasville to the same thing, Marthasville. 
                  $this->db->where('id', 2);
                  $this->db->update('table', $data);
                  
                  if($this->db->affected_rows() > 0)
                  {
                      //I need it to return TRUE when the MySQL was successful even if nothing was actually updated.
                      return TRUE;
                  }else{
                      return FALSE;
                  }
                  

                  这将在每次 UPDATE 语句成功时返回 TRUE,但在没有实际更新行时返回 FALSE.

                  This will return TRUE every time the UPDATE statement is successful, but FALSE when no rows were actually updated.

                  我需要它在每次成功执行 UPDATE 语句时返回 TRUE,即使它实际上并没有更改任何记录.

                  I need it to return TRUE every time the UPDATE statement was successfully executed even if it doesn't actually change any records.

                  推荐答案

                  看看mysql_affected_rows()

                  它应该告诉您是否实际更新了任何内容,而不是没有成功更新任何内容并返回 true.

                  It should tell you if anything was actually updated as opposed to nothing was successfully updated resulting in a return of true.

                  php.net 说:

                  mysql_affected_rows()

                  mysql_affected_rows()

                  成功时返回受影响的行数,如果最后一个则返回 -1查询失败.

                  Returns the number of affected rows on success, and -1 if the last query failed.

                  您可以使用以下方法来实现您想要的结果:

                  You could use the following to achieve your desired results:

                  if($this->db->affected_rows() >= 0){ }
                  

                  这篇关于如何判断 MySQL UPDATE 何时成功与实际更新的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                  Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)

                  <tfoot id='otkCo'></tfoot>
                  • <small id='otkCo'></small><noframes id='otkCo'>

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