packaging one directory
|
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::SQL::Template 3" |
|
132 |
.TH DBIx::Custom::SQL::Template 3 "2009-11-16" "perl v5.8.8" "User Contributed Perl Documentation" |
|
133 |
.SH "NAME" |
|
134 |
DBIx::Custom::SQL::Template \- Custamizable SQL Template for DBIx::Custom |
|
135 |
.SH "VERSION" |
|
136 |
.IX Header "VERSION" |
|
137 |
Version 0.0101 |
|
138 |
.SH "SYNOPSIS" |
|
139 |
.IX Header "SYNOPSIS" |
|
140 |
.Vb 1 |
|
141 |
\& my $sql_tmpl = DBIx::Custom::SQL::Template->new; |
|
142 |
.Ve |
|
143 |
.PP |
|
144 |
.Vb 2 |
|
145 |
\& my $tmpl = "select from table {= k1} && {<> k2} || {like k3}"; |
|
146 |
\& my $param = {k1 => 1, k2 => 2, k3 => 3}; |
|
147 |
.Ve |
|
148 |
.PP |
|
149 |
.Vb 1 |
|
150 |
\& my $query = $sql_template->create_query($tmpl); |
|
151 |
.Ve |
|
152 |
.PP |
|
153 |
.Vb 8 |
|
154 |
\& # Using query from DBIx::Custom |
|
155 |
\& use DBIx::Custom; |
|
156 |
\& my $dbi = DBI->new( |
|
157 |
\& data_source => $data_source, |
|
158 |
\& user => $user, |
|
159 |
\& password => $password, |
|
160 |
\& dbi_options => {PrintError => 0, RaiseError => 1} |
|
161 |
\& ); |
|
162 |
.Ve |
|
163 |
.PP |
|
164 |
.Vb 2 |
|
165 |
\& $query = $dbi->create_query($tmpl); # This is SQL::Template create_query |
|
166 |
\& $dbi->query($query, $param); |
|
167 |
.Ve |
|
168 |
.SH "CLASS-OBJECT ACCESSORS" |
|
169 |
.IX Header "CLASS-OBJECT ACCESSORS" |
|
170 |
Class-Object accessor is used from both object and class |
|
171 |
.PP |
|
172 |
.Vb 2 |
|
173 |
\& $class->$accessor # call from class |
|
174 |
\& $self->$accessor # call form object |
|
175 |
.Ve |
|
176 |
.Sh "tag_processors" |
|
177 |
.IX Subsection "tag_processors" |
|
178 |
.Vb 3 |
|
179 |
\& # Set and get |
|
180 |
\& $self = $sql_tmpl->tag_processors($tag_processors); |
|
181 |
\& $tag_processors = $sql_tmpl->tag_processors; |
|
182 |
.Ve |
|
183 |
.PP |
|
184 |
.Vb 5 |
|
185 |
\& # Sample |
|
186 |
\& $sql_tmpl->tag_processors( |
|
187 |
\& '?' => \e&expand_question, |
|
188 |
\& '=' => \e&expand_equel |
|
189 |
\& ); |
|
190 |
.Ve |
|
191 |
.PP |
|
192 |
You can use add_tag_processor to add tag processor |
|
193 |
.Sh "tag_start" |
|
194 |
.IX Subsection "tag_start" |
|
195 |
.Vb 3 |
|
196 |
\& # Set and get |
|
197 |
\& $self = $sql_tmpl->tag_start($tag_start); |
|
198 |
\& $tag_start = $sql_tmpl->tag_start; |
|
199 |
.Ve |
|
200 |
.PP |
|
201 |
.Vb 2 |
|
202 |
\& # Sample |
|
203 |
\& $sql_tmpl->tag_start('{'); |
|
204 |
.Ve |
|
205 |
.PP |
|
206 |
Default is '{' |
|
207 |
.Sh "tag_end" |
|
208 |
.IX Subsection "tag_end" |
|
209 |
.Vb 3 |
|
210 |
\& # Set and get |
|
211 |
\& $self = $sql_tmpl->tag_start($tag_end); |
|
212 |
\& $tag_end = $sql_tmpl->tag_start; |
|
213 |
.Ve |
|
214 |
.PP |
|
215 |
.Vb 2 |
|
216 |
\& # Sample |
|
217 |
\& $sql_tmpl->tag_start('}'); |
|
218 |
.Ve |
|
219 |
.PP |
|
220 |
Default is '}' |
|
221 |
.Sh "tag_syntax" |
|
222 |
.IX Subsection "tag_syntax" |
|
223 |
.Vb 3 |
|
224 |
\& # Set and get |
|
225 |
\& $self = $sql_tmpl->tag_syntax($tag_syntax); |
|
226 |
\& $tag_syntax = $sql_tmpl->tag_syntax; |
|
227 |
.Ve |
|
228 |
.PP |
|
229 |
.Vb 7 |
|
230 |
\& # Sample |
|
231 |
\& $sql_tmpl->tag_syntax( |
|
232 |
\& "[Tag] [Expand]\en" . |
|
233 |
\& "{? name} ?\en" . |
|
234 |
\& "{= name} name = ?\en" . |
|
235 |
\& "{<> name} name <> ?\en" |
|
236 |
\& ); |
|
237 |
.Ve |
|
238 |
.SH "METHODS" |
|
239 |
.IX Header "METHODS" |
|
240 |
.Sh "create_query" |
|
241 |
.IX Subsection "create_query" |
|
242 |
.Vb 2 |
|
243 |
\& # Create SQL form SQL template |
|
244 |
\& $query = $sql_tmpl->create_query($tmpl); |
|
245 |
.Ve |
|
246 |
.PP |
|
247 |
.Vb 3 |
|
248 |
\& # Sample |
|
249 |
\& $query = $sql_tmpl->create_sql( |
|
250 |
\& "select * from table where {= title} && {like author} || {<= price}") |
|
251 |
.Ve |
|
252 |
.PP |
|
253 |
.Vb 3 |
|
254 |
\& # Result |
|
255 |
\& $qeury->{sql} : "select * from table where title = ? && author like ? price <= ?;" |
|
256 |
\& $query->{key_infos} : [['title'], ['author'], ['price']] |
|
257 |
.Ve |
|
258 |
.PP |
|
259 |
.Vb 5 |
|
260 |
\& # Sample2 (with table name) |
|
261 |
\& ($sql, @bind_values) = $sql_tmpl->create_sql( |
|
262 |
\& "select * from table where {= table.title} && {like table.author}", |
|
263 |
\& {table => {title => 'Perl', author => '%Taro%'}} |
|
264 |
\& ) |
|
265 |
.Ve |
|
266 |
.PP |
|
267 |
.Vb 4 |
|
268 |
\& # Result2 |
|
269 |
\& $query->{sql} : "select * from table where table.title = ? && table.title like ?;" |
|
270 |
\& $query->{key_infos} :[ [['table.title'],['table', 'title']], |
|
271 |
\& [['table.author'],['table', 'author']] ] |
|
272 |
.Ve |
|
273 |
.PP |
|
274 |
This method create query using by DBIx::Custom. |
|
275 |
query is two infomation |
|
276 |
.PP |
|
277 |
.Vb 2 |
|
278 |
\& 1.sql : SQL |
|
279 |
\& 2.key_infos : Parameter access key information |
|
280 |
.Ve |
|
281 |
.Sh "add_tag_processor" |
|
282 |
.IX Subsection "add_tag_processor" |
|
283 |
Add tag processor |
|
284 |
.PP |
|
285 |
.Vb 2 |
|
286 |
\& # Add |
|
287 |
\& $self = $sql_tmpl->add_tag_processor($tag_processor); |
|
288 |
.Ve |
|
289 |
.PP |
|
290 |
.Vb 4 |
|
291 |
\& # Sample |
|
292 |
\& $sql_tmpl->add_tag_processor( |
|
293 |
\& '?' => sub { |
|
294 |
\& my ($tag_name, $tag_args) = @_; |
|
295 |
.Ve |
|
296 |
.PP |
|
297 |
.Vb 2 |
|
298 |
\& my $key1 = $tag_args->[0]; |
|
299 |
\& my $key2 = $tag_args->[1]; |
|
300 |
.Ve |
|
301 |
.PP |
|
302 |
.Vb 1 |
|
303 |
\& my $key_infos = []; |
|
304 |
.Ve |
|
305 |
.PP |
|
306 |
.Vb 1 |
|
307 |
\& # Expand tag and create key informations |
|
308 |
.Ve |
|
309 |
.PP |
|
310 |
.Vb 4 |
|
311 |
\& # Return expand tags and key informations |
|
312 |
\& return ($expand, $key_infos); |
|
313 |
\& } |
|
314 |
\& ); |
|
315 |
.Ve |
|
316 |
.PP |
|
317 |
Tag processor recieve 2 argument |
|
318 |
.PP |
|
319 |
.Vb 2 |
|
320 |
\& 1. Tag name (?, =, <>, or etc) |
|
321 |
\& 2. Tag arguments (arg1 and arg2 in {tag_name arg1 arg2}) |
|
322 |
.Ve |
|
323 |
.PP |
|
324 |
Tag processor return 2 value |
|
325 |
.PP |
|
326 |
.Vb 2 |
|
327 |
\& 1. Expanded Tag (For exsample, '{= title}' is expanded to 'title = ?') |
|
328 |
\& 2. Key infomations |
|
329 |
.Ve |
|
330 |
.PP |
|
331 |
You must be return expanded tag and key infomations. |
|
332 |
.PP |
|
333 |
Key information is a little complex. so I will explan this in future. |
|
334 |
.PP |
|
335 |
If you want to know more, Please see DBIx::Custom::SQL::Template source code. |
|
336 |
.Sh "clone" |
|
337 |
.IX Subsection "clone" |
|
338 |
.Vb 2 |
|
339 |
\& # Clone DBIx::Custom::SQL::Template object |
|
340 |
\& $clone = $self->clone; |
|
341 |
.Ve |
|
342 |
.SH "Available Tags" |
|
343 |
.IX Header "Available Tags" |
|
344 |
.Vb 5 |
|
345 |
\& # Available Tags |
|
346 |
\& [tag] [expand] |
|
347 |
\& {? name} ? |
|
348 |
\& {= name} name = ? |
|
349 |
\& {<> name} name <> ? |
|
350 |
.Ve |
|
351 |
.PP |
|
352 |
.Vb 4 |
|
353 |
\& {< name} name < ? |
|
354 |
\& {> name} name > ? |
|
355 |
\& {>= name} name >= ? |
|
356 |
\& {<= name} name <= ? |
|
357 |
.Ve |
|
358 |
.PP |
|
359 |
.Vb 2 |
|
360 |
\& {like name} name like ? |
|
361 |
\& {in name} name in [?, ?, ..] |
|
362 |
.Ve |
|
363 |
.PP |
|
364 |
.Vb 2 |
|
365 |
\& {insert} (key1, key2, key3) values (?, ?, ?) |
|
366 |
\& {update} set key1 = ?, key2 = ?, key3 = ? |
|
367 |
.Ve |
|
368 |
.PP |
|
369 |
.Vb 6 |
|
370 |
\& # Sample1 |
|
371 |
\& $query = $sql_tmpl->create_sql( |
|
372 |
\& "insert into table {insert key1 key2}" |
|
373 |
\& ); |
|
374 |
\& # Result1 |
|
375 |
\& $sql : "insert into table (key1, key2) values (?, ?)" |
|
376 |
.Ve |
|
377 |
.PP |
|
378 |
.Vb 4 |
|
379 |
\& # Sample2 |
|
380 |
\& $query = $sql_tmpl->create_sql( |
|
381 |
\& "update table {update key1 key2} where {= key3}" |
|
382 |
\& ); |
|
383 |
.Ve |
|
384 |
.PP |
|
385 |
.Vb 2 |
|
386 |
\& # Result2 |
|
387 |
\& $query->{sql} : "update table set key1 = ?, key2 = ? where key3 = ?;" |
|
388 |
.Ve |
|
389 |
.SH "AUTHOR" |
|
390 |
.IX Header "AUTHOR" |
|
391 |
Yuki Kimoto, \f(CW\*(C`<kimoto.yuki at gmail.com>\*(C'\fR |
|
392 |
.PP |
|
393 |
Github |
|
394 |
<http://github.com/yuki\-kimoto> |
|
395 |
<http://github.com/yuki\-kimoto/DBIx\-Custom\-SQL\-Template> |
|
396 |
.PP |
|
397 |
Please let know me bag if you find |
|
398 |
Please request me if you want to do something |
|
399 |
.SH "COPYRIGHT & LICENSE" |
|
400 |
.IX Header "COPYRIGHT & LICENSE" |
|
401 |
Copyright 2009 Yuki Kimoto, all rights reserved. |
|
402 |
.PP |
|
403 |
This program is free software; you can redistribute it and/or modify it |
|
404 |
under the same terms as Perl itself. |