[prev] [thread] [next] [Date index for 2006/02/12]
--===============1391852043==
Content-Type: multipart/alternative;
boundary="----=_Part_11055_20986491.1139748083725"
------=_Part_11055_20986491.1139748083725
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
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=3DCOUNT>(cds.cdid) as
cd_count
FROM <http://stockcharts.com/def/servlet/SC.web?c=3DFROM> =20
%s -- ("from")
WHERE <http://stockcharts.com/def/servlet/SC.web?c=3DWHERE> =20
%s -- ("where")
GROUP <http://stockcharts.com/def/servlet/SC.web?c=3DGROUP> BY
<http://stockcharts.com/def/servlet/SC.web?c=3DBY> __ESSENTIAL(me)__
%s %s -- ("limit" and "order_by")
Then in your application code:
my ($pager, $iterator) =3D MyDB::Artist->page(
{
'cds.title' =3D> { '!=3D', undef },
},
{
sql_method =3D> 'count_by_cd',
statement_order =3D> [qw/ from where limit order_by / ],
disable_sql_paging =3D> 1,
order_by =3D> 'cd_count desc',
rows =3D> 10,
page =3D> 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
------=_Part_11055_20986491.1139748083725
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
How do you loop through the results after you call ->page like in the ex=
ample in the CDBI::Sweet docs?<br><br>From the Class::DBI::Sweet docs:<br><=
dl><dd><pre> __PACKAGE__->set_sql( 'count_by_cd', <<'');<br> =
SELECT __ESSENTIAL(me)__,=20
<span><a style=3D"border-bottom: 1px solid orange;" class=3D"autolink autol=
ink-ticker-symbol" title=3D"Link added by Stock Chart AutoLink filter: Tick=
er Symbol" href=3D"http://stockcharts.com/def/servlet/SC.web?c=3DCOUNT">COU=
NT</a>
</span>(cds.cdid) as cd_count<br> <span><a style=3D"border-bottom: 1=
px solid orange;" class=3D"autolink autolink-ticker-symbol" title=3D"Link a=
dded by Stock Chart AutoLink filter: Ticker Symbol" href=3D"http://stockcha=
rts.com/def/servlet/SC.web?c=3DFROM">
FROM</a></span> %s -- ("from")<br> =
<span><a style=3D"border-bottom: 1px solid orange;" class=3D"autolink auto=
link-ticker-symbol" title=3D"Link added by Stock Chart AutoLink filter: Tic=
ker Symbol" href=3D"http://stockcharts.com/def/servlet/SC.web?c=3DWHERE">
WHERE</a></span> %s -- ("where")<br> =
<span><a style=3D"border-bottom: 1px solid orange;" class=3D"autolink aut=
olink-ticker-symbol" title=3D"Link added by Stock Chart AutoLink filter: Ti=
cker Symbol" href=3D"http://stockcharts.com/def/servlet/SC.web?c=3DGROUP">
GROUP</a></span> <span><a style=3D"border-bottom: 1px solid orange;" class=
=3D"autolink autolink-ticker-symbol" title=3D"Link added by Stock Chart Aut=
oLink filter: Ticker Symbol" href=3D"http://stockcharts.com/def/servlet/SC.=
web?c=3DBY">
BY</a></span> __ESSENTIAL(me)__<br> %s %s =
-- ("limit" and "order_by")</pre>
</dd><dd>
<p>Then in your application code:</p>
</dd><dd>
<pre> my ($pager, $iterator) =3D MyDB::Artist->page(<br> {<br>=
'cds.title' =3D> { '!=3D', undef },<br> },<br> =
{<br> sql_method =3D> 'count_by_cd',<br> =
statement_order =3D> [qw/ from where limit order_by / ],
<br> disable_sql_paging =3D> 1,<br> order_by =
=3D> 'cd_count desc',<br> rows =3D> =
10,<br> page =3D> 1,<br> } );</pre>
</dd></dl>How do you use $pager and $iterator to loop through results?<br><=
br>TIA.<br clear=3D"all"><br>-- <br>Dave Mabe<br><a href=3D"http://www.stoc=
ktickr.com">http://www.stocktickr.com</a><br><br>My New Book: BlackBerry Ha=
cks
<br><a href=3D"http://www.amazon.com/exec/obidos/tg/detail/-/0596101155/run=
ningwatch">http://www.amazon.com/exec/obidos/tg/detail/-/0596101155/running=
watch</a>
------=_Part_11055_20986491.1139748083725--
--===============1391852043==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
--===============1391852043==--
|
[CDBI] Paging through Results using Class::DBI::Sweet
|
|
Re: [CDBI] Paging through Results using Class::DBI::Sweet
|
Generated at 10:41 on 18 Feb 2006 by mariachi v0.52