【发布时间】:2016-02-02 20:37:42
【问题描述】:
这是我的 index() 函数:
$this->paginate = [
'conditions' => [
'Items.state_id' => $state,
],
'contain' => ['Accounts', 'Creditors', 'States', 'Bankaccounts' => ['joinType' => 'LEFT']],
'order' => ['Items.account_id ASC', 'Items.creditor_id ASC', 'Items.payuntil ASC']
];
$this->set('items', $this->paginate($this->Items));
$this->set('_serialize', ['items']);
在我想使用第 2 页的分页链接之前,它可以正常工作:
我的看法:
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->prev('< ' . __('vorherige')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('nächste') . ' >') ?>
</ul>
<p><?= $this->Paginator->counter('Seite {{page}} von {{pages}}') ?></p>
</div>
这是浏览器中的输出:
<a href="/items?page=2&sort=0&direction=Items.account_id+ASC">2</a>
但是这样会导致sql错误:
WHERE
Items.state_id = 1
ORDER BY
asc
LIMIT
20 OFFSET 0
有一个空的 ORDER BY 选项。
如果我将上述链接更改为仅:/items?page=2 它按预期工作。
那么这里有什么问题呢? 我怎样才能解决这个问题? 请指教:-)
【问题讨论】:
标签: cakephp pagination