我正试图通过分页器中的joins
属性将我的ApplicationPayday
模型连接到Cake PHP 2.10应用程序中的Application
。不过,出于某种原因,我只看到了Application
,而没有看到我加入的Payday,如果我在分页之外进行常规模型查询,我会错过什么。
// 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>';
我建议删除recursive=-1并使用contain((,如下所示:
$this->Application->contain([
'ApplicationPayday',
]);
点击此处阅读有关contain((的更多信息:https://book.cakephp.org/2/en/core-libraries/behaviors/containable.html