Pagination from http://www.noswad.me.uk/Pagination12
works fine for custom query.
add custom COUNT query, paginationCount = "SELECT COUNT()..."
$this->Pagination->init(null,$params,array('total'=>$paginationCount).
There is also minor bug in pagination:
/**
 * Fix pagination for custom SQL  queries
 **/
        function fixPage($show, $page)
        {
                $page--;
                $page = $page*$show;

                if ($page < 0)
                {
                        $page = 0;
                }
                return $page;
        }


On Apr 12, 9:01 am, "AD7six" <[EMAIL PROTECTED]> wrote:
> On 12 abr, 00:27, "c0m" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Good afternoon everyone!
>
> > I've been looking online to see some examples of how to use pagination
> > with 1.2, in addition to viewing the API.  I haven't found all that
> > much and have arrived at a dead end.
>
> > Two questions that I have are:
>
> > 1 - Anyone have any good reference links to show how to use pagination
> > properly using 1.2's codebase?
> > 2 - Is it possible to paginate the custom queries?  To explain, all of
> > the queries that are being used are hand-written -- ie. from within a
> > controller, $this->someModel->someMethod($someId)... where in
> > someModel, the method would be someMethod($id) { $result = 
> > $this->query("SELECT * FROM sometable WHERE id = $id"); ..... etc }; that is
>
> > a very basic, probably not-even-used type method, but hopefully it can
> > give you an idea.  Is it possible to paginate those results using
> > 1.2's implicit pagination?
>
> What's a very complex, probably used type method, and why use custom
> queries at all? If there isn't a real reason to use custom queries
> it's just making life difficult for yourself; it pretty much negates
> the possibility to use cake (or anything in cake's) pagination
> abilities without some extra code on your part.
>
> I wrote this recently which you can download from the demos tab and
> have a look around:http://www.noswad.me.uk/Pagination12The download
> may not function out of the box, but all the code you see is what you
> get.
>
> hth,
>
> AD


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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