Pagination after inserting or updateing record
one more question related with cakephp...
let's say that i have 20+ records in my table. they are sorted by some criteria, ie. by title. and on a list view, i have a list of 10 records, with available pagination.
how can i achieve that when i insert new record, to be redirected to proper page, where i can see record that is just was insterted? how can i get information on which page i have to be redirected?
hope my question is enough clear for understanding...
tnx in开发者_运维知识库 adv!
I do not think you can do it in CakePHP without unnecessary database queries if you do not sort your records by id. You can get the id of the last saved record this way: $this->YourModel->save($data); $newId = $this->YourModel->id;
You can use this id to redirect to $this->redirect(array('action' => 'view', $newId));
to ensure the record has been saved.
Or after saving the new record you can redirect to /your_model/index/page:1/sort:id/direction:desc
.
精彩评论