Reputation: 2953
I'm trying to join my ApplicationPayday
model to my Application
in my Cake PHP 2.10 application via the joins
property in my paginator. For some reason though, I'm only seeing the Application
and not my joined Payday, what am I missing as this works if I do a regular model query outside of pagination.
// define pagination settings
$this->Paginator->settings = array(
'maxLimit' => 20,
'joins' => array(
array(
'table' => 'tlp_application_paydays',
'alias' => 'ApplicationPayday',
'type' => 'inner',
'conditions' => array(
'ApplicationPayday.application_id = Application.id'
)
),
),
'order' => array(
'Application.id' => 'desc'
),
'recursive' => -1
);
// run query to get applications via paginated settings
$applications = $this->Paginator->paginate('Application');
echo '<pre>';
var_dump($applications);
echo '</pre>';
Upvotes: 0
Views: 46
Reputation: 2094
I recommend removing recursive = -1 and use contain() like this:
$this->Application->contain([
'ApplicationPayday',
]);
Read more about contain() here: https://book.cakephp.org/2/en/core-libraries/behaviors/containable.html
Upvotes: 1