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

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

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

        教义:如何从侦听器(preDqlSelect)内的选择查询中删除部分 where 子句?

        Doctrine: How to remove part of a where clause from select query inside listener (preDqlSelect)?(教义:如何从侦听器(preDqlSelect)内的选择查询中删除部分 where 子句?)
          <tbody id='GVDSy'></tbody>

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

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

                • <legend id='GVDSy'><style id='GVDSy'><dir id='GVDSy'><q id='GVDSy'></q></dir></style></legend>
                • <tfoot id='GVDSy'></tfoot>
                  本文介绍了教义:如何从侦听器(preDqlSelect)内的选择查询中删除部分 where 子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的侦听器是行为的一部分,它应该删除任何调用的选择查询的 where 子句中的所有 is_published 检查.将部分添加到子句非常容易,但是如何删除.

                  My listener is part of a behavior, that should remove all is_published checks in the where clause of any called select query. Adding a part to a clause is really easy, but how to remove one.

                  有一些函数如Doctrine_Query->removeDqlQueryPart('where'),但这删除了完整的 where 子句,而我只需要删除 'is_published = ?' 部分.

                  There are some functions like Doctrine_Query->removeDqlQueryPart('where'), but that removes the complete where clause, while I only need the 'is_published = ?' part to be removed.

                  但是,我可以使用正则表达式或其他方式手动处理此问题.但棘手的部分是,如何删除?"表示的参数.从相应的参数数组(可通过 Doctrine_Query->getRawParams() 检索).

                  However I could handle this manually somehow, with regex or something. But the tricky part is, how to remove the parameter represented by the '?' from the corresponding parameters array (retrievable by Doctrine_Query->getRawParams()).

                  所以我问,有没有一种干净的方法来转换这种查询:
                  ...FROM Video v WHERE v.is_published = ?AND v.start_date <?AND v.end_date >?

                  So I ask, is there a clean way to transform this kind of query:
                  ...FROM Video v WHERE v.is_published = ? AND v.start_date < ? AND v.end_date > ?

                  到此剥离一个并且不会弄乱问号表示的参数:
                  ...FROM Video v WHERE v.start_date ?

                  to this stripped one and without messing up the params represented by the question marks:
                  ...FROM Video v WHERE v.start_date < ? AND v.end_date > ?

                  这当然只是一个简单的例子,我的查询要复杂一些.不幸的是,由于 symfony 框架,我坚持使用 1.0.x 学说.

                  This is of course just a simple example, my queries are a bit more complex. Unfortunately I'm stuck with doctrine 1.0.x because of the symfony framework.

                  推荐答案

                  调用 $query->getDqlPart('where') 将返回一个 array 部分通过 where()andWhere() 等函数添加 where 子句.因此,您可以使用它来查找和删除您想要的部分.

                  Calling $query->getDqlPart('where') will return an array of the parts of the where clause as they were added via the where(), andWhere(), etc functions. So you can use that to find and remove the part you want.

                  然后你必须处理参数.骑自行车时,您需要找到所有零件吗?并计算它们并记住您删除的任何数字的数字,然后调用 $params = $query->getParams(); 并且 where 子句参数将在 $params['where'] 这样您就可以从那里删除它们,然后调用 $query->setParams($params);

                  Then you have to deal with the params. While cycling through the where parts you would need to find all ? and count them and remember the numbers for any of the ones you remove and then call $params = $query->getParams(); and the where clause parameters will be in $params['where'] so you can remove them from there and then call $query->setParams($params);

                  这篇关于教义:如何从侦听器(preDqlSelect)内的选择查询中删除部分 where 子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Converting between timezones in PHP(在 PHP 中的时区之间转换)
                  PHP - strtotime, specify timezone(PHP - strtotime,指定时区)
                  Get current date, given a timezone in PHP?(获取当前日期,给定 PHP 中的时区?)
                  List of US Time Zones for PHP to use?(PHP 使用的美国时区列表?)
                  How to detect Ambiguous and Invalid DateTime in PHP?(如何在 PHP 中检测不明确和无效的 DateTime?)
                  How to update timezonedb in PHP (updating timezones info)?(如何在 PHP 中更新 timezonedb(更新时区信息)?)

                • <tfoot id='p0Rbt'></tfoot>

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

                            <tbody id='p0Rbt'></tbody>
                        1. <small id='p0Rbt'></small><noframes id='p0Rbt'>