NAME
DBIx::Class::ResultSetColumn - helpful methods for messing
with a single column of the resultset
SYNOPSIS
$rs = $schema->resultset('CD')->search({ artist => 'Tool' });
$rs_column = $rs->get_column('year');
$max_year = $rs_column->max; #returns latest year
DESCRIPTION
A convenience class used to perform operations on a specific column of a resultset.
METHODS
new
my $obj = DBIx::Class::ResultSetColumn->new($rs, $column);
Creates a new resultset column object from the resultset and column passed as params. Used internally by "get_column" in DBIx::Class::ResultSet.
next
Returns the next value of the column in the resultset (or undef
if there is none).
Much like "next" in DBIx::Class::ResultSet but just returning the one value.
all
Returns all values of the column in the resultset (or undef
if there are none).
Much like "all" in DBIx::Class::ResultSet but returns values rather than row objects.
min
my $first_year = $year_col->min();
Wrapper for ->func. Returns the lowest value of the column in the resultset (or undef
if there are none).
max
my $last_year = $year_col->max();
Wrapper for ->func. Returns the highest value of the column in the resultset (or undef
if there are none).
sum
my $total = $prices_col->sum();
Wrapper for ->func. Returns the sum of all the values in the column of the resultset. Use on varchar-like columns at your own risk.
func
$rs = $schema->resultset("CD")->search({});
$length = $rs->get_column('title')->func('LENGTH');
Runs a query using the function on the column and returns the value. Produces the following SQL:
SELECT LENGTH( title ) FROM cd me
AUTHORS
Luke Saunders <luke.saunders@gmail.com>
Jess Robinson
LICENSE
You may distribute this code under the same terms as Perl itself.