在cakephp中对结果进行分页不会给出正确的结果

在cakephp中对结果进行分页不会给出正确的结果,cakephp,pagination,Cakephp,Pagination,我的控制器中有以下功能 public function getDeleted(){ $options = array( 'conditions' => array('deleteFlag' => 1 )); $assets = $this->Asset->find('all', $options); $this->set('assets', $this->paginate());

我的控制器中有以下功能

public function getDeleted(){

    $options = array(
            'conditions' => array('deleteFlag' => 1
                ));
    $assets = $this->Asset->find('all', $options);
    $this->set('assets', $this->paginate());
    $this->render('index');
}
我用它来过滤基于一个字段的find'all'函数的结果。查询返回的数据正确,如果在呈现视图之前调试$assets,则信息正确。但是,在我使用$this->paginate之后,它将返回表中的所有行,而不是筛选结果。谁能告诉我这是为什么

如果我将paginate函数保留在set方法之外,页面将抛出一个错误。我的看法如下:

<div class="assets index">
<h2>
    <!-- <?php echo __('Assets'); ?> -->
</h2>
<table cellpadding="0" cellspacing="0">
    <thead>
        <tr>
            <th><?php echo $this->Paginator->sort('id'); ?></th>
            <th><?php echo $this->Paginator->sort('fleet_id'); ?></th>
            <th><?php echo $this->Paginator->sort('type_id'); ?></th>
            <th><?php echo $this->Paginator->sort('make_id'); ?></th>
            <th><?php echo $this->Paginator->sort('model'); ?></th>
            <th><?php echo $this->Paginator->sort('fleetNumber', 'Fleet No'); ?>
            </th>
            <th><?php echo $this->Paginator->sort('registrationNumber', 'Reg No'); ?>
            </th>
            <th><?php echo $this->Paginator->sort('chassisNumber', 'Chassis No'); ?>
            </th>
            <th><?php echo $this->Paginator->sort('status_id'); ?></th>
            <th><?php echo $this->Paginator->sort('operator'); ?></th>
            <th><?php echo $this->Paginator->sort('created', 'Created date'); ?>
            </th>
            <th><?php echo $this->Paginator->sort('createdBy', 'Created by'); ?>
            </th>
            <th><?php echo $this->Paginator->sort('modified', 'Modified date'); ?>
            </th>
            <th><?php echo $this->Paginator->sort('modifiedBy', 'Modified by'); ?>
            </th>
            <th><?php echo $this->Paginator->sort('deleteFlag', 'Deleted?'); ?>
            </th>
            <th class="actions"><?php echo __('Actions'); ?></th>
        </tr>
    </thead>
    <tbody>
    <?php foreach ($assets as $asset): ?>
        <tr>
            <td><?php echo $this->Html->link(__($asset['Asset']['id']), array('action' => 'view', $asset['Asset']['id'])); ?>&nbsp;</td>
            <td><?php echo h($asset['Fleet']['name']); ?>&nbsp;</td>
            <td><?php echo h($asset['Type']['name']); ?>&nbsp;</td>
            <td><?php echo h($asset['Make']['name']); ?>&nbsp;</td>
            <td><?php echo h($asset['Asset']['model']); ?>&nbsp;</td>
            <td><?php echo h($asset['Asset']['fleetNumber']); ?>&nbsp;</td>
            <td><?php echo h($asset['Asset']['registrationNumber']); ?>&nbsp;</td>
            <td><?php echo h($asset['Asset']['chassisNumber']); ?>&nbsp;</td>
            <td><?php echo h($asset['Status']['name']); ?>&nbsp;</td>
            <td><?php echo h($asset['Asset']['operator']); ?>&nbsp;</td>
            <td><?php echo h($this->Time->format(($asset['Asset']['created']),'%d/%m/%Y %H:%M')); ?>&nbsp;</td>
            <td><?php echo h($asset['Asset']['createdBy']); ?>&nbsp;</td>
            <td><?php echo h($this->Time->format(($asset['Asset']['modified']),'%d/%m/%Y %H:%M')); ?>&nbsp;</td>
            <td><?php echo h($asset['Asset']['modifiedBy']); ?>&nbsp;</td>
            <td><?php if($asset['Asset']['deleteFlag'] == 0){
                echo h('Active');
            }
            elseif($asset['Asset']['deleteFlag'] == 1){
                echo h('Deleted');  
            }
            ?>&nbsp;</td>

            <td class="actions">
                <?php echo $this->element('buttons',array('values' => $asset)); ?>
            </td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?>
</p>
<div class="paging">
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</div>

您没有正确使用paginate

Paginate不同于普通的find查询,其中两个用于不同的目的。检查url以了解如何使用分页组件

 $this->Paginator->settings = array(
        'conditions' => array('Recipe.deleteFlag' => 1),
        'limit' => 10
    );
    $assets = $this->Paginator->paginate('Recipe');
    $this->set(compact('assets'));
这将是正确的做事方式

而find'all'是普通的find查询,与paginator无关