[CDBI] Paging through Results using Class::DBI::Sweet

Dave Mabe davemabe at gmail.com
Sun Feb 12 12:41:23 GMT 2006


How do you loop through the results after you call ->page like in the
example in the CDBI::Sweet docs?

>From the Class::DBI::Sweet docs:

 __PACKAGE__->set_sql( 'count_by_cd', <<'');
        SELECT      __ESSENTIAL(me)__, COUNT
<http://stockcharts.com/def/servlet/SC.web?c=COUNT>(cds.cdid) as
cd_count
        FROM <http://stockcharts.com/def/servlet/SC.web?c=FROM>       
%s                  -- ("from")
        WHERE <http://stockcharts.com/def/servlet/SC.web?c=WHERE>     
 %s                  -- ("where")
        GROUP <http://stockcharts.com/def/servlet/SC.web?c=GROUP> BY
<http://stockcharts.com/def/servlet/SC.web?c=BY>    __ESSENTIAL(me)__
        %s %s                           -- ("limit" and "order_by")

 Then in your application code:

    my ($pager, $iterator) = MyDB::Artist->page(
        {
            'cds.title'    => { '!=', undef },
        },
        {
            sql_method          => 'count_by_cd',
            statement_order     => [qw/ from where limit order_by / ],
            disable_sql_paging  => 1,
            order_by            => 'cd_count desc',
            rows                => 10,
            page                => 1,
        } );

How do you use $pager and $iterator to loop through results?

TIA.

--
Dave Mabe
http://www.stocktickr.com

My New Book: BlackBerry Hacks
http://www.amazon.com/exec/obidos/tg/detail/-/0596101155/runningwatch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20060212/57befa6e/attachment.html


More information about the ClassDBI mailing list