1DBIx::Class::ResultSetCUosleurmnC(o3n)tributed Perl DocuDmBeInxt:a:tCiloanss::ResultSetColumn(3)
2
3
4

NAME

6         DBIx::Class::ResultSetColumn - helpful methods for messing
7         with a single column of the resultset
8

SYNOPSIS

10         $rs = $schema->resultset('CD')->search({ artist => 'Tool' });
11         $rs_column = $rs->get_column('year');
12         $max_year = $rs_column->max; #returns latest year
13

DESCRIPTION

15       A convenience class used to perform operations on a specific column of
16       a resultset.
17

METHODS

19   new
20         my $obj = DBIx::Class::ResultSetColumn->new($rs, $column);
21
22       Creates a new resultset column object from the resultset and column
23       passed as params. Used internally by "get_column" in
24       DBIx::Class::ResultSet.
25
26   as_query
27       Arguments: none
28       Return Value: \[ $sql, @bind_values ]
29
30       Returns the SQL query and bind vars associated with the invocant.
31
32       This is generally used as the RHS for a subquery.
33
34   next
35       Arguments: none
36       Return Value: $value
37
38       Returns the next value of the column in the resultset (or "undef" if
39       there is none).
40
41       Much like "next" in DBIx::Class::ResultSet but just returning the one
42       value.
43
44   all
45       Arguments: none
46       Return Value: @values
47
48       Returns all values of the column in the resultset (or "undef" if there
49       are none).
50
51       Much like "all" in DBIx::Class::ResultSet but returns values rather
52       than result objects.
53
54   reset
55       Arguments: none
56       Return Value: $self
57
58       Resets the underlying resultset's cursor, so you can iterate through
59       the elements of the column again.
60
61       Much like "reset" in DBIx::Class::ResultSet.
62
63   first
64       Arguments: none
65       Return Value: $value
66
67       Resets the underlying resultset and returns the next value of the
68       column in the resultset (or "undef" if there is none).
69
70       Much like "first" in DBIx::Class::ResultSet but just returning the one
71       value.
72
73   single
74       Arguments: none
75       Return Value: $value
76
77       Much like "single" in DBIx::Class::ResultSet fetches one and only one
78       column value using the cursor directly. If additional rows are present
79       a warning is issued before discarding the cursor.
80
81   min
82       Arguments: none
83       Return Value: $lowest_value
84
85         my $first_year = $year_col->min();
86
87       Wrapper for ->func. Returns the lowest value of the column in the
88       resultset (or "undef" if there are none).
89
90   min_rs
91       Arguments: none
92       Return Value: $resultset
93
94         my $rs = $year_col->min_rs();
95
96       Wrapper for ->func_rs for function MIN().
97
98   max
99       Arguments: none
100       Return Value: $highest_value
101
102         my $last_year = $year_col->max();
103
104       Wrapper for ->func. Returns the highest value of the column in the
105       resultset (or "undef" if there are none).
106
107   max_rs
108       Arguments: none
109       Return Value: $resultset
110
111         my $rs = $year_col->max_rs();
112
113       Wrapper for ->func_rs for function MAX().
114
115   sum
116       Arguments: none
117       Return Value: $sum_of_values
118
119         my $total = $prices_col->sum();
120
121       Wrapper for ->func. Returns the sum of all the values in the column of
122       the resultset. Use on varchar-like columns at your own risk.
123
124   sum_rs
125       Arguments: none
126       Return Value: $resultset
127
128         my $rs = $year_col->sum_rs();
129
130       Wrapper for ->func_rs for function SUM().
131
132   func
133       Arguments: $function
134       Return Value: $function_return_value
135
136         $rs = $schema->resultset("CD")->search({});
137         $length = $rs->get_column('title')->func('LENGTH');
138
139       Runs a query using the function on the column and returns the value.
140       Produces the following SQL:
141
142         SELECT LENGTH( title ) FROM cd me
143
144   func_rs
145       Arguments: $function
146       Return Value: $resultset
147
148       Creates the resultset that func() uses to run its query.
149
150   throw_exception
151       See "throw_exception" in DBIx::Class::Schema for details.
152

FURTHER QUESTIONS?

154       Check the list of additional DBIC resources.
155
157       This module is free software copyright by the DBIx::Class (DBIC)
158       authors. You can redistribute it and/or modify it under the same terms
159       as the DBIx::Class library.
160
161
162
163perl v5.36.0                      2023-01-20   DBIx::Class::ResultSetColumn(3)
Impressum