Newer Older
564 lines | 13.173kb
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 {
287
    my $self = shift;
288
    if (@_) {
289
        my $end_filter = {};
cleanup
Yuki Kimoto authored on 2011-06-15
290
        if (ref $_[0] eq 'HASH') { $end_filter = $_[0] }
291
        else { 
cleanup
Yuki Kimoto authored on 2011-06-13
292
            $end_filter = _array_to_hash(
293
                @_ > 1 ? [@_] : $_[0]
294
            );
295
        }
296
        foreach my $column (keys %$end_filter) {
297
            my $fname = $end_filter->{$column};
298
            if  (exists $end_filter->{$column}
299
              && defined $fname
300
              && ref $fname ne 'CODE') 
301
            {
302
              croak qq{Filter "$fname" is not registered" } . _subname
303
                unless exists $self->filters->{$fname};
304
              $end_filter->{$column} = $self->filters->{$fname};
305
            }
306
        }
307
        $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
308
        return $self;
309
    }
310
    return $self->{end_filter} ||= {};
311
}
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 {
315
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-06-13
316
    warn "remove_end_filter is DEPRECATED! use filter_off attribute instead";
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
317
    $self->{end_filter} = {};
318
    return $self;
319
}
320

            
cleanup
Yuki Kimoto authored on 2011-06-13
321
# DEPRECATED!
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
322
sub remove_filter {
323
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-06-13
324
    warn "remove_filter is DEPRECATED! use filter_off attribute instead";
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
325
    $self->{filter} = {};
326
    return $self;
327
}
328

            
cleanup
Yuki Kimoto authored on 2011-06-13
329
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
330
sub default_filter {
331
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-06-13
332
    warn "default_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
333
    if (@_) {
334
        my $fname = $_[0];
335
        if (@_ && !$fname) {
336
            $self->{default_filter} = undef;
337
        }
338
        else {
many changed
Yuki Kimoto authored on 2011-01-23
339
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
340
              unless exists $self->filters->{$fname};
341
            $self->{default_filter} = $self->filters->{$fname};
342
        }
343
        return $self;
344
    }
345
    return $self->{default_filter};
346
}
347

            
cleanup
Yuki Kimoto authored on 2011-01-23
348
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
349
has 'filter_check'; 
cleanup
Yuki Kimoto authored on 2011-01-23
350

            
update document
yuki-kimoto authored on 2010-01-30
351
1;
352

            
packaging one directory
yuki-kimoto authored on 2009-11-16
353
=head1 NAME
354

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
390
=head2 C<filters>
391

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

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

            
397
=head2 C<sth>
398

            
399
    my $sth = $reuslt->sth
400
    $result = $result->sth($sth);
401

            
402
Statement handle of L<DBI>.
403

            
update document
yuki-kimoto authored on 2010-01-30
404
=head1 METHODS
405

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

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

            
411
    my $rows = $result->all;
412

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
427
=head2 C<fetch_first>
428

            
429
    my $row = $result->fetch_first;
430

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
440
=head2 C<fetch_hash_all>
441

            
442
    my $rows = $result->fetch_hash_all;
443

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2010-12-21
465
=head2 C<filter>
466

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

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

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

            
476
    $result = $result->filter_off;
477

            
478
Turn filtering by C<filter> method off.
479
By default, filterin is on.
480

            
481
=head2 C<filter_on> EXPERIMENTAL
482

            
483
    $result = $resutl->filter_on;
484

            
485
Turn filtering by C<filter> method on.
486
By default, filterin is on.
487

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

            
490
    my $row = $result->one;
491

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

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

            
496
    my $stash = $result->stash;
497
    my $foo = $result->stash->{foo};
498
    $result->stash->{foo} = $foo;
499

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

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

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

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

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

            
524
    $result = $result->type_rule_off;
525

            
526
Turn C<from1> and C<from2> type rule off.
527
By default, type rule is on.
528

            
529
=head2 C<type_rule_on> EXPERIMENTAL
530

            
531
    $result = $result->type_rule_on;
532

            
533
Turn C<from1> and C<from2> type rule on.
534
By default, type rule is on.
535

            
536
=head2 C<type_rule1_off> EXPERIMENTAL
537

            
538
    $result = $result->type_rule1_off;
539

            
540
Turn C<from1> type rule off.
541
By default, type rule is on.
542

            
543
=head2 C<type_rule1_on> EXPERIMENTAL
544

            
545
    $result = $result->type_rule1_on;
546

            
547
Turn C<from1> type rule on.
548
By default, type rule is on.
549

            
550
=head2 C<type_rule2_off> EXPERIMENTAL
551

            
552
    $result = $result->type_rule2_off;
553

            
554
Turn C<from2> type rule off.
555
By default, type rule is on.
556

            
557
=head2 C<type_rule2_on> EXPERIMENTAL
558

            
559
    $result = $result->type_rule2_on;
560

            
561
Turn C<from2> type rule on.
562
By default, type rule is on.
563

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