phpcakephpcakephp-2.3

issue in cakephp pagination


i am getting data based on category using this code

$this->paginate=$this->Project->find('all', array('conditions' => array('category' => $this->request->data['Project']['category'])));
        $this->set('projects', $this->paginate);

by using above code i am getting these errors

Warning (2): array_filter() expects parameter 1 to be array, null given [CORE\Cake\View\Helper\PaginatorHelper.php, line 403]
Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE\Cake\View\Helper\PaginatorHelper.php, line 403]

how i can resolve this isse?


Solution

  • Your code is wrong.

    Use:

    $this->Paginator->settings = array('conditions' => array('Project.category' => $this->request->data['Project']['category']));
    $this->set('projects', $this->Paginator->paginate());