0

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
1

2 Answers 2

1

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
    ));
Sign up to request clarification or add additional context in comments.

Comments

0

Zend Framework Select Objects And UNION()

2 Comments

that is not very helpful. don't consider it duplicate answer. I need it written for idiots cuz i've been troubling my mind here and it doesn't seem to work.
I'm sorry if you didn't find that link "helpful", however what you accepted as solution was already proposed and accepted there. Therefore, this is a duplicate. Don't say this is not a duplicate because the other question is not exactly what you're asking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.