views:

27

answers:

1

Hello. I have 3 tables.

1. payment(user_id, calculation_id)
2. user(id, user_name)
3. calculation(id, period_start_date, period_end_date)

I need to select payments with user_name, period_start_date, period_end_date. How can I do it within one query in Zend Framework?

Thanks a lot.

+1  A: 
    $db      =  new Lyf_DB_Table('payment');
    $select  =  $db->select()->setIntegrityCheck(false);
    $select  -> from('payment')
             -> join('user', 'user.id = payment.user_id', array('user_name'))
             -> join('calculation', 'calculation.id = payment.calculation_id', array('period_start_date', 'period_end_date'))
    $payment =  $db->fetchAll($select)->toArray();
Alexander.Plutov