简体   繁体   中英

Zend Db Table Three tables JOIN

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.

I have found the solution:

$db     = new Zend_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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM