DBIx-Custom / DBIx-Custom-0.1711 / blib / man3 / DBIx::Custom::Result.3pm /
Newer Older
409 lines | 10.922kb
added common test executing ...
Yuki Kimoto authored on 2011-08-07
1
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2
.\"
3
.\" Standard preamble:
4
.\" ========================================================================
5
.de Sh \" Subsection heading
6
.br
7
.if t .Sp
8
.ne 5
9
.PP
10
\fB\\$1\fR
11
.PP
12
..
13
.de Sp \" Vertical space (when we can't use .PP)
14
.if t .sp .5v
15
.if n .sp
16
..
17
.de Vb \" Begin verbatim text
18
.ft CW
19
.nf
20
.ne \\$1
21
..
22
.de Ve \" End verbatim text
23
.ft R
24
.fi
25
..
26
.\" Set up some character translations and predefined strings.  \*(-- will
27
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28
.\" double quote, and \*(R" will give a right double quote.  | will give a
29
.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30
.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31
.\" expand to `' in nroff, nothing in troff, for use with C<>.
32
.tr \(*W-|\(bv\*(Tr
33
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34
.ie n \{\
35
.    ds -- \(*W-
36
.    ds PI pi
37
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39
.    ds L" ""
40
.    ds R" ""
41
.    ds C` ""
42
.    ds C' ""
43
'br\}
44
.el\{\
45
.    ds -- \|\(em\|
46
.    ds PI \(*p
47
.    ds L" ``
48
.    ds R" ''
49
'br\}
50
.\"
51
.\" If the F register is turned on, we'll generate index entries on stderr for
52
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53
.\" entries marked with X<> in POD.  Of course, you'll have to process the
54
.\" output yourself in some meaningful fashion.
55
.if \nF \{\
56
.    de IX
57
.    tm Index:\\$1\t\\n%\t"\\$2"
58
..
59
.    nr % 0
60
.    rr F
61
.\}
62
.\"
63
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64
.\" way too many mistakes in technical documents.
65
.hy 0
66
.if n .na
67
.\"
68
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70
.    \" fudge factors for nroff and troff
71
.if n \{\
72
.    ds #H 0
73
.    ds #V .8m
74
.    ds #F .3m
75
.    ds #[ \f1
76
.    ds #] \fP
77
.\}
78
.if t \{\
79
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80
.    ds #V .6m
81
.    ds #F 0
82
.    ds #[ \&
83
.    ds #] \&
84
.\}
85
.    \" simple accents for nroff and troff
86
.if n \{\
87
.    ds ' \&
88
.    ds ` \&
89
.    ds ^ \&
90
.    ds , \&
91
.    ds ~ ~
92
.    ds /
93
.\}
94
.if t \{\
95
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101
.\}
102
.    \" troff and (daisy-wheel) nroff accents
103
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110
.ds ae a\h'-(\w'a'u*4/10)'e
111
.ds Ae A\h'-(\w'A'u*4/10)'E
112
.    \" corrections for vroff
113
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115
.    \" for low resolution devices (crt and lpr)
116
.if \n(.H>23 .if \n(.V>19 \
117
\{\
118
.    ds : e
119
.    ds 8 ss
120
.    ds o a
121
.    ds d- d\h'-1'\(ga
122
.    ds D- D\h'-1'\(hy
123
.    ds th \o'bp'
124
.    ds Th \o'LP'
125
.    ds ae ae
126
.    ds Ae AE
127
.\}
128
.rm #[ #] #H #V #F C
129
.\" ========================================================================
130
.\"
131
.IX Title "DBIx::Custom::Result 3"
132
.TH DBIx::Custom::Result 3 "2011-08-02" "perl v5.8.8" "User Contributed Perl Documentation"
133
.SH "NAME"
134
DBIx::Custom::Result \- Result of select statement
135
.SH "SYNOPSIS"
136
.IX Header "SYNOPSIS"
137
.Vb 2
138
\&    # Result
139
\&    my $result = $dbi->select(table => 'book');
140
.Ve
141
.PP
142
.Vb 5
143
\&    # Fetch a row and put it into array reference
144
\&    while (my $row = $result->fetch) {
145
\&        my $author = $row->[0];
146
\&        my $title  = $row->[1];
147
\&    }
148
.Ve
149
.PP
150
.Vb 2
151
\&    # Fetch only a first row and put it into array reference
152
\&    my $row = $result->fetch_first;
153
.Ve
154
.PP
155
.Vb 2
156
\&    # Fetch all rows and put them into array of array reference
157
\&    my $rows = $result->fetch_all;
158
.Ve
159
.PP
160
.Vb 5
161
\&    # Fetch a row and put it into hash reference
162
\&    while (my $row = $result->fetch_hash) {
163
\&        my $title  = $row->{title};
164
\&        my $author = $row->{author};
165
\&    }
166
.Ve
167
.PP
168
.Vb 3
169
\&    # Fetch only a first row and put it into hash reference
170
\&    my $row = $result->fetch_hash_first;
171
\&    my $row = $result->one; # Same as fetch_hash_first
172
.Ve
173
.PP
174
.Vb 3
175
\&    # Fetch all rows and put them into array of hash reference
176
\&    my $rows = $result->fetch_hash_all;
177
\&    my $rows = $result->all; # Same as fetch_hash_all
178
.Ve
179
.SH "ATTRIBUTES"
180
.IX Header "ATTRIBUTES"
181
.ie n .Sh """dbi"""
182
.el .Sh "\f(CWdbi\fP"
183
.IX Subsection "dbi"
184
.Vb 2
185
\&    my $dbi = $result->dbi;
186
\&    $result = $result->dbi($dbi);
187
.Ve
188
.PP
189
DBIx::Custom object.
190
.ie n .Sh """sth"""
191
.el .Sh "\f(CWsth\fP"
192
.IX Subsection "sth"
193
.Vb 2
194
\&    my $sth = $reuslt->sth
195
\&    $result = $result->sth($sth);
196
.Ve
197
.PP
198
Statement handle of \s-1DBI\s0.
199
.SH "METHODS"
200
.IX Header "METHODS"
201
DBIx::Custom::Result inherits all methods from Object::Simple
202
and implements the following new ones.
203
.ie n .Sh """all"""
204
.el .Sh "\f(CWall\fP"
205
.IX Subsection "all"
206
.Vb 1
207
\&    my $rows = $result->all;
208
.Ve
209
.PP
210
Same as \f(CW\*(C`fetch_hash_all\*(C'\fR.
211
.ie n .Sh """fetch"""
212
.el .Sh "\f(CWfetch\fP"
213
.IX Subsection "fetch"
214
.Vb 1
215
\&    my $row = $result->fetch;
216
.Ve
217
.PP
218
Fetch a row and put it into array reference.
219
.ie n .Sh """fetch_all"""
220
.el .Sh "\f(CWfetch_all\fP"
221
.IX Subsection "fetch_all"
222
.Vb 1
223
\&    my $rows = $result->fetch_all;
224
.Ve
225
.PP
226
Fetch all rows and put them into array of array reference.
227
.ie n .Sh """fetch_first"""
228
.el .Sh "\f(CWfetch_first\fP"
229
.IX Subsection "fetch_first"
230
.Vb 1
231
\&    my $row = $result->fetch_first;
232
.Ve
233
.PP
234
Fetch only a first row and put it into array reference,
235
and finish statment handle.
236
.ie n .Sh """fetch_hash"""
237
.el .Sh "\f(CWfetch_hash\fP"
238
.IX Subsection "fetch_hash"
239
.Vb 1
240
\&    my $row = $result->fetch_hash;
241
.Ve
242
.PP
243
Fetch a row and put it into hash reference.
244
.ie n .Sh """fetch_hash_all"""
245
.el .Sh "\f(CWfetch_hash_all\fP"
246
.IX Subsection "fetch_hash_all"
247
.Vb 1
248
\&    my $rows = $result->fetch_hash_all;
249
.Ve
250
.PP
251
Fetch all rows and put them into array of hash reference.
252
.ie n .Sh """fetch_hash_first"""
253
.el .Sh "\f(CWfetch_hash_first\fP"
254
.IX Subsection "fetch_hash_first"
255
.Vb 1
256
\&    my $row = $result->fetch_hash_first;
257
.Ve
258
.PP
259
Fetch only a first row and put it into hash reference,
260
and finish statment handle.
261
.ie n .Sh """fetch_hash_multi"""
262
.el .Sh "\f(CWfetch_hash_multi\fP"
263
.IX Subsection "fetch_hash_multi"
264
.Vb 1
265
\&    my $rows = $result->fetch_hash_multi(5);
266
.Ve
267
.PP
268
Fetch multiple rows and put them into array of hash reference.
269
.ie n .Sh """fetch_multi"""
270
.el .Sh "\f(CWfetch_multi\fP"
271
.IX Subsection "fetch_multi"
272
.Vb 1
273
\&    my $rows = $result->fetch_multi(5);
274
.Ve
275
.PP
276
Fetch multiple rows and put them into array of array reference.
277
.ie n .Sh """filter"""
278
.el .Sh "\f(CWfilter\fP"
279
.IX Subsection "filter"
280
.Vb 2
281
\&    $result->filter(title  => sub { uc $_[0] }, author => 'to_upper');
282
\&    $result->filter([qw/title author/] => 'to_upper');
283
.Ve
284
.PP
285
Set filter for column.
286
You can use subroutine or filter name as filter.
287
This filter is executed after \f(CW\*(C`type_rule\*(C'\fR filter.
288
.ie n .Sh """filter_off"" \s-1EXPERIMENTAL\s0"
289
.el .Sh "\f(CWfilter_off\fP \s-1EXPERIMENTAL\s0"
290
.IX Subsection "filter_off EXPERIMENTAL"
291
.Vb 1
292
\&    $result = $result->filter_off;
293
.Ve
294
.PP
295
Turn filtering by \f(CW\*(C`filter\*(C'\fR method off.
296
By default, filterin is on.
297
.ie n .Sh """filter_on"" \s-1EXPERIMENTAL\s0"
298
.el .Sh "\f(CWfilter_on\fP \s-1EXPERIMENTAL\s0"
299
.IX Subsection "filter_on EXPERIMENTAL"
300
.Vb 1
301
\&    $result = $resutl->filter_on;
302
.Ve
303
.PP
304
Turn filtering by \f(CW\*(C`filter\*(C'\fR method on.
305
By default, filterin is on.
306
.ie n .Sh """header"""
307
.el .Sh "\f(CWheader\fP"
308
.IX Subsection "header"
309
.Vb 1
310
\&    my $header = $result->header;
311
.Ve
312
.PP
313
Get header column names.
314
.ie n .Sh """one"""
315
.el .Sh "\f(CWone\fP"
316
.IX Subsection "one"
317
.Vb 1
318
\&    my $row = $result->one;
319
.Ve
320
.PP
321
Same as \f(CW\*(C`fetch_hash_first\*(C'\fR.
322
.ie n .Sh """stash"""
323
.el .Sh "\f(CWstash\fP"
324
.IX Subsection "stash"
325
.Vb 3
326
\&    my $stash = $result->stash;
327
\&    my $foo = $result->stash->{foo};
328
\&    $result->stash->{foo} = $foo;
329
.Ve
330
.PP
331
Stash is hash reference for data.
332
.ie n .Sh """type_rule"" \s-1EXPERIMENTAL\s0"
333
.el .Sh "\f(CWtype_rule\fP \s-1EXPERIMENTAL\s0"
334
.IX Subsection "type_rule EXPERIMENTAL"
335
.Vb 7
336
\&    # Merge type rule
337
\&    $result->type_rule(
338
\&        # DATE
339
\&        9 => sub { ... },
340
\&        # DATETIME or TIMESTAMP
341
\&        11 => sub { ... }
342
\&    );
343
.Ve
344
.PP
345
.Vb 7
346
\&    # Replace type rule(by reference)
347
\&    $result->type_rule([
348
\&        # DATE
349
\&        9 => sub { ... },
350
\&        # DATETIME or TIMESTAMP
351
\&        11 => sub { ... }
352
\&    ]);
353
.Ve
354
.PP
355
This is same as DBIx::Custom's \f(CW\*(C`type_rule\*(C'\fR's <from>.
356
.ie n .Sh """type_rule_off"" \s-1EXPERIMENTAL\s0"
357
.el .Sh "\f(CWtype_rule_off\fP \s-1EXPERIMENTAL\s0"
358
.IX Subsection "type_rule_off EXPERIMENTAL"
359
.Vb 1
360
\&    $result = $result->type_rule_off;
361
.Ve
362
.PP
363
Turn \f(CW\*(C`from1\*(C'\fR and \f(CW\*(C`from2\*(C'\fR type rule off.
364
By default, type rule is on.
365
.ie n .Sh """type_rule_on"" \s-1EXPERIMENTAL\s0"
366
.el .Sh "\f(CWtype_rule_on\fP \s-1EXPERIMENTAL\s0"
367
.IX Subsection "type_rule_on EXPERIMENTAL"
368
.Vb 1
369
\&    $result = $result->type_rule_on;
370
.Ve
371
.PP
372
Turn \f(CW\*(C`from1\*(C'\fR and \f(CW\*(C`from2\*(C'\fR type rule on.
373
By default, type rule is on.
374
.ie n .Sh """type_rule1_off"" \s-1EXPERIMENTAL\s0"
375
.el .Sh "\f(CWtype_rule1_off\fP \s-1EXPERIMENTAL\s0"
376
.IX Subsection "type_rule1_off EXPERIMENTAL"
377
.Vb 1
378
\&    $result = $result->type_rule1_off;
379
.Ve
380
.PP
381
Turn \f(CW\*(C`from1\*(C'\fR type rule off.
382
By default, type rule is on.
383
.ie n .Sh """type_rule1_on"" \s-1EXPERIMENTAL\s0"
384
.el .Sh "\f(CWtype_rule1_on\fP \s-1EXPERIMENTAL\s0"
385
.IX Subsection "type_rule1_on EXPERIMENTAL"
386
.Vb 1
387
\&    $result = $result->type_rule1_on;
388
.Ve
389
.PP
390
Turn \f(CW\*(C`from1\*(C'\fR type rule on.
391
By default, type rule is on.
392
.ie n .Sh """type_rule2_off"" \s-1EXPERIMENTAL\s0"
393
.el .Sh "\f(CWtype_rule2_off\fP \s-1EXPERIMENTAL\s0"
394
.IX Subsection "type_rule2_off EXPERIMENTAL"
395
.Vb 1
396
\&    $result = $result->type_rule2_off;
397
.Ve
398
.PP
399
Turn \f(CW\*(C`from2\*(C'\fR type rule off.
400
By default, type rule is on.
401
.ie n .Sh """type_rule2_on"" \s-1EXPERIMENTAL\s0"
402
.el .Sh "\f(CWtype_rule2_on\fP \s-1EXPERIMENTAL\s0"
403
.IX Subsection "type_rule2_on EXPERIMENTAL"
404
.Vb 1
405
\&    $result = $result->type_rule2_on;
406
.Ve
407
.PP
408
Turn \f(CW\*(C`from2\*(C'\fR type rule on.
409
By default, type rule is on.