Zend-framework DB: OR instead of AND operator

后端 未结 3 411
醉话见心
醉话见心 2021-02-05 22:23

have such zend query:

$select = $this->_table
               ->select()
               ->where(\'title LIKE  ?\', \'%\'.$searchWord.\'%\')
                      


        
相关标签:
3条回答
  • 2021-02-05 22:47
    $this->_table->select()->orWhere($condition);
    

    To build more complexe queries (i.g. sub-conditions) you might have to use $this->table->getAdapter()->quoteInto() and write your SELECT manually.

    0 讨论(0)
  • 2021-02-05 22:49

    I have implemented your zend query

    $select = $this->_table
                   ->select()
                   ->where('title LIKE  ?', '%'.$searchWord.'%')
                   ->ORwhere('description LIKE  ?', '%'.$searchWord.'%')
                   ->where('verified=1 AND activated=1');
    
    0 讨论(0)
  • 2021-02-05 22:57

    The others answers here do not work (anymore?), the current solution is to call nest() and unnest() in the where clause:

    $select->where
        ->nest()
            ->equalTo('column1', 1)
            ->or
            ->equalTo('column2', 2)
        ->unnest()
        ->and
        ->equalTo('column3', 3);
    
    0 讨论(0)
提交回复
热议问题