In sql i am using union i don\'t know how to write it in zend db.
select m.*, 0 as is_shared from test m where user_id = $userId
union
select m.*,1 as is_sh
According to the Zend_Db_Select documentation, you can create one query for each member of the union (they can be strings or Zend_Db_Select
objects themselves), and then call the union()
method of Zend_Db_Select
.
Something like:
$sql1 = FIRSTPARTOFTHEQUERY;
$sql2 = SECONDPARTOFTHEQUERY;
$select = $db->select();
$select->union(array($sql1, $sql2));
Hope that helps,