i did it !!!!!!!!

i passed the page current number to the (paginate) function in the
($extra) argument instead of passing it in the $limit argument,

here is the modefied code:

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

        function friday() {
                if(! isset($this->passedArgs["page"])) $pageNumber=0;
                else $pageNumber=$this->passedArgs["page"]-1;

                $this->paginate = Set::merge($this->paginate,
array('Lesson'=>array('limit'=>2, 'page'=>1, 'extra'=>$pageNumber)));

                $this->set('lessons', $this->paginate('Lesson'));
        }
}

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

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

                $offset=$extra["extra"];
                return $this->query(
"SELECT *
FROM lessons
WHERE YEAR(created) = (
                        SELECT DISTINCT( YEAR(created)))
                        FROM lessons
                        ORDER BY id DESC
                        LIMIT $offset ,1)
ORDER BY id DESC");
        }

        function paginateCount($limit, $pageCount, $conditions = null,
$recursive = 0, $extra = array()) {
                $results =$this->query(
"SELECT COUNT(*) count
FROM lessons
WHERE lessons.status='1'");

                return $results[0][0]["count"];
        }
}

--~--~---------~--~----~------------~-------~--~----~
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