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

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

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

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

            
packaging one directory
yuki-kimoto authored on 2009-11-16
119
sub fetch_hash {
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
120
    my $self = shift;
121
    
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-07-11
122
    # Info
123
    my $columns = $self->{sth}->{NAME};
124
    my $types = $self->{sth}->{TYPE};
125
    
packaging one directory
yuki-kimoto authored on 2009-11-16
126
    # Fetch
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
127
    my $row = $self->{sth}->fetchrow_arrayref;
packaging one directory
yuki-kimoto authored on 2009-11-16
128
    return unless $row;
added check_filter attribute
yuki-kimoto authored on 2010-08-08
129

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

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

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

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

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-07-11
222
sub header { shift->sth->{NAME} }
223

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
226
sub type_rule {
227
    my $self = shift;
228
    
229
    if (@_) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
230
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
231

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

            
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
255
sub type_rule_off {
256
    my $self = shift;
257
    $self->{type_rule_off} = 1;
258
    return $self;
259
}
260

            
261
sub type_rule_on {
262
    my $self = shift;
263
    $self->{type_rule_off} = 0;
264
    return $self;
265
}
266

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

            
273
sub type_rule1_on {
274
    my $self = shift;
275
    $self->{type_rule1_off} = 0;
276
    return $self;
277
}
278

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

            
285
sub type_rule2_on {
286
    my $self = shift;
287
    $self->{type_rule2_off} = 0;
288
    return $self;
289
}
290

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

            
update document
yuki-kimoto authored on 2010-01-30
354
1;
355

            
packaging one directory
yuki-kimoto authored on 2009-11-16
356
=head1 NAME
357

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
393
=head2 C<filters>
394

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

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

            
400
=head2 C<sth>
401

            
402
    my $sth = $reuslt->sth
403
    $result = $result->sth($sth);
404

            
405
Statement handle of L<DBI>.
406

            
update document
yuki-kimoto authored on 2010-01-30
407
=head1 METHODS
408

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

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

            
414
    my $rows = $result->all;
415

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
430
=head2 C<fetch_first>
431

            
432
    my $row = $result->fetch_first;
433

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
443
=head2 C<fetch_hash_all>
444

            
445
    my $rows = $result->fetch_hash_all;
446

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2010-12-21
468
=head2 C<filter>
469

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

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

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

            
479
    $result = $result->filter_off;
480

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

            
484
=head2 C<filter_on> EXPERIMENTAL
485

            
486
    $result = $resutl->filter_on;
487

            
488
Turn filtering by C<filter> method on.
489
By default, filterin is on.
490

            
- removed EXPERIMENTAL statu...
Yuki Kimoto authored on 2011-07-26
491
=head2 C<header>
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-07-11
492

            
493
    my $header = $result->header;
494

            
495
Get header column names.
496

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

            
499
    my $row = $result->one;
500

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

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

            
505
    my $stash = $result->stash;
506
    my $foo = $result->stash->{foo};
507
    $result->stash->{foo} = $foo;
508

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
511
=head2 C<type_rule> EXPERIMENTAL
cleanup
Yuki Kimoto authored on 2011-06-15
512
    
513
    # Merge type rule
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
514
    $result->type_rule(
515
        # DATE
516
        9 => sub { ... },
517
        # DATETIME or TIMESTAMP
518
        11 => sub { ... }
519
    );
520

            
cleanup
Yuki Kimoto authored on 2011-06-15
521
    # Replace type rule(by reference)
522
    $result->type_rule([
523
        # DATE
524
        9 => sub { ... },
525
        # DATETIME or TIMESTAMP
526
        11 => sub { ... }
527
    ]);
EXPERIMENTAL type_rule_off i...
Yuki Kimoto authored on 2011-06-14
528

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

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

            
533
    $result = $result->type_rule_off;
534

            
535
Turn C<from1> and C<from2> type rule off.
536
By default, type rule is on.
537

            
538
=head2 C<type_rule_on> EXPERIMENTAL
539

            
540
    $result = $result->type_rule_on;
541

            
542
Turn C<from1> and C<from2> type rule on.
543
By default, type rule is on.
544

            
545
=head2 C<type_rule1_off> EXPERIMENTAL
546

            
547
    $result = $result->type_rule1_off;
548

            
549
Turn C<from1> type rule off.
550
By default, type rule is on.
551

            
552
=head2 C<type_rule1_on> EXPERIMENTAL
553

            
554
    $result = $result->type_rule1_on;
555

            
556
Turn C<from1> type rule on.
557
By default, type rule is on.
558

            
559
=head2 C<type_rule2_off> EXPERIMENTAL
560

            
561
    $result = $result->type_rule2_off;
562

            
563
Turn C<from2> type rule off.
564
By default, type rule is on.
565

            
566
=head2 C<type_rule2_on> EXPERIMENTAL
567

            
568
    $result = $result->type_rule2_on;
569

            
570
Turn C<from2> type rule on.
571
By default, type rule is on.
572

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