Basically i need to have this query done through zend framework.
SELECT k.id AS ID ,k.name AS NAME ,k.ppu_sell AS PRICE, k.type as TYPE FROM `inventory` as k UNION
select m.id AS ID, m.name AS NAME, m.price AS PRICE, 'menu' as TYPE FROM menu as m
Basically i need to have this query done through zend framework.
SELECT k.id AS ID ,k.name AS NAME ,k.ppu_sell AS PRICE, k.type as TYPE FROM `inventory` as k UNION
select m.id AS ID, m.name AS NAME, m.price AS PRICE, 'menu' as TYPE FROM menu as m
Try this:
$select = Zend_Db_Table::getDefaultAdapter()->select();
$select->from(
array('inventory' => 'k'),
array(
'ID' => 'k.id',
'NAME' => 'k.name',
'PRICE' => 'k.ppu_sell',
'TYPE' => 'k.type'));
$selectClone = clone $select;
$select->reset()->from(
array('menu' => 'm'),
array(
'ID' => 'm.id',
'NAME' => 'm.name',
'PRICE' => 'm.price',
'TYPE' => new Zend_Db_Expr("'menu'")));
$select = Zend_Db_Table::getDefaultAdapter()->select()->union(array(
$selectClone, $select
));