DBIx-Custom / DBIx-Custom-0.0501 / blib / libdoc / DBIx::Custom::Result.3pm /
Newer Older
367 lines | 9.304kb
packaging one directory
yuki-kimoto authored on 2009-11-16
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 "2009-11-16" "perl v5.8.8" "User Contributed Perl Documentation"
133
.SH "NAME"
134
DBIx::Custom::Result \- Resultset for DBIx::Custom
135
.SH "VERSION"
136
.IX Header "VERSION"
137
Version 0.0301
138
.SH "SYNOPSIS"
139
.IX Header "SYNOPSIS"
140
.Vb 3
141
\&    # $result is DBIx::Custom::Result object
142
\&    my $dbi = DBIx::Custom->new;
143
\&    my $result = $dbi->query($sql_template, $param);
144
.Ve
145
.PP
146
.Vb 3
147
\&    while (my ($val1, $val2) = $result->fetch) {
148
\&        # do something
149
\&    }
150
.Ve
151
.SH "OBJECT ACCESSORS"
152
.IX Header "OBJECT ACCESSORS"
153
.Sh "sth"
154
.IX Subsection "sth"
155
.Vb 3
156
\&    # Set and Get statement handle
157
\&    $self = $result->sth($sth);
158
\&    $sth  = $reuslt->sth
159
.Ve
160
.PP
161
Statement handle is automatically set by DBIx::Custom.
162
so you do not set statement handle.
163
.PP
164
If you need statement handle, you can get statement handle by using this method.
165
.Sh "fetch_filter"
166
.IX Subsection "fetch_filter"
167
.Vb 3
168
\&    # Set and Get fetch filter
169
\&    $self         = $result->fetch_filter($sth);
170
\&    $fetch_filter = $result->fech_filter;
171
.Ve
172
.PP
173
Statement handle is automatically set by DBIx::Custom.
174
If you want to set your fetch filter, you set it.
175
.Sh "no_fetch_filters"
176
.IX Subsection "no_fetch_filters"
177
.Vb 3
178
\&    # Set and Get no filter keys when fetching
179
\&    $self             = $result->no_fetch_filters($no_fetch_filters);
180
\&    $no_fetch_filters = $result->no_fetch_filters;
181
.Ve
182
.SH "METHODS"
183
.IX Header "METHODS"
184
.Sh "fetch"
185
.IX Subsection "fetch"
186
.Vb 2
187
\&    # Fetch row as array reference (Scalar context)
188
\&    $row = $result->fetch;
189
.Ve
190
.PP
191
.Vb 2
192
\&    # Fetch row as array (List context)
193
\&    @row = $result->fecth
194
.Ve
195
.PP
196
.Vb 6
197
\&    # Sample
198
\&    while (my $row = $result->fetch) {
199
\&        # do something
200
\&        my $val1 = $row->[0];
201
\&        my $val2 = $row->[1];
202
\&    }
203
.Ve
204
.PP
205
fetch method is fetch resultset and get row as array or array reference.
206
.Sh "fetch_hash"
207
.IX Subsection "fetch_hash"
208
.Vb 2
209
\&    # Fetch row as hash reference (Scalar context)
210
\&    $row = $result->fetch_hash;
211
.Ve
212
.PP
213
.Vb 2
214
\&    # Fetch row as hash (List context)
215
\&    %row = $result->fecth_hash
216
.Ve
217
.PP
218
.Vb 6
219
\&    # Sample
220
\&    while (my $row = $result->fetch_hash) {
221
\&        # do something
222
\&        my $val1 = $row->{key1};
223
\&        my $val2 = $row->{key2};
224
\&    }
225
.Ve
226
.PP
227
fetch_hash method is fetch resultset and get row as hash or hash reference.
228
.Sh "fetch_first"
229
.IX Subsection "fetch_first"
230
.Vb 2
231
\&    # Fetch only first (Scalar context)
232
\&    $row = $result->fetch_first;
233
.Ve
234
.PP
235
.Vb 2
236
\&    # Fetch only first (List context)
237
\&    @row = $result->fetch_first;
238
.Ve
239
.PP
240
This method fetch only first and finish statement handle
241
.Sh "fetch_hash_first"
242
.IX Subsection "fetch_hash_first"
243
.Vb 2
244
\&    # Fetch only first as hash (Scalar context)
245
\&    $row = $result->fetch_hash_first;
246
.Ve
247
.PP
248
.Vb 2
249
\&    # Fetch only first as hash (Scalar context)
250
\&    @row = $result->fetch_hash_first;
251
.Ve
252
.PP
253
This method fetch only first and finish statement handle
254
.Sh "fetch_rows"
255
.IX Subsection "fetch_rows"
256
.Vb 2
257
\&    # Fetch multi rows (Scalar context)
258
\&    $rows = $result->fetch_rows($row_count);
259
.Ve
260
.PP
261
.Vb 2
262
\&    # Fetch multi rows (List context)
263
\&    @rows = $result->fetch_rows($row_count);
264
.Ve
265
.PP
266
.Vb 2
267
\&    # Sapmle 
268
\&    $rows = $result->fetch_rows(10);
269
.Ve
270
.Sh "fetch_hash_rows"
271
.IX Subsection "fetch_hash_rows"
272
.Vb 2
273
\&    # Fetch multi rows as hash (Scalar context)
274
\&    $rows = $result->fetch_hash_rows($row_count);
275
.Ve
276
.PP
277
.Vb 2
278
\&    # Fetch multi rows as hash (List context)
279
\&    @rows = $result->fetch_hash_rows($row_count);
280
.Ve
281
.PP
282
.Vb 2
283
\&    # Sapmle 
284
\&    $rows = $result->fetch_hash_rows(10);
285
.Ve
286
.Sh "fetch_all"
287
.IX Subsection "fetch_all"
288
.Vb 2
289
\&    # Fetch all row as array ref of array ref (Scalar context)
290
\&    $rows = $result->fetch_all;
291
.Ve
292
.PP
293
.Vb 2
294
\&    # Fetch all row as array of array ref (List context)
295
\&    @rows = $result->fecth_all;
296
.Ve
297
.PP
298
.Vb 4
299
\&    # Sample
300
\&    my $rows = $result->fetch_all;
301
\&    my $val0_0 = $rows->[0][0];
302
\&    my $val1_1 = $rows->[1][1];
303
.Ve
304
.PP
305
fetch_all method is fetch resultset and get all rows as array or array reference.
306
.Sh "fetch_hash_all"
307
.IX Subsection "fetch_hash_all"
308
.Vb 2
309
\&    # Fetch all row as array ref of hash ref (Scalar context)
310
\&    $rows = $result->fetch_hash_all;
311
.Ve
312
.PP
313
.Vb 2
314
\&    # Fetch all row as array of hash ref (List context)
315
\&    @rows = $result->fecth_all_hash;
316
.Ve
317
.PP
318
.Vb 4
319
\&    # Sample
320
\&    my $rows = $result->fetch_hash_all;
321
\&    my $val0_key1 = $rows->[0]{key1};
322
\&    my $val1_key2 = $rows->[1]{key2};
323
.Ve
324
.Sh "error"
325
.IX Subsection "error"
326
.Vb 3
327
\&    # Get error infomation
328
\&    $error_messege = $result->error;
329
\&    ($error_message, $error_number, $error_state) = $result->error;
330
.Ve
331
.PP
332
You can get get information. This is crenspond to the following.
333
.PP
334
.Vb 3
335
\&    $error_message : $result->sth->errstr
336
\&    $error_number  : $result->sth->err
337
\&    $error_state   : $result->sth->state
338
.Ve
339
.Sh "finish"
340
.IX Subsection "finish"
341
.Vb 2
342
\&    # Finish statement handle
343
\&    $result->finish
344
.Ve
345
.PP
346
.Vb 3
347
\&    # Sample
348
\&    my $row = $reuslt->fetch; # fetch only one row
349
\&    $result->finish
350
.Ve
351
.PP
352
You can finish statement handle.This is equel to
353
.PP
354
.Vb 1
355
\&    $result->sth->finish;
356
.Ve
357
.SH "AUTHOR"
358
.IX Header "AUTHOR"
359
Yuki Kimoto, \f(CW\*(C`<kimoto.yuki at gmail.com>\*(C'\fR
360
.PP
361
Github <http://github.com/yuki\-kimoto>
362
.SH "COPYRIGHT & LICENSE"
363
.IX Header "COPYRIGHT & LICENSE"
364
Copyright 2009 Yuki Kimoto, all rights reserved.
365
.PP
366
This program is free software; you can redistribute it and/or modify it
367
under the same terms as Perl itself.