I need my tree sorted by each post sort value. Here is the function
dealing with this. But it is executed extremely slow if some of the
parents has more than 20-30 children
function _sortPosts($newSort){
foreach ($newSort AS $id => $value) {
if(is_numeric($value['sort'])){
$this->Post->updateAll(array('Post.sort' => $value['sort']),
array('Post.id' => $id));
} else {
$this->Session->setFlash(__('Non-numeric value given.', true),
'default', array('class' => 'error'));
$this->redirect($this->referer());
}
}
foreach(array_keys($this->data['Post']) as $parent){
$this->Post->reorder(array('id'
=> $parent, 'field' =>
'Post.sort', 'order' => 'ASC', 'verify' => true));
}
}
Example:
38 posts, 8 parents and 30 children
5518 queries took 6028 ms
Page rendered in 20032ms.
Is there some other way to do this reorder without such a delay?
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php