Newer Older
561 lines | 13.148kb
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

            
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
7
has [qw/filters sth/],
8
    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

            
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
42
sub filter_off {
43
    my $self = shift;
44
    $self->{filter_off} = 1;
45
    return $self;
46
}
47

            
48
sub filter_on {
49
    my $self = shift;
50
    $self->{filter_off} = 0;
51
    return $self;
52
}
53

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
91
    return \@row;
92
}
93

            
cleanup
yuki-kimoto authored on 2010-10-17
94
sub fetch_all {
95
    my $self = shift;
96
    
97
    # Fetch all rows
98
    my $rows = [];
cleanup
Yuki Kimoto authored on 2011-06-15
99
    while(my $row = $self->fetch) { push @$rows, $row}
100
    
cleanup
yuki-kimoto authored on 2010-10-17
101
    return $rows;
102
}
103

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
104
sub fetch_first {
105
    my $self = shift;
106
    
107
    # Fetch
108
    my $row = $self->fetch;
109
    return unless $row;
110
    
111
    # Finish statement handle
112
    $self->sth->finish;
113
    
114
    return $row;
115
}
116

            
packaging one directory
yuki-kimoto authored on 2009-11-16
117
sub fetch_hash {
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
118
    my $self = shift;
119
    
packaging one directory
yuki-kimoto authored on 2009-11-16
120
    # Fetch
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
121
    my $row = $self->{sth}->fetchrow_arrayref;
packaging one directory
yuki-kimoto authored on 2009-11-16
122
    return unless $row;
added check_filter attribute
yuki-kimoto authored on 2010-08-08
123

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

            
cleanup
yuki-kimoto authored on 2010-10-17
159
sub fetch_hash_all {
160
    my $self = shift;
161
    
162
    # Fetch all rows as hash
163
    my $rows = [];
cleanup
Yuki Kimoto authored on 2011-06-15
164
    while(my $row = $self->fetch_hash) { push @$rows, $row }
cleanup
yuki-kimoto authored on 2010-10-17
165
    
166
    return $rows;
167
}
168

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
169
sub fetch_hash_first {
packaging one directory
yuki-kimoto authored on 2009-11-16
170
    my $self = shift;
171
    
172
    # Fetch hash
173
    my $row = $self->fetch_hash;
174
    return unless $row;
175
    
176
    # Finish statement handle
some changed
yuki-kimoto authored on 2010-05-02
177
    $self->sth->finish;
packaging one directory
yuki-kimoto authored on 2009-11-16
178
    
removed reconnect method
yuki-kimoto authored on 2010-05-28
179
    return $row;
packaging one directory
yuki-kimoto authored on 2009-11-16
180
}
181

            
renamed fetch_rows to fetch_...
yuki-kimoto authored on 2010-05-01
182
sub fetch_hash_multi {
packaging one directory
yuki-kimoto authored on 2009-11-16
183
    my ($self, $count) = @_;
184
    
cleanup
Yuki Kimoto authored on 2011-06-15
185
    # Fetch multiple rows
cleanup
Yuki Kimoto authored on 2011-04-25
186
    croak 'Row count must be specified ' . _subname
packaging one directory
yuki-kimoto authored on 2009-11-16
187
      unless $count;
188
    my $rows = [];
189
    for (my $i = 0; $i < $count; $i++) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
190
        my $row = $self->fetch_hash;
191
        last unless $row;
192
        push @$rows, $row;
packaging one directory
yuki-kimoto authored on 2009-11-16
193
    }
194
    
195
    return unless @$rows;
removed reconnect method
yuki-kimoto authored on 2010-05-28
196
    return $rows;
packaging one directory
yuki-kimoto authored on 2009-11-16
197
}
198

            
cleanup
yuki-kimoto authored on 2010-10-17
199
sub fetch_multi {
200
    my ($self, $count) = @_;
packaging one directory
yuki-kimoto authored on 2009-11-16
201
    
cleanup
yuki-kimoto authored on 2010-10-17
202
    # Row count not specifed
cleanup
Yuki Kimoto authored on 2011-04-25
203
    croak 'Row count must be specified ' . _subname
cleanup
yuki-kimoto authored on 2010-10-17
204
      unless $count;
205
    
206
    # Fetch multi rows
packaging one directory
yuki-kimoto authored on 2009-11-16
207
    my $rows = [];
cleanup
yuki-kimoto authored on 2010-10-17
208
    for (my $i = 0; $i < $count; $i++) {
209
        my $row = $self->fetch;
210
        last unless $row;
removed reconnect method
yuki-kimoto authored on 2010-05-28
211
        push @$rows, $row;
packaging one directory
yuki-kimoto authored on 2009-11-16
212
    }
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
213
    
cleanup
yuki-kimoto authored on 2010-10-17
214
    return unless @$rows;
removed reconnect method
yuki-kimoto authored on 2010-05-28
215
    return $rows;
packaging one directory
yuki-kimoto authored on 2009-11-16
216
}
217

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
220
sub type_rule {
221
    my $self = shift;
222
    
223
    if (@_) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
224
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
225

            
226
        # From
227
        foreach my $i (1 .. 2) {
228
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
229
            foreach my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
230
                croak qq{data type of from$i section must be lower case or number}
231
                  if $data_type =~ /[A-Z]/;
232
                my $fname = $type_rule->{"from$i"}{$data_type};
233
                if (defined $fname && ref $fname ne 'CODE') {
234
                    croak qq{Filter "$fname" is not registered" } . _subname
235
                      unless exists $self->filters->{$fname};
236
                    
237
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
238
                }
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
239
            }
240
        }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
241
        $self->{type_rule} = $type_rule;
DBIx::Custom::Result type_ru...
Yuki Kimoto authored on 2011-06-17
242
        
243
        return $self;
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
244
    }
