<tfoot id='VQreL'></tfoot>

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

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

        <bdo id='VQreL'></bdo><ul id='VQreL'></ul>
    2. ZF2 如何 orWhere()

      时间:2023-10-02
          <bdo id='ylWNH'></bdo><ul id='ylWNH'></ul>
          <tfoot id='ylWNH'></tfoot>

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

              1. <legend id='ylWNH'><style id='ylWNH'><dir id='ylWNH'><q id='ylWNH'></q></dir></style></legend>

                  <tbody id='ylWNH'></tbody>
              2. <i id='ylWNH'><tr id='ylWNH'><dt id='ylWNH'><q id='ylWNH'><span id='ylWNH'><b id='ylWNH'><form id='ylWNH'><ins id='ylWNH'></ins><ul id='ylWNH'></ul><sub id='ylWNH'></sub></form><legend id='ylWNH'></legend><bdo id='ylWNH'><pre id='ylWNH'><center id='ylWNH'></center></pre></bdo></b><th id='ylWNH'></th></span></q></dt></tr></i><div id='ylWNH'><tfoot id='ylWNH'></tfoot><dl id='ylWNH'><fieldset id='ylWNH'></fieldset></dl></div>
              3. 本文介绍了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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:为什么 Zend Framework 如此受欢迎? 下一篇:ZF2 是基于 MOVE 的吗?

                相关文章

                最新文章

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

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