On Fri, 24 Oct 2008, Howe, Tom (IT) wrote:
I'm trying to do the following
i have a table with 3 columns.... col1, col2 & time
I want to create some methods that I can pass dbix resultsets into that will
generate new tables
the first byMin takes the time field and blanks out the seconds, generating a
new column called 'minutes'
the second method is designed to take the output from the first resultset and
group by the newly formed minutes column.
However it doesnt work - it complains that minutes does not exist.
So its obviously not attempting to generate a nested select for me.
Is there anyway to do this?
sub byMin {
my $rs = shift;
$rs->search ( {} , { select => [ 'col1', 'col2', 'strftime("%H%M:00", time)' ],
as => ['col1', 'col2', 'minutes'] } );
}
sub byMinGrouped {
my $rs = byMin(shift);
$rs->search ( {} , { select => [ 'col1', 'minutes' ], as => ['col1', 'minutes'],
group_by => ['col1', 'minutes'] } );
}
Yes, See DBIx::Class::Manual::FAQ, the section about using "AS" in the
queries.
Next time please create a new email instead of replying to an old one, as
threaded email clients display your new question at the bottom of a long
and possibly ignored thread of another question. Thanks!
Jess
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]