Hatena::Groupcatalyst

LAPISLAZULI HILL#Catalyst このページをアンテナに追加 RSSフィード

2006-10-25

[]DBIx::Class::ResultSetでのpaging DBIx::Class::ResultSetでのpaging - LAPISLAZULI HILL#Catalyst を含むブックマーク はてなブックマーク - DBIx::Class::ResultSetでのpaging - LAPISLAZULI HILL#Catalyst DBIx::Class::ResultSetでのpaging - LAPISLAZULI HILL#Catalyst のブックマークコメント

my $schema = Hoge::Schema->connect(~);
my $rs = $schema->resultset('hoge')->search({}, { page => 1, rows => 10});

print "         First page: ", $rs->pager->first_page, "\n";
print "          Last page: ", $rs->pager->last_page, "\n";
print "First entry on page: ", $rs->pager->first, "\n";
print " Last entry on page: ", $rs->pager->last, "\n";

Catalyst::Model::DBIC::Schemaだと

$c->stash->{data} = $c->model('DBIC::Hoge')->search({}, { page => 1, rows => 10});

としておいて,TTで

<ul>
<li>         First page: [% data.pager.first_page %]</li>
<li>          Last page: [% data.pager.last_page %]</li>
<li>First entry on page: [% data.pager.first %]</li>
<li> Last entry on page: [% data.pager.last %]</li>
</ul>

とかすればできた.

ちなみにClass::DBI::Sweetではこんな感じ

my ($page, $data) =  CDBI::hoge->page(
    {}, { rows => 10, page => 1 }
)

print "         First page: ", $page->first_page, "\n";
print "          Last page: ", $page->last_page, "\n";
print "First entry on page: ", $page->first, "\n";
print " Last entry on page: ", $page->last, "\n";
トラックバック - http://catalyst.g.hatena.ne.jp/lapis25/20061025