Zend Framework Select Objects And UNION()

前端 未结 6 1989
南旧
南旧 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条回答
  •  萌比男神i
    2020-12-30 16:59

    Here's what I've done to make a union:

    $select = $this->select();
    //common select from both sides of the union goes here
    
    $select1 = clone($select);
    //select1 specifics here
    
    $select2 = clone($select);
    //select 2 specifics here
    
    $db = $this->getAdapter();
    $pageselect = $db->select()->union(array("($select1)", "($select2)"));
    

    Remember Db_Select's __toString will print out the SQL generated by that select, to help you debug.

提交回复
热议问题