Zend Db表三表JOIN

Ale*_*tau 2 php mysql zend-framework join

1. payment(user_id, calculation_id)
2. user(id, user_name)
3. calculation(id, period_start_date, period_end_date)
Run Code Online (Sandbox Code Playgroud)

我需要选择payments使用user_name,period_start_date,period_end_date.如何在Zend Framework中的一个查询中执行此操作?

非常感谢.

Ale*_*tau 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();
Run Code Online (Sandbox Code Playgroud)