i created an application that has a navigation bar.
the query is complex, and the count of returned records varies from
page to another.
i need to get the current page number in my model to use it in the
query, is this possible?

here is the code:

/////////////// the controller ///////////////
class LessonsController extends AppController {
        var $name = 'Lessons';
        var $paginate = array('Lesson' => array('limit' => 2, 'page' => 1));

        function friday() {
                $this->set('lessons', $this->paginate('Lesson'));
                //print_r($this->paginator->params); // this works very fine 
here,
but does not work in the model
        }
}

/////////////// the model ///////////////
class Lesson extends AppModel {
        var $name = 'Lesson';

        function paginate($conditions, $fields, $order, $limit, $page = 1,
$recursive = null, $extra = array()) {

                return $this->query(
"SELECT *
FROM lessons
WHERE YEAR(created) = (
                        SELECT DISTINCT( YEAR(created)))
                        FROM lessons
                        ORDER BY id DESC
                        LIMIT $the_page_number ,1)
ORDER BY id DESC");
        }
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to