0
我有我的控制器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')
功能的基礎上一場的結果。該查詢返回正確的數據,並且如果我在渲染視圖之前對其進行了處理,則信息是正確的。但是,在使用$ 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'])); ?> </td>
<td><?php echo h($asset['Fleet']['name']); ?> </td>
<td><?php echo h($asset['Type']['name']); ?> </td>
<td><?php echo h($asset['Make']['name']); ?> </td>
<td><?php echo h($asset['Asset']['model']); ?> </td>
<td><?php echo h($asset['Asset']['fleetNumber']); ?> </td>
<td><?php echo h($asset['Asset']['registrationNumber']); ?> </td>
<td><?php echo h($asset['Asset']['chassisNumber']); ?> </td>
<td><?php echo h($asset['Status']['name']); ?> </td>
<td><?php echo h($asset['Asset']['operator']); ?> </td>
<td><?php echo h($this->Time->format(($asset['Asset']['created']),'%d/%m/%Y %H:%M')); ?> </td>
<td><?php echo h($asset['Asset']['createdBy']); ?> </td>
<td><?php echo h($this->Time->format(($asset['Asset']['modified']),'%d/%m/%Y %H:%M')); ?> </td>
<td><?php echo h($asset['Asset']['modifiedBy']); ?> </td>
<td><?php if($asset['Asset']['deleteFlag'] == 0){
echo h('Active');
}
elseif($asset['Asset']['deleteFlag'] == 1){
echo h('Deleted');
}
?> </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>