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