Newer Older
488 lines | 12.015kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Result;
updatedd pod
Yuki Kimoto authored on 2011-06-12
2
use Object::Simple -base;
cleanup
yuki-kimoto authored on 2010-02-11
3

            
packaging one directory
yuki-kimoto authored on 2009-11-16
4
use Carp 'croak';
cleanup
Yuki Kimoto authored on 2011-04-25
5
use DBIx::Custom::Util qw/_array_to_hash _subname/;
packaging one directory
yuki-kimoto authored on 2009-11-16
6

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
7
has [qw/filters filter_off sth type_rule_off type_rule1_off type_rule2_off/];
cleanup
Yuki Kimoto authored on 2011-06-15
8
has stash => sub { {} };
cleanup
Yuki Kimoto authored on 2010-12-21
9

            
- added DBIx::Custom::Result...
Yuki Kimoto authored on 2011-06-07
10
*all = \&fetch_hash_all;
11

            
cleanup
Yuki Kimoto authored on 2010-12-21
12
sub filter {
13
    my $self = shift;
cleanup
Yuki Kimoto authored on 2010-12-22
14
    
cleanup
Yuki Kimoto authored on 2011-06-15
15
    # Set
cleanup
Yuki Kimoto authored on 2010-12-22
16
    if (@_) {
17
        
cleanup
Yuki Kimoto authored on 2011-06-15
18
        # Convert filter name to subroutine
19
        my $filter = @_ == 1 ? $_[0] : [@_];
20
        $filter = _array_to_hash($filter);
cleanup
Yuki Kimoto authored on 2010-12-22
21
        foreach my $column (keys %$filter) {
22
            my $fname = $filter->{$column};
fix bug : filter can't over...
Yuki Kimoto authored on 2011-02-09
23
            if  (exists $filter->{$column}
24
              && defined $fname
25
              && ref $fname ne 'CODE') 
26
            {
cleanup
Yuki Kimoto authored on 2011-04-25
27
              croak qq{Filter "$fname" is not registered" } . _subname
cleanup
Yuki Kimoto authored on 2010-12-22
28
                unless exists $self->filters->{$fname};
29
              $filter->{$column} = $self->filters->{$fname};
30
            }
cleanup
Yuki Kimoto authored on 2010-12-21
31
        }
cleanup
Yuki Kimoto authored on 2010-12-22
32
        
cleanup
Yuki Kimoto authored on 2011-06-15
33
        # Merge
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
34
        $self->{filter} = {%{$self->filter}, %$filter};
cleanup
Yuki Kimoto authored on 2010-12-22
35
        
36
        return $self;
cleanup
Yuki Kimoto authored on 2010-12-21
37
    }
38
    
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
39
    return $self->{filter} ||= {};
40
}
41

            
packaging one directory
yuki-kimoto authored on 2009-11-16
42
sub fetch {
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
43
    my $self = shift;
44
    
packaging one directory
yuki-kimoto authored on 2009-11-16
45
    # Fetch
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
46
    my @row = $self->{sth}->fetchrow_array;
update document
yuki-kimoto authored on 2010-05-27
47
    return unless @row;
added check_filter attribute
yuki-kimoto authored on 2010-08-08
48
    
cleanup
yuki-kimoto authored on 2010-08-05
49
    # Filtering
added experimental iterate_a...
Yuki Kimoto authored on 2010-12-22
50
    my $columns = $self->{sth}->{NAME};
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
51
    my $types = $self->{sth}->{TYPE};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
52
    my $type_rule1 = $self->type_rule->{from1} || {};
53
    my $type_rule2 = $self->type_rule->{from2} || {};
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
54
    my $filter = $self->filter;
55
    my $end_filter = $self->end_filter;
cleanup
yuki-kimoto authored on 2010-08-05
56
    for (my $i = 0; $i < @$columns; $i++) {
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
57
        
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
58
        # Column
cleanup
yuki-kimoto authored on 2010-08-05
59
        my $column = $columns->[$i];
some changed
yuki-kimoto authored on 2010-05-02
60
        
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
61
        # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
62
        my $type_filter1 = $type_rule1->{lc($types->[$i])};
63
        $row[$i] = $type_filter1->($row[$i])
64
          if  $type_filter1 && !$self->{type_rule_off}
65
           && !$self->{type_rule1_off};
66
        my $type_filter2 = $type_rule2->{lc($types->[$i])};
67
        $row[$i] = $type_filter2->($row[$i])
68
          if  $type_filter2 && !$self->{type_rule_off}
69
           && !$self->{type_rule2_off};
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
70
        
71
        # Filter
72
        my $filter  = $filter->{$column} || $self->{default_filter};
73
        $row[$i] = $filter->($row[$i])
74
          if $filter && !$self->{filter_off};
75
        $row[$i] = $end_filter->{$column}->($row[$i])
76
          if $end_filter->{$column} && !$self->{filter_off};
packaging one directory
yuki-kimoto authored on 2009-11-16
77
    }
many many changes
yuki-kimoto authored on 2010-04-30
78

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
79
    return \@row;
80
}
81

            
cleanup
yuki-kimoto authored on 2010-10-17
82
sub fetch_all {
83
    my $self = shift;
84
    
85
    # Fetch all rows
86
    my $rows = [];
cleanup
Yuki Kimoto authored on 2011-06-15
87
    while(my $row = $self->fetch) { push @$rows, $row}
88
    
cleanup
yuki-kimoto authored on 2010-10-17
89
    return $rows;
90
}
91

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
92
sub fetch_first {
93
    my $self = shift;
94
    
95
    # Fetch
96
    my $row = $self->fetch;
97
    return unless $row;
98
    
99
    # Finish statement handle
100
    $self->sth->finish;
101
    
102
    return $row;
103
}
104

            
packaging one directory
yuki-kimoto authored on 2009-11-16
105
sub fetch_hash {
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
106
    my $self = shift;
107
    
packaging one directory
yuki-kimoto authored on 2009-11-16
108
    # Fetch
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
109
    my $row = $self->{sth}->fetchrow_arrayref;
packaging one directory
yuki-kimoto authored on 2009-11-16
110
    return unless $row;
added check_filter attribute
yuki-kimoto authored on 2010-08-08
111

            
packaging one directory
yuki-kimoto authored on 2009-11-16
112
    # Filter
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
113
    my $hash_row = {};
114
    my $filter  = $self->filter;
115
    my $end_filter = $self->end_filter || {};
added experimental iterate_a...
Yuki Kimoto authored on 2010-12-22
116
    my $columns = $self->{sth}->{NAME};
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
117
    my $types = $self->{sth}->{TYPE};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
118
    my $type_rule1 = $self->type_rule->{from1} || {};
119
    my $type_rule2 = $self->type_rule->{from2} || {};
cleanup
yuki-kimoto authored on 2010-08-05
120
    for (my $i = 0; $i < @$columns; $i++) {
update document
yuki-kimoto authored on 2010-05-27
121
        
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
122
        # Column
cleanup
yuki-kimoto authored on 2010-08-05
123
        my $column = $columns->[$i];
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
124
        $hash_row->{$column} = $row->[$i];
add query filter error check
yuki-kimoto authored on 2010-05-14
125
        
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
126
        # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
127
        my $type_filter1 = $type_rule1->{lc($types->[$i])};
128
        $hash_row->{$column} = $type_filter1->($hash_row->{$column})
129
        if  !$self->{type_rule_off} && !$self->{type_rule1_off}
130
         && $type_filter1;
131
        my $type_filter2 = $type_rule2->{lc($types->[$i])};
132
        $hash_row->{$column} = $type_filter2->($hash_row->{$column})
133
        if  !$self->{type_rule_off} && !$self->{type_rule2_off}
134
         && $type_filter2;
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
135
        
136
        # Filter
137
        my $f = $filter->{$column} || $self->{default_filter};
138
        $hash_row->{$column} = $f->($hash_row->{$column})
139
          if $f && !$self->{filter_off};
140
        $hash_row->{$column} = $end_filter->{$column}->($hash_row->{$column})
141
          if $end_filter->{$column} && !$self->{filter_off};
packaging one directory
yuki-kimoto authored on 2009-11-16
142
    }
143
    
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
144
    return $hash_row;
packaging one directory
yuki-kimoto authored on 2009-11-16
145
}
146

            
cleanup
yuki-kimoto authored on 2010-10-17
147
sub fetch_hash_all {
148
    my $self = shift;
149
    
150
    # Fetch all rows as hash
151
    my $rows = [];
cleanup
Yuki Kimoto authored on 2011-06-15
152
    while(my $row = $self->fetch_hash) { push @$rows, $row }
cleanup
yuki-kimoto authored on 2010-10-17
153
    
154
    return $rows;
155
}
156

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
157
sub fetch_hash_first {
packaging one directory
yuki-kimoto authored on 2009-11-16
158
    my $self = shift;
159
    
160
    # Fetch hash
161
    my $row = $self->fetch_hash;
162
    return unless $row;
163
    
164
    # Finish statement handle
some changed
yuki-kimoto authored on 2010-05-02
165
    $self->sth->finish;
packaging one directory
yuki-kimoto authored on 2009-11-16
166
    
removed reconnect method
yuki-kimoto authored on 2010-05-28
167
    return $row;
packaging one directory
yuki-kimoto authored on 2009-11-16
168
}
169

            
renamed fetch_rows to fetch_...
yuki-kimoto authored on 2010-05-01
170
sub fetch_hash_multi {
packaging one directory
yuki-kimoto authored on 2009-11-16
171
    my ($self, $count) = @_;
172
    
cleanup
Yuki Kimoto authored on 2011-06-15
173
    # Fetch multiple rows
cleanup
Yuki Kimoto authored on 2011-04-25
174
    croak 'Row count must be specified ' . _subname
packaging one directory
yuki-kimoto authored on 2009-11-16
175
      unless $count;
176
    my $rows = [];
177
    for (my $i = 0; $i < $count; $i++) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
178
        my $row = $self->fetch_hash;
179
        last unless $row;
180
        push @$rows, $row;
packaging one directory
yuki-kimoto authored on 2009-11-16
181
    }
182
    
183
    return unless @$rows;
removed reconnect method
yuki-kimoto authored on 2010-05-28
184
    return $rows;
packaging one directory
yuki-kimoto authored on 2009-11-16
185
}
186

            
cleanup
yuki-kimoto authored on 2010-10-17
187
sub fetch_multi {
188
    my ($self, $count) = @_;
packaging one directory
yuki-kimoto authored on 2009-11-16
189
    
cleanup
yuki-kimoto authored on 2010-10-17
190
    # Row count not specifed
cleanup
Yuki Kimoto authored on 2011-04-25
191
    croak 'Row count must be specified ' . _subname
cleanup
yuki-kimoto authored on 2010-10-17
192
      unless $count;
193
    
194
    # Fetch multi rows
packaging one directory
yuki-kimoto authored on 2009-11-16
195
    my $rows = [];
cleanup
yuki-kimoto authored on 2010-10-17
196
    for (my $i = 0; $i < $count; $i++) {
197
        my $row = $self->fetch;
198
        last unless $row;
removed reconnect method
yuki-kimoto authored on 2010-05-28
199
        push @$rows, $row;
packaging one directory
yuki-kimoto authored on 2009-11-16
200
    }
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
201
    
cleanup
yuki-kimoto authored on 2010-10-17
202
    return unless @$rows;
removed reconnect method
yuki-kimoto authored on 2010-05-28
203
    return $rows;
packaging one directory
yuki-kimoto authored on 2009-11-16
204
}
205

            
- added DBIx::Custom::Result...
Yuki Kimoto authored on 2011-06-07
206
*one = \&fetch_hash_first;
207

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
208
sub type_rule {
209
    my $self = shift;
210
    
211
    if (@_) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
212
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
213

            
214
        # From
215
        foreach my $i (1 .. 2) {
216
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
217
            foreach my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
218
                croak qq{data type of from$i section must be lower case or number}
219
                  if $data_type =~ /[A-Z]/;
220
                my $fname = $type_rule->{"from$i"}{$data_type};
221
                if (defined $fname && ref $fname ne 'CODE') {
222
                    croak qq{Filter "$fname" is not registered" } . _subname
223
                      unless exists $self->filters->{$fname};
224
                    
225
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
226
                }
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
227
            }
228
        }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
229
        $self->{type_rule} = $type_rule;
DBIx::Custom::Result type_ru...
Yuki Kimoto authored on 2011-06-17
230
        
231
        return $self;
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
232
    }
