I have the following models in CakePHP:
A Deposit belongs to an Account
An Account belongs to a Customer
I want to have a list of Deposits, and I need to show the name of the customer (so I have to join through the Customer). I also need to paginate this list.
If I set Deposit->recursive = 2, I can get the Customer, however, CakePHP runs one query joining Deposit and Account, and then runs one query per each Deposit, to get the Customer.
How can I make it get both models with only one query?
I tried this, but it didn't work:
$this->paginate = array('joins' => array(
array(
'table' => 'customers',
'alias' => 'AccountCustomer',
'type' => 'inner',
'foreignKey' => false,
'conditions' => array('Account.customer_id = AccountCustomer.id')
)
));
Any ideas?
Thanks!
Daniel