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

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

      • <bdo id='PqKoM'></bdo><ul id='PqKoM'></ul>

      <tfoot id='PqKoM'></tfoot>
      1. Doctrine listener - 仅在字段更改时运行操作

        Doctrine listener - run action only if a field has changed(Doctrine listener - 仅在字段更改时运行操作)

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

              <tbody id='Rnc9m'></tbody>

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

              • <legend id='Rnc9m'><style id='Rnc9m'><dir id='Rnc9m'><q id='Rnc9m'></q></dir></style></legend>
              • <i id='Rnc9m'><tr id='Rnc9m'><dt id='Rnc9m'><q id='Rnc9m'><span id='Rnc9m'><b id='Rnc9m'><form id='Rnc9m'><ins id='Rnc9m'></ins><ul id='Rnc9m'></ul><sub id='Rnc9m'></sub></form><legend id='Rnc9m'></legend><bdo id='Rnc9m'><pre id='Rnc9m'><center id='Rnc9m'></center></pre></bdo></b><th id='Rnc9m'></th></span></q></dt></tr></i><div id='Rnc9m'><tfoot id='Rnc9m'></tfoot><dl id='Rnc9m'><fieldset id='Rnc9m'></fieldset></dl></div>
                  <tfoot id='Rnc9m'></tfoot>
                  本文介绍了Doctrine listener - 仅在字段更改时运行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何检查字段是否已更改?

                  How do I check if field has changed?

                  我想在 preSave() 中仅在特定字段发生更改时触发操作,例如

                  I'd like to trigger an action in preSave() only if specific field has changed, e.q.

                  public function preSave() {
                      if ($bodyBefore != $bodyNow) {
                           $this->html = $this->_htmlify($bodyNow);
                      }
                  } 
                  

                  问题是如何得到这个$bodyBefore$bodyNow

                  推荐答案

                  请不要再取数据库了!这适用于 Doctrine 1.2,我还没有测试过低版本.

                  Please don't fetch the database again! This works for Doctrine 1.2, I haven't tested lower versions.

                  // in your model class
                  public function preSave($event) {
                    if (!$this->isModified())
                      return;
                  
                    $modifiedFields = $this->getModified();
                    if (array_key_exists('title', $modifiedFields)) {
                      // your code
                    }
                  }
                  

                  也请查看文档.

                  这篇关于Doctrine listener - 仅在字段更改时运行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                  Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                  Doctrine 2, query inside entities(原则 2,实体内部查询)
                  Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                  Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                  Doctrine and unrefreshed relationships(教义和未更新的关系)

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

                    • <bdo id='mUQbA'></bdo><ul id='mUQbA'></ul>
                    • <tfoot id='mUQbA'></tfoot>

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