245
    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
246
    return $self->{type_rule} || {};
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
247
}
248

            
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
249
sub type_rule_off {
250
    my $self = shift;
251
    $self->{type_rule_off} = 1;
252
    return $self;
253
}
254

            
255
sub type_rule_on {
256
    my $self = shift;
257
    $self->{type_rule_off} = 0;
258
    return $self;
259
}
260

            
261
sub type_rule1_off {
262
    my $self = shift;
263
    $self->{type_rule1_off} = 1;
264
    return $self;
265
}
266

            
267
sub type_rule1_on {
268
    my $self = shift;
269
    $self->{type_rule1_off} = 0;
270
    return $self;
271
}
272

            
273
sub type_rule2_off {
274
    my $self = shift;
275
    $self->{type_rule2_off} = 1;
276
    return $self;
277
}
278

            
279
sub type_rule2_on {
280
    my $self = shift;
281
    $self->{type_rule2_off} = 0;
282
    return $self;
283
}
284

            
cleanup
Yuki Kimoto authored on 2011-06-13
285
# DEPRECATED!
286
sub end_filter {
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
287
    warn "end_filter method is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
288
    my $self = shift;
289
    if (@_) {
290
        my $end_filter = {};
cleanup
Yuki Kimoto authored on 2011-06-15
291
        if (ref $_[0] eq 'HASH') { $end_filter = $_[0] }
292
        else { 
cleanup
Yuki Kimoto authored on 2011-06-13
293
            $end_filter = _array_to_hash(
294
                @_ > 1 ? [@_] : $_[0]
295
            );
296
        }
297
        foreach my $column (keys %$end_filter) {
298
            my $fname = $end_filter->{$column};
299
            if  (exists $end_filter->{$column}
300
              && defined $fname
301
              && ref $fname ne 'CODE') 
302
            {
303
              croak qq{Filter "$fname" is not registered" } . _subname
304
                unless exists $self->filters->{$fname};
305
              $end_filter->{$column} = $self->filters->{$fname};
306
            }
307
        }
308
        $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
309
        return $self;
310
    }
311
    return $self->{end_filter} ||= {};
312
}
cleanup
Yuki Kimoto authored on 2011-06-13
313
# DEPRECATED!
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
314
sub remove_end_filter {
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
315
    warn "remove_end_filter is DEPRECATED!";
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
316
    my $self = shift;
317
    $self->{end_filter} = {};
318
    return $self;
319
}
cleanup
Yuki Kimoto authored on 2011-06-13
320
# DEPRECATED!
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
321
sub remove_filter {
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
322
    warn "remove_filter is DEPRECATED!";
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
323
    my $self = shift;
324
    $self->{filter} = {};
325
    return $self;
326
}
cleanup
Yuki Kimoto authored on 2011-06-13
327
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
328
sub default_filter {
cleanup
Yuki Kimoto authored on 2011-06-13
329
    warn "default_filter is DEPRECATED!";
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
330
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-01-12
331
    if (@_) {
332
        my $fname = $_[0];
333
        if (@_ && !$fname) {
334
            $self->{default_filter} = undef;
335
        }
336
        else {
many changed
Yuki Kimoto authored on 2011-01-23
337
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
338
              unless exists $self->filters->{$fname};
339
            $self->{default_filter} = $self->filters->{$fname};
340
        }
341
        return $self;
342
    }
343
    return $self->{default_filter};
344
}
cleanup
Yuki Kimoto authored on 2011-01-23
345
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
346
has 'filter_check'; 
cleanup
Yuki Kimoto authored on 2011-01-23
347

            
update document
yuki-kimoto authored on 2010-01-30
348
1;
349

            
packaging one directory
yuki-kimoto authored on 2009-11-16
350
=head1 NAME
351

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-15
359
    # Fetch a row and put it into array reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
360
    while (my $row = $result->fetch) {
cleanup
yuki-kimoto authored on 2010-08-05
361
        my $author = $row->[0];
362
        my $title  = $row->[1];
version 0.0901
yuki-kimoto authored on 2009-12-17
363
    }
364
    
cleanup
Yuki Kimoto authored on 2011-06-15
365
    # Fetch only a first row and put it into array reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
366
    my $row = $result->fetch_first;
367
    
cleanup
Yuki Kimoto authored on 2011-06-15
368
    # Fetch all rows and put them into array of array reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
369
    my $rows = $result->fetch_all;
cleanup
yuki-kimoto authored on 2010-08-05
370

            
cleanup
Yuki Kimoto authored on 2011-06-15
371
    # Fetch a row and put it into hash reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
372
    while (my $row = $result->fetch_hash) {
cleanup
yuki-kimoto authored on 2010-08-05
373
        my $title  = $row->{title};
374
        my $author = $row->{author};
packaging one directory
yuki-kimoto authored on 2009-11-16
375
    }
removed reconnect method
yuki-kimoto authored on 2010-05-28
376
    
cleanup
Yuki Kimoto authored on 2011-06-15
377
    # Fetch only a first row and put it into hash reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
378
    my $row = $result->fetch_hash_first;
cleanup
Yuki Kimoto authored on 2011-06-15
379
    my $row = $result->one; # Same as fetch_hash_first
removed reconnect method
yuki-kimoto authored on 2010-05-28
380
    
cleanup
Yuki Kimoto authored on 2011-06-15
381
    # Fetch all rows and put them into array of hash reference
removed reconnect method
yuki-kimoto authored on 2010-05-28
382
    my $rows = $result->fetch_hash_all;
cleanup
Yuki Kimoto authored on 2011-06-15
383
    my $rows = $result->all; # Same as fetch_hash_all
packaging one directory
yuki-kimoto authored on 2009-11-16
384

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

            
cleanup
yuki-kimoto authored on 2010-10-17
387
=head2 C<filters>
388

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

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

            
394
=head2 C<sth>
395

            
396
    my $sth = $reuslt->sth
397
    $result = $result->sth($sth);
398

            
399
Statement handle of L<DBI>.
400

            
update document
yuki-kimoto authored on 2010-01-30
401
=head1 METHODS
402

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

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

            
408
    my $rows = $result->all;
409

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
424
=head2 C<fetch_first>
425

            
426
    my $row = $result->fetch_first;
427

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
437
=head2 C<fetch_hash_all>
438

            
439
    my $rows = $result->fetch_hash_all;
440

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2010-12-21
462
=head2 C<filter>
463

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

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

            
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
471
=head2 C<filter_off> EXPERIMENTAL
472

            
473
    $result = $result->filter_off;
474

            
475
Turn filtering by C<filter> method off.
476
By default, filterin is on.
477

            
478
=head2 C<filter_on> EXPERIMENTAL
479

            
480
    $result = $resutl->filter_on;
481

            
482
Turn filtering by C<filter> method on.
483
By default, filterin is on.
484

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

            
487
    my $row = $result->one;
488

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

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

            
493
    my $stash = $result->stash;
494
    my $foo = $result->stash->{foo};
495
    $result->stash->{foo} = $foo;
496

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
499
=head2 C<type_rule> EXPERIMENTAL
cleanup
Yuki Kimoto authored on 2011-06-15
500
    
501
    # Merge type rule
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
502
    $result->type_rule(
503
        # DATE
504
        9 => sub { ... },
505
        # DATETIME or TIMESTAMP
506
        11 => sub { ... }
507
    );
508

            
cleanup
Yuki Kimoto authored on 2011-06-15
509
    # Replace type rule(by reference)
510
    $result->type_rule([
511
        # DATE
512
        9 => sub { ... },
513
        # DATETIME or TIMESTAMP
514
        11 => sub { ... }
515
    ]);
EXPERIMENTAL type_rule_off i...
Yuki Kimoto authored on 2011-06-14
516

            
cleanup
Yuki Kimoto authored on 2011-06-15
517
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
518

            
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
519
=head2 C<type_rule_off> EXPERIMENTAL
520

            
521
    $result = $result->type_rule_off;
522

            
523
Turn C<from1> and C<from2> type rule off.
524
By default, type rule is on.
525

            
526
=head2 C<type_rule_on> EXPERIMENTAL
527

            
528
    $result = $result->type_rule_on;
529

            
530
Turn C<from1> and C<from2> type rule on.
531
By default, type rule is on.
532

            
533
=head2 C<type_rule1_off> EXPERIMENTAL
534

            
535
    $result = $result->type_rule1_off;
536

            
537
Turn C<from1> type rule off.
538
By default, type rule is on.
539

            
540
=head2 C<type_rule1_on> EXPERIMENTAL
541

            
542
    $result = $result->type_rule1_on;
543

            
544
Turn C<from1> type rule on.
545
By default, type rule is on.
546

            
547
=head2 C<type_rule2_off> EXPERIMENTAL
548

            
549
    $result = $result->type_rule2_off;
550

            
551
Turn C<from2> type rule off.
552
By default, type rule is on.
553

            
554
=head2 C<type_rule2_on> EXPERIMENTAL
555

            
556
    $result = $result->type_rule2_on;
557

            
558
Turn C<from2> type rule on.
559
By default, type rule is on.
560

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