/[Frey]/trunk/lib/Frey/Collection.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/Collection.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 106 - (show annotations)
Sun Jul 13 12:22:14 2008 UTC (15 years, 9 months ago) by dpavlin
File size: 861 byte(s)
added Frey::Collection role to database models
1 package Frey::Collection;
2 use Moose::Role;
3
4 use Data::Dump qw/dump/;
5
6 sub collection {
7 my ( $class, $limit, $offset ) = @_;
8 my $schema = $class->SchemaClass()->Schema();
9 my $select = $class->SchemaClass()->SQLFactoryClass()->new_select();
10
11 my $table = $class->collection_table;
12
13 warn "## table $table";
14
15 $limit ||= 20;
16 $offset ||= 0;
17
18 my $users_t = $schema->table( $table );
19
20 $select->select( $users_t )
21 ->from( $users_t )
22 # ->where( $message_t->column('message_date'), '>=',
23 # DateTime->today()->subtract( days => 7 )->strftime( '%Y-%m-%d' ) )
24 ->limit( $limit, $offset )
25 ;
26
27 my $dbh = $class->_dbh($select);
28
29 my $sth = $dbh->prepare( $select->sql($dbh) );
30
31 return
32 Fey::Object::Iterator->new(
33 classes => [ $class->meta()->ClassForTable( $users_t ) ],
34 handle => $sth,
35 bind_params => [ $select->bind_params() ],
36 );
37 }
38
39 1;

  ViewVC Help
Powered by ViewVC 1.1.26