Newer Older
563 lines | 13.067kb
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

            
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
7
has [qw/dbi sth/],
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
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 2011-10-21
21
        for my $column (keys %$filter) {
cleanup
Yuki Kimoto authored on 2010-12-22
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
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
28
                unless exists $self->dbi->filters->{$fname};
29
              $filter->{$column} = $self->dbi->filters->{$fname};
cleanup
Yuki Kimoto authored on 2010-12-22
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
    
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-07-11
45
    # Info
46
    my $columns = $self->{sth}->{NAME};
47
    my $types = $self->{sth}->{TYPE};
48
    
packaging one directory
yuki-kimoto authored on 2009-11-16
49
    # Fetch
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
50
    my @row = $self->{sth}->fetchrow_array;
update document
yuki-kimoto authored on 2010-05-27
51
    return unless @row;
added check_filter attribute
yuki-kimoto authored on 2010-08-08
52
    
cleanup
yuki-kimoto authored on 2010-08-05
53
    # Filtering
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
54
    my $type_rule1 = $self->type_rule->{from1} || {};
55
    my $type_rule2 = $self->type_rule->{from2} || {};
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
56
    my $filter = $self->filter;
fixed end_filter DEPRECATED ...
Yuki Kimoto authored on 2011-07-01
57
    my $end_filter = $self->{end_filter} || {};
cleanup
yuki-kimoto authored on 2010-08-05
58
    for (my $i = 0; $i < @$columns; $i++) {
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
59
        
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
60
        # Column
cleanup
yuki-kimoto authored on 2010-08-05
61
        my $column = $columns->[$i];
some changed
yuki-kimoto authored on 2010-05-02
62
        
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
63
        # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
64
        my $type_filter1 = $type_rule1->{lc($types->[$i])};
65
        $row[$i] = $type_filter1->($row[$i])
66
          if  $type_filter1 && !$self->{type_rule_off}
67
           && !$self->{type_rule1_off};
68
        my $type_filter2 = $type_rule2->{lc($types->[$i])};
69
        $row[$i] = $type_filter2->($row[$i])
70
          if  $type_filter2 && !$self->{type_rule_off}
71
           && !$self->{type_rule2_off};
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
72
        
73
        # Filter
74
        my $filter  = $filter->{$column} || $self->{default_filter};
75
        $row[$i] = $filter->($row[$i])
76
          if $filter && !$self->{filter_off};
77
        $row[$i] = $end_filter->{$column}->($row[$i])
78
          if $end_filter->{$column} && !$self->{filter_off};
packaging one directory
yuki-kimoto authored on 2009-11-16
79
    }
many many changes
yuki-kimoto authored on 2010-04-30
80

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

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

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

            
packaging one directory
yuki-kimoto authored on 2009-11-16
107
sub fetch_hash {
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
108
    my $self = shift;
109
    
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-07-11
110
    # Info
111
    my $columns = $self->{sth}->{NAME};
112
    my $types = $self->{sth}->{TYPE};
113
    
packaging one directory
yuki-kimoto authored on 2009-11-16
114
    # Fetch
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
115
    my $row = $self->{sth}->fetchrow_arrayref;
packaging one directory
yuki-kimoto authored on 2009-11-16
116
    return unless $row;
added check_filter attribute
yuki-kimoto authored on 2010-08-08
117

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

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

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

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

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

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

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
214
sub type_rule {
215
    my $self = shift;
216
    
217
    if (@_) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
218
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
219

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

            
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
243
sub type_rule_off {
244
    my $self = shift;
245
    $self->{type_rule_off} = 1;
246
    return $self;
247
}
248

            
249
sub type_rule_on {
250
    my $self = shift;
251
    $self->{type_rule_off} = 0;
252
    return $self;
253
}
254

            
255
sub type_rule1_off {
256
    my $self = shift;
257
    $self->{type_rule1_off} = 1;
258
    return $self;
259
}
260

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

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

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

            
- DBIx::Custom::Result filte...
Yuki Kimoto authored on 2011-11-03
279
# DEPRECATED!
280
sub filter_off {
281
    warn "filter_off method is DEPRECATED!";
282
    my $self = shift;
283
    $self->{filter_off} = 1;
284
    return $self;
285
}
286

            
287
# DEPRECATED!
288
sub filter_on {
289
    warn "filter_on method is DEPRECATED!";
290
    my $self = shift;
291
    $self->{filter_off} = 0;
292
    return $self;
293
}
294

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

            
update document
yuki-kimoto authored on 2010-01-30
358
1;
359

            
packaging one directory
yuki-kimoto authored on 2009-11-16
360
=head1 NAME
361

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

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

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

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

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

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

            
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
397
=head2 C<dbi>
cleanup
yuki-kimoto authored on 2010-10-17
398

            
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
399
    my $dbi = $result->dbi;
400
    $result = $result->dbi($dbi);
cleanup
yuki-kimoto authored on 2010-10-17
401

            
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
402
L<DBIx::Custom> object.
cleanup
yuki-kimoto authored on 2010-10-17
403

            
404
=head2 C<sth>
405

            
406
    my $sth = $reuslt->sth
407
    $result = $result->sth($sth);
408

            
409
Statement handle of L<DBI>.
410

            
update document
yuki-kimoto authored on 2010-01-30
411
=head1 METHODS
412

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

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

            
418
    my $rows = $result->all;
419

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
434
=head2 C<fetch_first>
435

            
436
    my $row = $result->fetch_first;
437

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
447
=head2 C<fetch_hash_all>
448

            
449
    my $rows = $result->fetch_hash_all;
450

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2010-12-21
472
=head2 C<filter>
473

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

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

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

            
483
    my $header = $result->header;
484

            
485
Get header column names.
486

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

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

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

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

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

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

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

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
521
=head2 C<type_rule_off>
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
522

            
523
    $result = $result->type_rule_off;
524

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
528
=head2 C<type_rule_on>
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
529

            
530
    $result = $result->type_rule_on;
531

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
535
=head2 C<type_rule1_off>
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
536

            
537
    $result = $result->type_rule1_off;
538

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
542
=head2 C<type_rule1_on>
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
543

            
544
    $result = $result->type_rule1_on;
545

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
549
=head2 C<type_rule2_off>
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
550

            
551
    $result = $result->type_rule2_off;
552

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
556
=head2 C<type_rule2_on>
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
557

            
558
    $result = $result->type_rule2_on;
559

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

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