DBIx::C...tColumn(3)
β¨ NAME β¨
Hiii bestie π welcome to the DBIx::C...tColumn(3) page from User Contributed Perl Documentation. This is DBIx::Class::ResultSetColumn β helpful methods for messing with a single column of the resultset. Slay, that's the whole assignment. π
π SYNOPSIS π
Okay so picture this, bestie:
$rs = $schema->resultset('CD')->search({ artist => 'Tool' });
$rs_column = $rs->get_column('year');
$max_year = $rs_column->max; #returns latest year
π DESCRIPTION π
It's a convenience class used to perform operations on a specific column of a resultset. Lowkey iconic for when you only care about one column, fr fr. β¨
π 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. π«Ά
π¦ as_query π¦
- Arguments: none
- Return Value:
\[ $sql, @bind_values ]
Returns the SQL query and bind vars associated with the invocant.
This is generally used as the RHS for a subquery. π§
πΈ next πΈ
- Arguments: none
- Return Value:
$value
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 β
- Arguments: none
- Return Value:
@values
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 result objects. Periodt. π
π reset π
- Arguments: none
- Return Value:
$self
Resets the underlying resultset's cursor, so you can iterate through the elements of the column again.
Much like "reset" in DBIx::Class::ResultSet. π
π first π
- Arguments: none
- Return Value:
$value
Resets the underlying resultset and returns the next value of the column in the resultset (or undef if there is none).
Much like "first" in DBIx::Class::ResultSet but just returning the one value. π«Ά
π§ single π§
- Arguments: none
- Return Value:
$value
Much like "single" in DBIx::Class::ResultSet fetches one and only one column value using the cursor directly.
β οΈ If additional rows are present a warning is issued before discarding the cursor. Not me getting warned mid-fetch π
π min π
- Arguments: none
- Return Value:
$lowest_value
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). π
π¦ min_rs π¦
- Arguments: none
- Return Value:
$resultset
my $rs = $year_col->min_rs();
Wrapper for ->func_rs for function MIN(). π
π max π
- Arguments: none
- Return Value:
$highest_value
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). π₯
π max_rs π
- Arguments: none
- Return Value:
$resultset
my $rs = $year_col->max_rs();
Wrapper for ->func_rs for function MAX(). β¨
π sum π
- Arguments: none
- Return Value:
$sum_of_values
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. Like, that's the actual warning, bestie. π
π§ sum_rs π§
- Arguments: none
- Return Value:
$resultset
my $rs = $year_col->sum_rs();
Wrapper for ->func_rs for function SUM(). π«Ά
β func β
- Arguments:
$function - Return Value:
$function_return_value
$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
πΈ func_rs πΈ
- Arguments:
$function - Return Value:
$resultset
Creates the resultset that func() uses to run its query. π
π throw_exception π
See "throw_exception" in DBIx::Class::Schema for details. π«‘
π¦ FURTHER QUESTIONS? π¦
Check the list of additional DBIC resources. π
π COPYRIGHT AND LICENSE π
This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.
Sign-off: perl v5.42.0 Β· 2025-01-22 Β· DBIx::C...tColumn(3) β bye bestie! π
π
π¦ where this page comes from
- opensuse-leap 16.0: perl-DBIx-Class 0.082844-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms