Zend Framework Select Objects And UNION()

前端 未结 6 1986
南旧
南旧 2020-12-30 16:16

I\'m pretty sure this is not possible in Zend Framework (I have searched the Web, the documentation and issue tracker) but I just want to make sure so I\'m asking here.

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 17:16

    The best way Zend suggest is like follows....

    $sql = $this->_db->select()
        ->union(array($select1, $select2,$select3))
                ->order('by_someorder');
    
    echo $sql->__toString();
    
    $stmt = $db->query($sql);
    $result = $stmt->fetchAll();
    

    echo will show the query

    Here $select1, $select2, $select3 can be different select queries with same number of columns...

提交回复
热议问题