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

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

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

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

        ZF2 如何 orWhere()

        ZF2 How to orWhere()(ZF2 如何 orWhere())

          <legend id='51Xp9'><style id='51Xp9'><dir id='51Xp9'><q id='51Xp9'></q></dir></style></legend>
            <bdo id='51Xp9'></bdo><ul id='51Xp9'></ul>

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

                  <small id='51Xp9'></small><noframes id='51Xp9'>

                  本文介绍了ZF2 如何 orWhere()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想弄清楚如何在 where 子句中使用 OR 进行 Mysql Select.默认情况下,where 语句中的所有子句都是 AND 运算的,经过几个小时的尝试和失败,查看网络无法使其工作.在 ZF1 中它将是 orWhere() 但在 ZF2 中没有.

                  I am trying to figure out how to make a Mysql Select with an OR in where Clause. By default all clauses in where statement are ANDed and after some hours of try and fail and looking the net can't make it work. In ZF1 it would be an orWhere() but there is not in ZF2.

                  这是我在 AbstracttableGateway 中的代码:

                  This is the code i have inside a AbstracttableGateway:

                  $resultSet = $this->select(function (Select $select) use ($searchstring) {
                               $select->join('users','blog_posts.id_user = users.id',array('name'))
                                      ->join('blog_categories','blog_posts.id_category = blog_categories.id', array(
                                                             'cat_name'   => 'name',
                                                             'cat_alias' => 'alias',
                                                             'cat_image'  => 'icon'))
                                      ->order('date DESC');
                                      //->where("title LIKE '%" .$searchstring . "%' OR content LIKE '%". $searchstring ."%'")
                              $select->where->like('content','%'.$searchstring.'%');
                              $select->where->like('title','%'.$searchstring.'%');
                          }
                      );
                      return $resultSet;
                  

                  带有 $select->where->like 的行是 AND 运算的,我希望它们带有 OR.我应该改变什么?

                  the lines with the $select->where->like are the ones that are ANDed and I want them with OR. What should I change?

                  推荐答案

                  ZF2 中没有 orWhere,但你可以使用 ZendDbSqlPredicate 的任意组合代码>对象.对于 OR,在 PredicateSetPredicateSet::COMBINED_BY_OR 中使用 2 个谓词.

                  There is no orWhere in ZF2, but you could use any combination of ZendDbSqlPredicate objects. For OR use 2 predicates in a PredicateSet with PredicateSet::COMBINED_BY_OR.

                  关于它的文档不多,但您可以浏览源代码 - 现在.

                  There's not much documentation for it, but you could browse the source - for now.

                  编辑:示例

                  use ZendDbSqlPredicate;
                  
                  $select->where(array(
                      // ...
                      new PredicatePredicateSet(
                          array(
                              new PredicateLike('content', '%'.$searchstring.'%'),
                              new PredicateLike('title', '%'.$searchstring.'%'),
                          ),
                          PredicatePredicateSet::COMBINED_BY_OR
                      ),
                      // ...
                  ));
                  

                  这篇关于ZF2 如何 orWhere()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  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 的问题)
                    <legend id='ZUNeq'><style id='ZUNeq'><dir id='ZUNeq'><q id='ZUNeq'></q></dir></style></legend>
                    <i id='ZUNeq'><tr id='ZUNeq'><dt id='ZUNeq'><q id='ZUNeq'><span id='ZUNeq'><b id='ZUNeq'><form id='ZUNeq'><ins id='ZUNeq'></ins><ul id='ZUNeq'></ul><sub id='ZUNeq'></sub></form><legend id='ZUNeq'></legend><bdo id='ZUNeq'><pre id='ZUNeq'><center id='ZUNeq'></center></pre></bdo></b><th id='ZUNeq'></th></span></q></dt></tr></i><div id='ZUNeq'><tfoot id='ZUNeq'></tfoot><dl id='ZUNeq'><fieldset id='ZUNeq'></fieldset></dl></div>
                    • <bdo id='ZUNeq'></bdo><ul id='ZUNeq'></ul>

                            <tfoot id='ZUNeq'></tfoot>
                              <tbody id='ZUNeq'></tbody>

                          1. <small id='ZUNeq'></small><noframes id='ZUNeq'>