1. payment(user_id, calculation_id)
2. user(id, user_name)
3. calculation(id, period_start_date, period_end_date)
我需要payments
,user_name
,period_start_date
选择period_end_date
。如何在Zend Framework中的一个查询中完成?
非常感谢。
答案 0 :(得分:11)
我找到了解决方案:
$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();