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