233
    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
234
    return $self->{type_rule} || {};
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
235
}
236

            
cleanup
Yuki Kimoto authored on 2011-06-13
237
# DEPRECATED!
238
sub end_filter {
239
    my $self = shift;
240
    if (@_) {
241
        my $end_filter = {};
cleanup
Yuki Kimoto authored on 2011-06-15
242
        if (ref $_[0] eq 'HASH') { $end_filter = $_[0] }
243
        else { 
cleanup
Yuki Kimoto authored on 2011-06-13
244
            $end_filter = _array_to_hash(
245
                @_ > 1 ? [@_] : $_[0]
246
            );
247
        }
248
        foreach my $column (keys %$end_filter) {
249
            my $fname = $end_filter->{$column};
250
            if  (exists $end_filter->{$column}
251
              && defined $fname
252
              && ref $fname ne 'CODE') 
253
            {
254
              croak qq{Filter "$fname" is not registered" } . _subname
255
                unless exists $self->filters->{$fname};
256
              $end_filter->{$column} = $self->filters->{$fname};
257
            }
258
        }
259
        $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
260
        return $self;
261
    }
262
    return $self->{end_filter} ||= {};
263
}
264

            
cleanup
Yuki Kimoto authored on 2011-06-13
265
# DEPRECATED!
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
266
sub remove_end_filter {
267
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-06-13
268
    warn "remove_end_filter is DEPRECATED! use filter_off attribute instead";
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
269
    $self->{end_filter} = {};
270
    return $self;
271
}
272

            
cleanup
Yuki Kimoto authored on 2011-06-13
273
# DEPRECATED!
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
274
sub remove_filter {
275
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-06-13
276
    warn "remove_filter is DEPRECATED! use filter_off attribute instead";
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
277
    $self->{filter} = {};
278
    return $self;
279
}
280

            
cleanup
Yuki Kimoto authored on 2011-06-13
281
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
282
sub default_filter {
283
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-06-13
284
    warn "default_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
285
    if (@_) {
286
        my $fname = $_[0];
287
        if (@_ && !$fname) {
288
            $self->{default_filter} = undef;
289
        }
290
        else {
many changed
Yuki Kimoto authored on 2011-01-23
291
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
292
              unless exists $self->filters->{$fname};
293
            $self->{default_filter} = $self->filters->{$fname};
294
        }
295
        return $self;
296
    }
297
    return $self->{default_filter};
298
}
299

            
cleanup
Yuki Kimoto authored on 2011-01-23
300
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
301
has 'filter_check'; 
cleanup
Yuki Kimoto authored on 2011-01-23
302

            
update document
yuki-kimoto authored on 2010-01-30
303
1;
304

            
packaging one directory
yuki-kimoto authored on 2009-11-16
305
=head1 NAME
306

            
cleanup
yuki-kimoto authored on 2010-08-05
307
DBIx::Custom::Result - Result of select statement
packaging one directory
yuki-kimoto authored on 2009-11-16
308

            
update document
yuki-kimoto authored on 2010-01-30
309
=head1 SYNOPSIS
cleanup
yuki-kimoto authored on 2010-08-05
310

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
311
    # Result
cleanup
Yuki Kimoto authored on 2011-06-15
312
    my $result = $dbi->select(table => 'book');
cleanup
yuki-kimoto authored on 2010-08-05
313

            
cleanup
Yuki Kimoto authored on 2011-06-15
314
    # Fetch a row and put it into array reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
315
    while (my $row = $result->fetch) {
cleanup
yuki-kimoto authored on 2010-08-05
316
        my $author = $row->[0];
317
        my $title  = $row->[1];
version 0.0901
yuki-kimoto authored on 2009-12-17
318
    }
319
    
cleanup
Yuki Kimoto authored on 2011-06-15
320
    # Fetch only a first row and put it into array reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
321
    my $row = $result->fetch_first;
322
    
cleanup
Yuki Kimoto authored on 2011-06-15
323
    # Fetch all rows and put them into array of array reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
324
    my $rows = $result->fetch_all;
cleanup
yuki-kimoto authored on 2010-08-05
325

            
cleanup
Yuki Kimoto authored on 2011-06-15
326
    # Fetch a row and put it into hash reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
327
    while (my $row = $result->fetch_hash) {
cleanup
yuki-kimoto authored on 2010-08-05
328
        my $title  = $row->{title};
329
        my $author = $row->{author};
packaging one directory
yuki-kimoto authored on 2009-11-16
330
    }
removed reconnect method
yuki-kimoto authored on 2010-05-28
331
    
cleanup
Yuki Kimoto authored on 2011-06-15
332
    # Fetch only a first row and put it into hash reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
333
    my $row = $result->fetch_hash_first;
cleanup
Yuki Kimoto authored on 2011-06-15
334
    my $row = $result->one; # Same as fetch_hash_first
removed reconnect method
yuki-kimoto authored on 2010-05-28
335
    
cleanup
Yuki Kimoto authored on 2011-06-15
336
    # Fetch all rows and put them into array of hash reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
337
    my $rows = $result->fetch_hash_all;
cleanup
Yuki Kimoto authored on 2011-06-15
338
    my $rows = $result->all; # Same as fetch_hash_all
packaging one directory
yuki-kimoto authored on 2009-11-16
339

            
update document
yuki-kimoto authored on 2010-01-30
340
=head1 ATTRIBUTES
packaging one directory
yuki-kimoto authored on 2009-11-16
341

            
updated_pod
Yuki Kimoto authored on 2011-06-12
342
=head2 C<filter_off> EXPERIMENTAL
343

            
344
    my $filter_off = $resutl->filter_off;
345
    $result = $result->filter_off(1);
346

            
cleanup
Yuki Kimoto authored on 2011-06-15
347
Filtering by C<filter> method is turned off.
updated_pod
Yuki Kimoto authored on 2011-06-12
348

            
cleanup
yuki-kimoto authored on 2010-10-17
349
=head2 C<filters>
350

            
351
    my $filters = $result->filters;
cleanup
Yuki Kimoto authored on 2011-06-15
352
    $result = $result->filters(\%filters);
cleanup
yuki-kimoto authored on 2010-10-17
353

            
cleanup
Yuki Kimoto authored on 2011-06-15
354
Filters.
cleanup
yuki-kimoto authored on 2010-10-17
355

            
356
=head2 C<sth>
357

            
358
    my $sth = $reuslt->sth
359
    $result = $result->sth($sth);
360

            
361
Statement handle of L<DBI>.
362

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
363
=head2 C<type_rule_off> EXPERIMENTAL
364

            
365
    my $type_rule_off = $result->type_rule_off;
366
    $result = $result->type_rule_off(1);
367

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
368
Turn C<from1> and C<from2> type rule off.
369

            
370
=head2 C<type_rule1_off> EXPERIMENTAL
371

            
372
    my $type_rule1_off = $result->type_rule1_off;
373
    $result = $result->type_rule1_off(1);
374

            
375
Turn C<from1> type rule off.
376

            
377
=head2 C<type_rule2_off> EXPERIMENTAL
378

            
379
    my $type_rule2_off = $result->type_rule2_off;
380
    $result = $result->type_rule2_off(1);
381

            
382
Turn C<from2> type rule off.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
383

            
update document
yuki-kimoto authored on 2010-01-30
384
=head1 METHODS
385

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
386
L<DBIx::Custom::Result> inherits all methods from L<Object::Simple>
cleanup
yuki-kimoto authored on 2010-08-05
387
and implements the following new ones.
packaging one directory
yuki-kimoto authored on 2009-11-16
388

            
updated pod
Yuki Kimoto authored on 2011-06-07
389
=head2 C<all>
390

            
391
    my $rows = $result->all;
392

            
cleanup
Yuki Kimoto authored on 2011-06-15
393
Same as C<fetch_hash_all>.
updated pod
Yuki Kimoto authored on 2011-06-07
394

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
395
=head2 C<fetch>
packaging one directory
yuki-kimoto authored on 2009-11-16
396

            
cleanup
yuki-kimoto authored on 2010-08-05
397
    my $row = $result->fetch;
version 0.0901
yuki-kimoto authored on 2009-12-17
398

            
cleanup
Yuki Kimoto authored on 2011-06-15
399
Fetch a row and put it into array reference.
packaging one directory
yuki-kimoto authored on 2009-11-16
400

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
401
=head2 C<fetch_all>
packaging one directory
yuki-kimoto authored on 2009-11-16
402

            
cleanup
yuki-kimoto authored on 2010-08-05
403
    my $rows = $result->fetch_all;
version 0.0901
yuki-kimoto authored on 2009-12-17
404

            
cleanup
Yuki Kimoto authored on 2011-06-15
405
Fetch all rows and put them into array of array reference.
packaging one directory
yuki-kimoto authored on 2009-11-16
406

            
cleanup
yuki-kimoto authored on 2010-10-17
407
=head2 C<fetch_first>
408

            
409
    my $row = $result->fetch_first;
410

            
cleanup
Yuki Kimoto authored on 2011-06-15
411
Fetch only a first row and put it into array reference,
412
and finish statment handle.
cleanup
yuki-kimoto authored on 2010-10-17
413

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
414
=head2 C<fetch_hash>
packaging one directory
yuki-kimoto authored on 2009-11-16
415

            
cleanup
yuki-kimoto authored on 2010-08-05
416
    my $row = $result->fetch_hash;
packaging one directory
yuki-kimoto authored on 2009-11-16
417

            
cleanup
Yuki Kimoto authored on 2011-06-15
418
Fetch a row and put it into hash reference.
update document
yuki-kimoto authored on 2009-11-19
419

            
cleanup
yuki-kimoto authored on 2010-10-17
420
=head2 C<fetch_hash_all>
421

            
422
    my $rows = $result->fetch_hash_all;
423

            
cleanup
Yuki Kimoto authored on 2011-06-15
424
Fetch all rows and put them into array of hash reference.
cleanup
yuki-kimoto authored on 2010-10-17
425

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
426
=head2 C<fetch_hash_first>
removed reconnect method
yuki-kimoto authored on 2010-05-28
427
    
cleanup
yuki-kimoto authored on 2010-08-05
428
    my $row = $result->fetch_hash_first;
packaging one directory
yuki-kimoto authored on 2009-11-16
429

            
cleanup
Yuki Kimoto authored on 2011-06-15
430
Fetch only a first row and put it into hash reference,
431
and finish statment handle.
packaging one directory
yuki-kimoto authored on 2009-11-16
432

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
433
=head2 C<fetch_hash_multi>
update document
yuki-kimoto authored on 2009-11-19
434

            
cleanup
yuki-kimoto authored on 2010-08-05
435
    my $rows = $result->fetch_hash_multi(5);
update document
yuki-kimoto authored on 2009-11-19
436
    
cleanup
Yuki Kimoto authored on 2011-06-15
437
Fetch multiple rows and put them into array of hash reference.
update document
yuki-kimoto authored on 2009-11-19
438

            
cleanup
yuki-kimoto authored on 2010-10-17
439
=head2 C<fetch_multi>
packaging one directory
yuki-kimoto authored on 2009-11-16
440

            
cleanup
yuki-kimoto authored on 2010-10-17
441
    my $rows = $result->fetch_multi(5);
442
    
cleanup
Yuki Kimoto authored on 2011-06-15
443
Fetch multiple rows and put them into array of array reference.
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
444

            
cleanup
Yuki Kimoto authored on 2010-12-21
445
=head2 C<filter>
446

            
cleanup
Yuki Kimoto authored on 2011-06-15
447
    $result->filter(title  => sub { uc $_[0] }, author => 'to_upper');
448
    $result->filter([qw/title author/] => 'to_upper');
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
449

            
cleanup
Yuki Kimoto authored on 2011-06-15
450
Set filter for column.
451
You can use subroutine or filter name as filter.
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
452
This filter is executed after C<type_rule> filter.
cleanup
Yuki Kimoto authored on 2010-12-21
453

            
updated pod
Yuki Kimoto authored on 2011-06-07
454
=head2 C<one>
455

            
456
    my $row = $result->one;
457

            
cleanup
Yuki Kimoto authored on 2011-06-15
458
Same as C<fetch_hash_first>.
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
459

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
460
=head2 C<stash>
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-25
461

            
462
    my $stash = $result->stash;
463
    my $foo = $result->stash->{foo};
464
    $result->stash->{foo} = $foo;
465

            
cleanup
Yuki Kimoto authored on 2011-06-15
466
Stash is hash reference for data.
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-25
467

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
468
=head2 C<type_rule> EXPERIMENTAL
cleanup
Yuki Kimoto authored on 2011-06-15
469
    
470
    # Merge type rule
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
471
    $result->type_rule(
472
        # DATE
473
        9 => sub { ... },
474
        # DATETIME or TIMESTAMP
475
        11 => sub { ... }
476
    );
477

            
cleanup
Yuki Kimoto authored on 2011-06-15
478
    # Replace type rule(by reference)
479
    $result->type_rule([
480
        # DATE
481
        9 => sub { ... },
482
        # DATETIME or TIMESTAMP
483
        11 => sub { ... }
484
    ]);
EXPERIMENTAL type_rule_off i...
Yuki Kimoto authored on 2011-06-14
485

            
cleanup
Yuki Kimoto authored on 2011-06-15
486
This is same as L<DBIx::Custom>'s C<type_rule>'s <from>.
EXPERIMENTAL type_rule_off i...
Yuki Kimoto authored on 2011-06-14
487

            
packaging one directory
yuki-kimoto authored on 2009-11-16
488
=cut