CakePHP paginate twice
I have a paginate call, as in $users = $this->paginate('User');
.
But then I make a call to update the $users
array with some stuff (third party). How do I get paginate to call itself again?
$resultsPerPage = 10;
$this->paginate = array
(
'conditions' => array
(
'User.name' => $query
),
'limit' => $resultsPerPage
);
Then I do: $users = $this->paginate('User');
Then I ta开发者_JS百科ke those user_ids in that 1st page returned set, and pass them to another system (I do an API call and don't have database access to that system). Some of the $users
array data gets update and a $this->save()
is done for each instance if something is updated (external code too). But that makes the $users
array out of date. If I do another call for the same data which should update it? But paginate doesn't do another database call?
what you are doing sounds like you are doing it wrong. api calls should not be done in a controller. that is for a model / datasource to do. however this is one way you can do what you are donig.
after the first call do something like the following
$this->params['named']['page'] = isset($this->params['named']['page']) ? $this->params['named']['page'] + 1 : 2;
that is saying increase the page number buy one if its set, or make it page 2. this will trick the paginator into thinking you are on the next page. you can then call $this->paginate() again to get the next set.
cake uses the page in the params to set limit x, y.
精彩评论