Zend_Db - 联盟

时间:2014-05-17 16:32:29

标签: zend-framework zend-db zend-db-table

我有代码:

$balanceModelCredit = new Model_BalanceCredit();
$balanceModelDebt = new Model_BalanceDebt();

$selectQueryDebt = $balanceModelDebt->select()
    ->from('balance_debt', array('date',
        'amount',
        'description',
        new Zend_Db_Expr('"koszta"')
    ));
$selectQueryDebt->where('balance_id=?', $balance_id);

$selectQueryCredit = $balanceModelCredit->select()
    ->from('balance_credit', array('date',
                             'amount',
                             'description',
                             new Zend_Db_Expr('"przychod"')
    ));
$selectQueryCredit->where('balance_id=?', $balance_id);

如何进行UNION声明?

1 个答案:

答案 0 :(得分:0)

你只需要这样做:

$selectQueryCredit->where('balance_id = ?', $balance_id);

$selectQueryCredit->union(array($selectQueryDebt));

希望它有所帮助。