- Hello, I have an array of query results that I want to be paginated. But somehow I got an error that says :
Unable to locate an object compatible with paginate.
Here’s my current code:
$this->paginate = ['limit' => 10]; $comment = TableRegistry::get('Comments'); $comments = $comment ->find() ->where(['Comments.post_id' => $id]) ->contain(['Users']) ->order(['Comments.created' => 'ASC']) ->all() ->toArray(); //the results will be array $comments = $this->paginate($comments);
- My second question is, is there a way to always have an array result instead of object results when having a query in the controller so that I won’t need to include ->toArray() into my code?