我抓取所有我的用戶,並在CakePhp的列表和分頁顯示它們。 但它爲什麼給我
錯誤:發生內部錯誤。 和堆棧跟蹤下的線cakephp分頁說錯誤:發生內部錯誤
$data = $this->Paginator->paginate('User');
被突出顯示。
UserhomeController.php
<?php
App::uses('AppController', 'Controller');
class UserhomeController extends AppController {
public $components = array('Paginator', 'RequestHandler');
public $helpers = array('Js', 'Paginator');
public $paginate = array(
'fields' => array('User.id', 'User.email'),
'limit' => 25,
'order' => array(
'User.email' => 'asc'
)
);
public function index() {
$this->Paginator->settings = $this->paginate;
// similar to findAll(), but fetches paged results
$data = $this->Paginator->paginate('User');
$this->set('user', $data);
}
}
USERHOME/index.ctp
<?php
$this->Paginator->options(array(
'update' => '#content',
'evalScripts' => true
));
?>
<div class="container bottom_padding background_color_E8E3D7 height_full padding_top box_shadow">
<table class="table table-striped background_color_eee">
<!-- Here is where we loop through our $users array, printing out post info -->
<?php foreach ($data as $user): ?>
<tr>
<td><?php echo $user['User']['id']; ?></td>
<td>
<?php echo $this->Html->link($user['User']['title'], array('controller' => 'users', 'action' => 'view', $user['User']['id']));
?>
</td>
<td><?php echo $user['User']['email']; ?></td>
</tr>
<?php endforeach; ?>
<?php unset($user); ?>
</table>
<ul class="pagination">
<?php
echo $this->Paginator->prev(__('<<'), array('tag' => 'li'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a'));
echo $this->Paginator->numbers(array('separator' => '', 'currentTag' => 'a', 'currentClass' => 'active', 'tag' => 'li', 'first' => 1));
echo $this->Paginator->next(__('>>'), array('tag' => 'li', 'currentClass' => 'disabled'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a'));
?>
</ul>
<br/>
<?php
echo $this->Paginator->counter(
'Page {:page} of {:pages}, showing {:current} records out of
{:count} total, starting on record {:start}, ending on {:end}'
);
?>
</div>
<?php echo $this->Js->writeBuffer(); ?>
您參考模型中的控制器一無所知關於 – AD7six
對不起,請你解釋一下。你在哪裏指出錯誤? –