0

我是 CakePHP 新手,对此控制器有疑问:

function showmy($userid) {

    return $this->Voucher->find('all', array('conditions' => array('Voucher.user_id' => $userid)));

}   

public function index() {
    $this->Voucher->recursive = 0;
    $userid = $this->Session->read('Auth.User.id');
    $this->set('vouchers', $this->showmy($userid ));
}

我想要登录用户的所有带有 user_id 的凭证。

它有效,但我收到很多错误,例如:

 Warning (2): array_filter() expects parameter 1 to be array, null given     [CORE\Cake\View\Helper\PaginatorHelper.php, line 419]

也许有经验的人可以给我一些建议!

谢谢,朱利叶斯

4

3 回答 3

0

我认为您需要使用PaginatorComponent::paginate()才能在您的视图中使用 PaginatorHelper。手册中的更多信息。

于 2013-08-08T10:43:12.973 回答
0
public function index() {
        $this->Voucher->recursive = 0;
        $userid = $this->Session->read('Auth.User.id');
        $this->Paginator->settings = array(
                    array('conditions' => array('Voucher.user_id' => $userid))
                );

        $this->set('vouchers', $this->Paginator->paginate('Voucher'));
    }
于 2014-07-30T20:01:06.920 回答
0

您必须在控制器中声明 $paginate 数组以进行分页

public $paginate = array( 'limit' => 25, 'order' => array( 'Post.title' => 'asc' ) );

分页 => 数组

于 2013-08-09T08:29:03.683 回答