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