Leser: 1
7 Einträge, 1 Seite |
1
2
3
4
5
6
7
my $rs = $schema->resultset('Thread')->search(
{board_id => $board_id},
{
join => qw/posts/,
order_by => 'posts.timestamp DESC',
}
);
1 2 3 4 5 6 7 8
my $rs = $schema->resultset('Posts')->search( # threads. durch den Namen der belongs_to-Beziehung P -> T ersetzen {'threads.board_id' => $board_id}, { prefetch => qw/threads/, order_by => 'timestamp DESC', } );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/usr/bin/perl use strict; use warnings; use Local::DBIC_Schema; my $schema = Local::DBIC_Schema->connect( 'DBI:SQLite:pktm' ); $schema->storage->debug(1); my $thread = $schema->resultset( 'T' )->search( { 'testid' => 1 }, { join => 'Ps', '+select' => 'Ps.timestamp', '+as' => 'timestamp', order_by => 'Ps.timestamp DESC', } )->first; print $thread->get_column( 'timestamp' );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
my $rs = $schema->resultset('Thread')->search(undef,
{
join => 'posts',
select => [qw/subject timestamp/],
'+select' => [
{max => 'timestamp'}
],
'+as' => [qw/tmax/],
order_by => 'timestamp DESC',
group_by => 'me.thread_id',
},
);
foreach my $x ( $rs->all() ) {
say $x->get_column('tmax') . " " . $x->subject();
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14
my $rs = $schema->resultset('Thread')->search(undef, { join => 'posts', select => [qw/subject timestamp/], '+select' => \'MAX(timestamp) as tmax', '+as' => [qw/tmax/], order_by => 'tmax DESC', group_by => 'me.thread_id', }, ); foreach my $x ( $rs->all() ) { say $x->get_column('tmax') . " " . $x->subject(); }
7 Einträge, 1 Seite |