in short, Article hasMany Rating the articles/index need to paginate and sorted with AVG(rating.score)
i found a good start in http://groups.google.com/group/cake-php/browse_thread/thread/bece8aab31fbba72/1b27c78b0a3023d8?#1b27c78b0a3023d8 but archived, and last solution do not work at all. (cakephp 1.2.5) my code: class ArticlesController extends AppController { // ... var $paginate = array( 'Article' => array( 'limit' => 15, 'order' => 'avg_rating DESC', 'group' => 'Article.id' ) ); // ... function index() { if (isset($this->passedArgs['sort'])) { if ($this->passedArgs['sort'] == 'avg_rating') { $this->paginate['Article']['order'] = 'avg_rating '.strtoupper ($this->passedArgs['direction']); $this->paginate['Article']['direction'] = $this->passedArgs ['direction']; unset($this->passedArgs['sort']); } } $this->Article->bindModel(array( 'hasOne' => array( 'AvgRating' => array( 'className' => 'Rating', 'fields' => 'AVG(AvgRating.rating) AS avg_rating' ) ) ), false); $this->set('articles', $this->paginate()); } } is there anything i can do for a more beautiful solution? at least, i think, a little modification in paginator help can help index controller during "reset" passedArg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---