packaging one directory
|
1 |
package DBIx::Custom::Result; |
updatedd pod
|
2 |
use Object::Simple -base; |
cleanup
|
3 | |
packaging one directory
|
4 |
use Carp 'croak'; |
cleanup
|
5 |
use DBIx::Custom::Util qw/_array_to_hash _subname/; |
packaging one directory
|
6 | |
sub module use DBIx::Custom ...
|
7 |
has [qw/dbi sth/], |
cleanup
|
8 |
stash => sub { {} }; |
cleanup
|
9 | |
- added DBIx::Custom::Result...
|
10 |
*all = \&fetch_hash_all; |
11 | ||
- added EXPERIMENTAL DBIx::C...
|
12 |
sub column { |
cleanup
|
13 |
my $self = shift; |
14 |
|
|
15 |
my $column = []; |
|
16 |
my $rows = $self->fetch_all; |
|
17 |
push @$column, $_->[0] for @$rows; |
|
18 |
return $column; |
|
- added EXPERIMENTAL DBIx::C...
|
19 |
} |
20 | ||
cleanup
|
21 |
sub filter { |
cleanup
|
22 |
my $self = shift; |
23 |
|
|
24 |
# Set |
|
25 |
if (@_) { |
|
26 |
|
|
27 |
# Convert filter name to subroutine |
|
28 |
my $filter = @_ == 1 ? $_[0] : [@_]; |
|
29 |
$filter = _array_to_hash($filter); |
|
30 |
for my $column (keys %$filter) { |
|
31 |
my $fname = $filter->{$column}; |
|
32 |
if (exists $filter->{$column} |
|
33 |
&& defined $fname |
|
34 |
&& ref $fname ne 'CODE') |
|
35 |
{ |
|
36 |
croak qq{Filter "$fname" is not registered" } . _subname |
|
37 |
unless exists $self->dbi->filters->{$fname}; |
|
38 |
$filter->{$column} = $self->dbi->filters->{$fname}; |
|
39 |
} |
|
cleanup
|
40 |
} |
41 |
|
|
cleanup
|
42 |
# Merge |
43 |
$self->{filter} = {%{$self->filter}, %$filter}; |
|
44 |
|
|
45 |
return $self; |
|
46 |
} |
|
47 |
|
|
48 |
return $self->{filter} ||= {}; |
|
added experimental DBIx::Cus...
|
49 |
} |
50 | ||
micro optimization
|
51 |
sub fetch { |
cleanup
|
52 |
my $self = shift; |
53 |
|
|
54 |
# Info |
|
55 |
$self->_cache unless $self->{_cache}; |
|
56 |
|
|
57 |
# Fetch |
|
58 |
my @row = $self->{sth}->fetchrow_array; |
|
59 |
return unless @row; |
|
60 |
|
|
61 |
# Type rule |
|
62 |
if ($self->{type_rule}->{from1} && !$self->{type_rule_off} && !$self->{type_rule1_off}) { |
|
63 |
my $from = $self->{type_rule}->{from1}; |
|
64 |
for my $type (keys %$from) { |
|
65 |
for my $column (@{$self->{_type_map}->{$type}}) { |
|
66 |
$row[$_] = $from->{$type}->($row[$_]) |
|
67 |
for @{$self->{_pos}{$column} || []}; |
|
68 |
} |
|
micro optimization
|
69 |
} |
cleanup
|
70 |
} |
71 |
if ($self->{type_rule}->{from2} && !$self->{type_rule_off} && !$self->{type_rule2_off}) { |
|
72 |
my $from = $self->{type_rule}->{from2}; |
|
73 |
for my $type (keys %$from) { |
|
74 |
for my $column (@{$self->{_type_map}->{$type}}) { |
|
75 |
$row[$_] = $from->{$type}->($row[$_]) |
|
76 |
for @{$self->{_pos}{$column} || []}; |
|
77 |
} |
|
micro optimization
|
78 |
} |
cleanup
|
79 |
} |
80 |
|
|
81 |
# Filter |
|
82 |
if (($self->{filter} || $self->{default_filter}) && !$self->{filter_off}) { |
|
83 |
my @columns = $self->{default_filter} ? keys %{$self->{_columns}} |
|
84 |
: keys %{$self->{filter}}; |
|
85 |
|
|
86 |
for my $column (@columns) { |
|
87 |
my $filter = exists $self->{filter}->{$column} ? $self->{filter}->{$column} |
|
88 |
: $self->{default_filter}; |
|
89 |
next unless $filter; |
|
90 |
$row[$_] = $filter->($row[$_]) |
|
91 |
for @{$self->{_pos}{$column} || []}; |
|
92 |
} |
|
93 |
} |
|
94 |
if ($self->{end_filter} && !$self->{filter_off}) { |
|
95 |
for my $column (keys %{$self->{end_filter}}) { |
|
96 |
next unless $self->{end_filter}->{$column}; |
|
97 |
$row[$_] = $self->{end_filter}->{$column}->($row[$_]) |
|
98 |
for @{$self->{_pos}{$column} || []}; |
|
99 |
} |
|
100 |
} |
|
101 | ||
102 |
return \@row; |
|
micro optimization
|
103 |
} |
104 | ||
105 |
sub fetch_hash { |
|
cleanup
|
106 |
my $self = shift; |
107 |
|
|
108 |
# Info |
|
109 |
$self->_cache unless $self->{_cache}; |
|
110 |
|
|
111 |
# Fetch |
|
112 |
return unless my $row = $self->{sth}->fetchrow_hashref; |
|
113 |
|
|
114 |
# Type rule |
|
115 |
if ($self->{type_rule}->{from1} && |
|
116 |
!$self->{type_rule_off} && !$self->{type_rule1_off}) |
|
117 |
{ |
|
118 |
my $from = $self->{type_rule}->{from1}; |
|
119 |
for my $type (keys %$from) { |
|
120 |
$from->{$type} and $row->{$_} = $from->{$type}->($row->{$_}) |
|
121 |
for @{$self->{_type_map}->{$type}}; |
|
micro optimization
|
122 |
} |
cleanup
|
123 |
} |
124 |
if ($self->{type_rule}->{from2} && |
|
125 |
!$self->{type_rule_off} && !$self->{type_rule2_off}) |
|
126 |
{ |
|
127 |
my $from = $self->{type_rule}->{from2}; |
|
128 |
for my $type (keys %{$self->{type_rule}->{from2}}) { |
|
129 |
$from->{$type} and $row->{$_} = $from->{$type}->($row->{$_}) |
|
130 |
for @{$self->{_type_map}->{$type}}; |
|
micro optimization
|
131 |
} |
cleanup
|
132 |
} |
133 |
# Filter |
|
134 |
if (($self->{filter} || $self->{default_filter}) && |
|
135 |
!$self->{filter_off}) |
|
136 |
{ |
|
137 |
my @columns = $self->{default_filter} ? keys %{$self->{_columns}} |
|
138 |
: keys %{$self->{filter}}; |
|
139 |
|
|
140 |
for my $column (@columns) { |
|
141 |
next unless exists $row->{$column}; |
|
142 |
my $filter = exists $self->{filter}->{$column} ? $self->{filter}->{$column} |
|
143 |
: $self->{default_filter}; |
|
144 |
$row->{$column} = $filter->($row->{$column}) if $filter; |
|
145 |
} |
|
146 |
} |
|
147 |
if ($self->{end_filter} && !$self->{filter_off}) { |
|
148 |
exists $self->{_columns}{$_} && $self->{end_filter}->{$_} and |
|
149 |
$row->{$_} = $self->{end_filter}->{$_}->($row->{$_}) |
|
150 |
for keys %{$self->{end_filter}}; |
|
151 |
} |
|
152 |
$row; |
|
micro optimization
|
153 |
} |
154 | ||
cleanup
|
155 |
sub fetch_all { |
cleanup
|
156 |
my $self = shift; |
157 |
|
|
158 |
# Fetch all rows |
|
159 |
my $rows = []; |
|
160 |
while(my $row = $self->fetch) { push @$rows, $row} |
|
161 |
|
|
162 |
return $rows; |
|
cleanup
|
163 |
} |
164 | ||
165 |
sub fetch_hash_all { |
|
cleanup
|
166 |
my $self = shift; |
167 |
|
|
168 |
# Fetch all rows as hash |
|
169 |
my $rows = []; |
|
170 |
while(my $row = $self->fetch_hash) { push @$rows, $row } |
|
171 |
|
|
172 |
return $rows; |
|
cleanup
|
173 |
} |
174 | ||
- renamed DBIx::Custom::Resu...
|
175 |
sub fetch_hash_one { |
cleanup
|
176 |
my $self = shift; |
177 |
|
|
178 |
# Fetch hash |
|
179 |
my $row = $self->fetch_hash; |
|
180 |
return unless $row; |
|
181 |
|
|
182 |
# Finish statement handle |
|
183 |
$self->sth->finish; |
|
184 |
|
|
185 |
return $row; |
|
packaging one directory
|
186 |
} |
187 | ||
renamed fetch_rows to fetch_...
|
188 |
sub fetch_hash_multi { |
cleanup
|
189 |
my ($self, $count) = @_; |
190 |
|
|
191 |
# Fetch multiple rows |
|
192 |
croak 'Row count must be specified ' . _subname |
|
193 |
unless $count; |
|
194 |
|
|
195 |
return if $self->{_finished}; |
|
196 | ||
197 |
my $rows = []; |
|
198 |
for (my $i = 0; $i < $count; $i++) { |
|
199 |
my $row = $self->fetch_hash; |
|
200 |
unless ($row) { |
|
201 |
$self->{_finished} = 1; |
|
202 |
last; |
|
packaging one directory
|
203 |
} |
cleanup
|
204 |
push @$rows, $row; |
205 |
} |
|
206 |
|
|
207 |
return unless @$rows; |
|
208 |
return $rows; |
|
packaging one directory
|
209 |
} |
210 | ||
cleanup
|
211 |
sub fetch_multi { |
cleanup
|
212 |
my ($self, $count) = @_; |
213 |
|
|
214 |
# Row count not specifed |
|
215 |
croak 'Row count must be specified ' . _subname |
|
216 |
unless $count; |
|
217 |
|
|
218 |
return if $self->{_finished}; |
|
219 |
|
|
220 |
# Fetch multi rows |
|
221 |
my $rows = []; |
|
222 |
for (my $i = 0; $i < $count; $i++) { |
|
223 |
my $row = $self->fetch; |
|
224 |
unless ($row) { |
|
225 |
$self->{_finished} = 1; |
|
226 |
last; |
|
packaging one directory
|
227 |
} |
cleanup
|
228 |
push @$rows, $row; |
229 |
} |
|
230 |
|
|
231 |
return unless @$rows; |
|
232 |
return $rows; |
|
packaging one directory
|
233 |
} |
234 | ||
- renamed DBIx::Custom::Resu...
|
235 | |
236 |
sub fetch_one { |
|
cleanup
|
237 |
my $self = shift; |
238 |
|
|
239 |
# Fetch |
|
240 |
my $row = $self->fetch; |
|
241 |
return unless $row; |
|
242 |
|
|
243 |
# Finish statement handle |
|
244 |
$self->sth->finish; |
|
245 |
|
|
246 |
return $row; |
|
- renamed DBIx::Custom::Resu...
|
247 |
} |
248 | ||
added EXPERIMENTAL DBIx::Cus...
|
249 |
sub header { shift->sth->{NAME} } |
250 | ||
- renamed DBIx::Custom::Resu...
|
251 |
*one = \&fetch_hash_one; |
- added DBIx::Custom::Result...
|
252 | |
added EXPERIMENTAL DBIx::Cus...
|
253 |
sub type_rule { |
cleanup
|
254 |
my $self = shift; |
255 |
|
|
256 |
if (@_) { |
|
257 |
my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_}; |
|
258 | ||
259 |
# From |
|
260 |
for my $i (1 .. 2) { |
|
261 |
$type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"}); |
|
262 |
for my $data_type (keys %{$type_rule->{"from$i"} || {}}) { |
|
263 |
croak qq{data type of from$i section must be lower case or number} |
|
264 |
if $data_type =~ /[A-Z]/; |
|
265 |
my $fname = $type_rule->{"from$i"}{$data_type}; |
|
266 |
if (defined $fname && ref $fname ne 'CODE') { |
|
267 |
croak qq{Filter "$fname" is not registered" } . _subname |
|
268 |
unless exists $self->dbi->filters->{$fname}; |
|
269 |
|
|
270 |
$type_rule->{"from$i"}{$data_type} = $self->dbi->filters->{$fname}; |
|
added EXPERIMENTAL DBIx::Cus...
|
271 |
} |
cleanup
|
272 |
} |
added EXPERIMENTAL DBIx::Cus...
|
273 |
} |
cleanup
|
274 |
$self->{type_rule} = $type_rule; |
added EXPERIMENTAL DBIx::Cus...
|
275 |
|
cleanup
|
276 |
return $self; |
277 |
} |
|
278 |
|
|
279 |
return $self->{type_rule} || {}; |
|
added EXPERIMENTAL DBIx::Cus...
|
280 |
} |
281 | ||
- changed EXPERIMENTAL DBIx:...
|
282 |
sub type_rule_off { |
cleanup
|
283 |
my $self = shift; |
284 |
$self->{type_rule_off} = 1; |
|
285 |
return $self; |
|
- changed EXPERIMENTAL DBIx:...
|
286 |
} |
287 | ||
288 |
sub type_rule_on { |
|
cleanup
|
289 |
my $self = shift; |
290 |
$self->{type_rule_off} = 0; |
|
291 |
return $self; |
|
- changed EXPERIMENTAL DBIx:...
|
292 |
} |
293 | ||
294 |
sub type_rule1_off { |
|
cleanup
|
295 |
my $self = shift; |
296 |
$self->{type_rule1_off} = 1; |
|
297 |
return $self; |
|
- changed EXPERIMENTAL DBIx:...
|
298 |
} |
299 | ||
300 |
sub type_rule1_on { |
|
cleanup
|
301 |
my $self = shift; |
302 |
$self->{type_rule1_off} = 0; |
|
303 |
return $self; |
|
- changed EXPERIMENTAL DBIx:...
|
304 |
} |
305 | ||
306 |
sub type_rule2_off { |
|
cleanup
|
307 |
my $self = shift; |
308 |
$self->{type_rule2_off} = 1; |
|
309 |
return $self; |
|
- changed EXPERIMENTAL DBIx:...
|
310 |
} |
311 | ||
312 |
sub type_rule2_on { |
|
cleanup
|
313 |
my $self = shift; |
314 |
$self->{type_rule2_off} = 0; |
|
315 |
return $self; |
|
- changed EXPERIMENTAL DBIx:...
|
316 |
} |
317 | ||
- added EXPERIMENTAL DBIx::C...
|
318 |
sub value { |
cleanup
|
319 |
my $self = shift; |
320 |
my $row = $self->fetch_one; |
|
321 |
my $value = $row ? $row->[0] : undef; |
|
322 |
return $value; |
|
- added EXPERIMENTAL DBIx::C...
|
323 |
} |
324 | ||
- fixed bug DBIx::Custom::Re...
|
325 |
sub _cache { |
cleanup
|
326 |
my $self = shift; |
327 |
$self->{_type_map} = {}; |
|
328 |
$self->{_pos} = {}; |
|
329 |
$self->{_columns} = {}; |
|
330 |
for (my $i = 0; $i < @{$self->{sth}->{NAME}}; $i++) { |
|
331 |
my $type = lc $self->{sth}{TYPE}[$i]; |
|
332 |
my $name = $self->{sth}{NAME}[$i]; |
|
333 |
$self->{_type_map}{$type} ||= []; |
|
334 |
push @{$self->{_type_map}{$type}}, $name; |
|
335 |
$self->{_pos}{$name} ||= []; |
|
336 |
push @{$self->{_pos}{$name}}, $i; |
|
337 |
$self->{_columns}{$name} = 1; |
|
338 |
} |
|
339 |
$self->{_cache} = 1; |
|
- fixed bug DBIx::Custom::Re...
|
340 |
} |
341 | ||
- renamed DBIx::Custom::Resu...
|
342 |
# DEPRECATED! |
343 |
sub fetch_hash_first { |
|
cleanup
|
344 |
my $self = shift; |
345 |
warn "DBIx::Custom::Result::fetch_hash_first is DEPRECATED! use fetch_hash_one instead"; |
|
346 |
return $self->fetch_hash_one(@_); |
|
- renamed DBIx::Custom::Resu...
|
347 |
} |
348 | ||
349 |
# DEPRECATED! |
|
350 |
sub fetch_first { |
|
cleanup
|
351 |
my $self = shift; |
352 |
warn "DBIx::Custom::Result::fetch_first is DEPRECATED! use fetch_one instead"; |
|
353 |
return $self->fetch_one(@_); |
|
- renamed DBIx::Custom::Resu...
|
354 |
} |
355 | ||
- DBIx::Custom::Result filte...
|
356 |
# DEPRECATED! |
357 |
sub filter_off { |
|
cleanup
|
358 |
warn "filter_off method is DEPRECATED!"; |
359 |
my $self = shift; |
|
360 |
$self->{filter_off} = 1; |
|
361 |
return $self; |
|
- DBIx::Custom::Result filte...
|
362 |
} |
363 | ||
364 |
# DEPRECATED! |
|
365 |
sub filter_on { |
|
cleanup
|
366 |
warn "filter_on method is DEPRECATED!"; |
367 |
my $self = shift; |
|
368 |
$self->{filter_off} = 0; |
|
369 |
return $self; |
|
- DBIx::Custom::Result filte...
|
370 |
} |
371 | ||
cleanup
|
372 |
# DEPRECATED! |
373 |
sub end_filter { |
|
cleanup
|
374 |
warn "end_filter method is DEPRECATED!"; |
375 |
my $self = shift; |
|
376 |
if (@_) { |
|
377 |
my $end_filter = {}; |
|
378 |
if (ref $_[0] eq 'HASH') { $end_filter = $_[0] } |
|
379 |
else { |
|
380 |
$end_filter = _array_to_hash( |
|
381 |
@_ > 1 ? [@_] : $_[0] |
|
382 |
); |
|
383 |
} |
|
384 |
for my $column (keys %$end_filter) { |
|
385 |
my $fname = $end_filter->{$column}; |
|
386 |
if (exists $end_filter->{$column} |
|
387 |
&& defined $fname |
|
388 |
&& ref $fname ne 'CODE') |
|
389 |
{ |
|
390 |
croak qq{Filter "$fname" is not registered" } . _subname |
|
391 |
unless exists $self->dbi->filters->{$fname}; |
|
392 |
$end_filter->{$column} = $self->dbi->filters->{$fname}; |
|
393 |
} |
|
cleanup
|
394 |
} |
cleanup
|
395 |
$self->{end_filter} = {%{$self->end_filter}, %$end_filter}; |
396 |
return $self; |
|
397 |
} |
|
398 |
return $self->{end_filter} ||= {}; |
|
cleanup
|
399 |
} |
cleanup
|
400 |
# DEPRECATED! |
added experimental DBIx::Cus...
|
401 |
sub remove_end_filter { |
cleanup
|
402 |
warn "remove_end_filter is DEPRECATED!"; |
403 |
my $self = shift; |
|
404 |
$self->{end_filter} = {}; |
|
405 |
return $self; |
|
added experimental DBIx::Cus...
|
406 |
} |
cleanup
|
407 |
# DEPRECATED! |
added experimental DBIx::Cus...
|
408 |
sub remove_filter { |
cleanup
|
409 |
warn "remove_filter is DEPRECATED!"; |
410 |
my $self = shift; |
|
411 |
$self->{filter} = {}; |
|
412 |
return $self; |
|
added experimental DBIx::Cus...
|
413 |
} |
cleanup
|
414 |
# DEPRECATED! |
cleanup
|
415 |
sub default_filter { |
cleanup
|
416 |
warn "default_filter is DEPRECATED!"; |
417 |
my $self = shift; |
|
418 |
if (@_) { |
|
419 |
my $fname = $_[0]; |
|
420 |
if (@_ && !$fname) { |
|
421 |
$self->{default_filter} = undef; |
|
cleanup
|
422 |
} |
cleanup
|
423 |
else { |
424 |
croak qq{Filter "$fname" is not registered} |
|
425 |
unless exists $self->dbi->filters->{$fname}; |
|
426 |
$self->{default_filter} = $self->dbi->filters->{$fname}; |
|
427 |
} |
|
428 |
return $self; |
|
429 |
} |
|
430 |
return $self->{default_filter}; |
|
cleanup
|
431 |
} |
cleanup
|
432 |
# DEPRECATED! |
cleanup
|
433 |
has 'filter_check'; |
cleanup
|
434 | |
update document
|
435 |
1; |
436 | ||
packaging one directory
|
437 |
=head1 NAME |
438 | ||
cleanup
|
439 |
DBIx::Custom::Result - Result of select statement |
packaging one directory
|
440 | |
update document
|
441 |
=head1 SYNOPSIS |
cleanup
|
442 | |
cleanup
|
443 |
# Result |
444 |
my $result = $dbi->select(table => 'book'); |
|
445 | ||
446 |
# Fetch a row and put it into array reference |
|
447 |
while (my $row = $result->fetch) { |
|
448 |
my $author = $row->[0]; |
|
449 |
my $title = $row->[1]; |
|
450 |
} |
|
451 |
|
|
452 |
# Fetch only a first row and put it into array reference |
|
453 |
my $row = $result->fetch_one; |
|
454 |
|
|
455 |
# Fetch all rows and put them into array of array reference |
|
456 |
my $rows = $result->fetch_all; |
|
457 | ||
458 |
# Fetch a row and put it into hash reference |
|
459 |
while (my $row = $result->fetch_hash) { |
|
460 |
my $title = $row->{title}; |
|
461 |
my $author = $row->{author}; |
|
462 |
} |
|
463 |
|
|
464 |
# Fetch only a first row and put it into hash reference |
|
465 |
my $row = $result->fetch_hash_one; |
|
466 |
my $row = $result->one; # Alias for "fetch_hash_one" |
|
467 |
|
|
468 |
# Fetch all rows and put them into array of hash reference |
|
469 |
my $rows = $result->fetch_hash_all; |
|
470 |
my $rows = $result->all; # Alias for "fetch_hash_all" |
|
packaging one directory
|
471 | |
update document
|
472 |
=head1 ATTRIBUTES |
packaging one directory
|
473 | |
sub module use DBIx::Custom ...
|
474 |
=head2 C<dbi> |
cleanup
|
475 | |
cleanup
|
476 |
my $dbi = $result->dbi; |
477 |
$result = $result->dbi($dbi); |
|
cleanup
|
478 | |
sub module use DBIx::Custom ...
|
479 |
L<DBIx::Custom> object. |
cleanup
|
480 | |
481 |
=head2 C<sth> |
|
482 | ||
cleanup
|
483 |
my $sth = $reuslt->sth |
484 |
$result = $result->sth($sth); |
|
cleanup
|
485 | |
486 |
Statement handle of L<DBI>. |
|
487 | ||
update document
|
488 |
=head1 METHODS |
489 | ||
renamed build_query to creat...
|
490 |
L<DBIx::Custom::Result> inherits all methods from L<Object::Simple> |
cleanup
|
491 |
and implements the following new ones. |
packaging one directory
|
492 | |
updated pod
|
493 |
=head2 C<all> |
494 | ||
cleanup
|
495 |
my $rows = $result->all; |
updated pod
|
496 | |
cleanup
|
497 |
Same as C<fetch_hash_all>. |
updated pod
|
498 | |
- added EXPERIMENTAL DBIx::C...
|
499 |
=head2 C<column> EXPERIMENTAL |
500 | ||
cleanup
|
501 |
my $column = $result->column; |
- added EXPERIMENTAL DBIx::C...
|
502 | |
503 |
Get first column's all values. |
|
504 | ||
cleanup
|
505 |
my $names = $dbi->select('name', table => 'book')->column; |
- added EXPERIMENTAL DBIx::C...
|
506 | |
removed DBIx::Custom commit ...
|
507 |
=head2 C<fetch> |
packaging one directory
|
508 | |
cleanup
|
509 |
my $row = $result->fetch; |
version 0.0901
|
510 | |
cleanup
|
511 |
Fetch a row and put it into array reference. |
packaging one directory
|
512 | |
removed DBIx::Custom commit ...
|
513 |
=head2 C<fetch_all> |
packaging one directory
|
514 | |
cleanup
|
515 |
my $rows = $result->fetch_all; |
version 0.0901
|
516 | |
cleanup
|
517 |
Fetch all rows and put them into array of array reference. |
packaging one directory
|
518 | |
- renamed DBIx::Custom::Resu...
|
519 |
=head2 C<fetch_one> |
cleanup
|
520 | |
cleanup
|
521 |
my $row = $result->fetch_one; |
cleanup
|
522 | |
cleanup
|
523 |
Fetch only a first row and put it into array reference, |
524 |
and finish statment handle. |
|
cleanup
|
525 | |
removed DESTROY method(not b...
|
526 |
=head2 C<fetch_hash> |
packaging one directory
|
527 | |
cleanup
|
528 |
my $row = $result->fetch_hash; |
packaging one directory
|
529 | |
cleanup
|
530 |
Fetch a row and put it into hash reference. |
update document
|
531 | |
cleanup
|
532 |
=head2 C<fetch_hash_all> |
533 | ||
cleanup
|
534 |
my $rows = $result->fetch_hash_all; |
cleanup
|
535 | |
cleanup
|
536 |
Fetch all rows and put them into array of hash reference. |
cleanup
|
537 | |
- renamed DBIx::Custom::Resu...
|
538 |
=head2 C<fetch_hash_one> |
cleanup
|
539 |
|
540 |
my $row = $result->fetch_hash_one; |
|
packaging one directory
|
541 | |
cleanup
|
542 |
Fetch only a first row and put it into hash reference, |
543 |
and finish statment handle. |
|
packaging one directory
|
544 | |
removed DESTROY method(not b...
|
545 |
=head2 C<fetch_hash_multi> |
update document
|
546 | |
cleanup
|
547 |
my $rows = $result->fetch_hash_multi(5); |
548 |
|
|
cleanup
|
549 |
Fetch multiple rows and put them into array of hash reference. |
update document
|
550 | |
cleanup
|
551 |
=head2 C<fetch_multi> |
packaging one directory
|
552 | |
cleanup
|
553 |
my $rows = $result->fetch_multi(5); |
554 |
|
|
cleanup
|
555 |
Fetch multiple rows and put them into array of array reference. |
removed DESTROY method(not b...
|
556 | |
cleanup
|
557 |
=head2 C<filter> |
558 | ||
cleanup
|
559 |
$result->filter(title => sub { uc $_[0] }, author => 'to_upper'); |
560 |
$result->filter([qw/title author/] => 'to_upper'); |
|
added experimental DBIx::Cus...
|
561 | |
cleanup
|
562 |
Set filter for column. |
563 |
You can use subroutine or filter name as filter. |
|
- DBIx::Custom Model filter ...
|
564 |
This filter is executed after C<type_rule> filter. |
cleanup
|
565 | |
- removed EXPERIMENTAL statu...
|
566 |
=head2 C<header> |
added EXPERIMENTAL DBIx::Cus...
|
567 | |
cleanup
|
568 |
my $header = $result->header; |
added EXPERIMENTAL DBIx::Cus...
|
569 | |
570 |
Get header column names. |
|
571 | ||
updated pod
|
572 |
=head2 C<one> |
573 | ||
cleanup
|
574 |
my $row = $result->one; |
updated pod
|
575 | |
- renamed DBIx::Custom::Resu...
|
576 |
Alias for C<fetch_hash_one>. |
added experimental DBIx::Cus...
|
577 | |
- removed DEPRECATED DBIx::C...
|
578 |
=head2 C<stash> |
added experimental DBIx::Cus...
|
579 | |
cleanup
|
580 |
my $stash = $result->stash; |
581 |
my $foo = $result->stash->{foo}; |
|
582 |
$result->stash->{foo} = $foo; |
|
added experimental DBIx::Cus...
|
583 | |
- added EXPERIMENTAL DBIx::C...
|
584 |
Stash is hash reference to save some data. |
added experimental DBIx::Cus...
|
585 | |
- removed EXPERIMENTAL flag ...
|
586 |
=head2 C<type_rule> |
cleanup
|
587 |
|
588 |
# Merge type rule |
|
589 |
$result->type_rule( |
|
590 |
# DATE |
|
591 |
9 => sub { ... }, |
|
592 |
# DATETIME or TIMESTAMP |
|
593 |
11 => sub { ... } |
|
594 |
); |
|
595 | ||
596 |
# Replace type rule(by reference) |
|
597 |
$result->type_rule([ |
|
598 |
# DATE |
|
599 |
9 => sub { ... }, |
|
600 |
# DATETIME or TIMESTAMP |
|
601 |
11 => sub { ... } |
|
602 |
]); |
|
EXPERIMENTAL type_rule_off i...
|
603 | |
cleanup
|
604 |
This is same as L<DBIx::Custom>'s C<type_rule>'s <from>. |
EXPERIMENTAL type_rule_off i...
|
605 | |
- removed EXPERIMENTAL flag ...
|
606 |
=head2 C<type_rule_off> |
- changed EXPERIMENTAL DBIx:...
|
607 | |
cleanup
|
608 |
$result = $result->type_rule_off; |
- changed EXPERIMENTAL DBIx:...
|
609 | |
610 |
Turn C<from1> and C<from2> type rule off. |
|
611 |
By default, type rule is on. |
|
612 | ||
- removed EXPERIMENTAL flag ...
|
613 |
=head2 C<type_rule_on> |
- changed EXPERIMENTAL DBIx:...
|
614 | |
cleanup
|
615 |
$result = $result->type_rule_on; |
- changed EXPERIMENTAL DBIx:...
|
616 | |
617 |
Turn C<from1> and C<from2> type rule on. |
|
618 |
By default, type rule is on. |
|
619 | ||
- removed EXPERIMENTAL flag ...
|
620 |
=head2 C<type_rule1_off> |
- changed EXPERIMENTAL DBIx:...
|
621 | |
cleanup
|
622 |
$result = $result->type_rule1_off; |
- changed EXPERIMENTAL DBIx:...
|
623 | |
624 |
Turn C<from1> type rule off. |
|
625 |
By default, type rule is on. |
|
626 | ||
- removed EXPERIMENTAL flag ...
|
627 |
=head2 C<type_rule1_on> |
- changed EXPERIMENTAL DBIx:...
|
628 | |
cleanup
|
629 |
$result = $result->type_rule1_on; |
- changed EXPERIMENTAL DBIx:...
|
630 | |
631 |
Turn C<from1> type rule on. |
|
632 |
By default, type rule is on. |
|
633 | ||
- removed EXPERIMENTAL flag ...
|
634 |
=head2 C<type_rule2_off> |
- changed EXPERIMENTAL DBIx:...
|
635 | |
cleanup
|
636 |
$result = $result->type_rule2_off; |
- changed EXPERIMENTAL DBIx:...
|
637 | |
638 |
Turn C<from2> type rule off. |
|
639 |
By default, type rule is on. |
|
640 | ||
- removed EXPERIMENTAL flag ...
|
641 |
=head2 C<type_rule2_on> |
- changed EXPERIMENTAL DBIx:...
|
642 | |
cleanup
|
643 |
$result = $result->type_rule2_on; |
- changed EXPERIMENTAL DBIx:...
|
644 | |
645 |
Turn C<from2> type rule on. |
|
646 |
By default, type rule is on. |
|
647 | ||
- added EXPERIMENTAL DBIx::C...
|
648 |
=head2 C<value> EXPERIMENTAL |
649 | ||
cleanup
|
650 |
my $value = $result->value; |
- added EXPERIMENTAL DBIx::C...
|
651 | |
652 |
Get first column's first value. |
|
653 | ||
cleanup
|
654 |
my $count = $dbi->select('count(*)')->value; |
- added EXPERIMENTAL DBIx::C...
|
655 | |
packaging one directory
|
656 |
=cut |