@teknoid > ... and the fastest and best to achieve it is to follow the > framework's methods. > But if you'd rather spend time trying to hack around the problem, > that's certainly up to you.
Sure you're right, but atm I estimate the time to hack smaller than to learn fw methods. The query delegate to that sorting may grow in complexity and I may found hard to build right conditions to pass at the framework. Let's say I have Photos, that belongs to Users and may have Comments, and Clicks, and Ratings, and I want to order by Comment count or Rating or Clicks over a certain span of time, but I don't want to always estabilish a relationship with Clicks because I'm not always interested in joining the tables because it may slow down the things if the table is large, so (I suppose) I cannot play with ->recursive because I don't want to exclude all other relationships. Those are many doubts of a beginner as I'm, aganist a problem (the pagination of this thread) that if resolved, will trick them all. @Liebermann Thanks for the links. Picking here and there, I managed to get it to work, I had to dig a bit into controller.php :) I know that is not the optimal solution for the framework, it's an hack and is not guaranteed to work for every release and is not recommended to be used, but if anyone is interested: A function could be used to create the paging array. var $helpers = ... 'Paginator' ...; function foo_controller::browse($page = 1) { ... $perpage = 2; // test. 15, 20, ... $start = ($page - 1) * $perpage; // custom query $foos = $this->Foo->query(" select sql_calc_found_rows Foo.* from foos Foo limit $start,$perpage "); $this->set('foos', $foos); $count = $this->Foo->query("select found_rows() as count"); $count = $count[0][0]['count']; $npages = (int)ceil($count/$perpage); // to transfer paging options to $paginator helper in the view // my real issue was to accomplish this: $this->set('paging', array( 'page' => $page, 'current' => count($foos), 'count' => $count, 'prevPage' => ($page > 1), 'nextPage' => ($count > ($page * $perpage)), 'pageCount'=> $npages, 'defaults' => am(array('limit' => 20, 'step' => 1), $this- >paginate), // $this->paginate, found already in the controller 'options' => array() // didnt know what to put here, put array(), it works )); } views/foo/browse.ctp <?php $paginator->params['paging']['Foo'] = $paging; ?> <?php echo $this->renderElement('paginator') // I had this element ready to show a cross-site well styled pagebar ?> --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---