Newer Older
649 lines | 17.497kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::SQL::Template;
cleanup
yuki-kimoto authored on 2009-12-22
2
use base 'Object::Simple::Base';
packaging one directory
yuki-kimoto authored on 2009-11-16
3

            
update document
yuki-kimoto authored on 2009-11-17
4
use strict;
5
use warnings;
packaging one directory
yuki-kimoto authored on 2009-11-16
6
use Carp 'croak';
7

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
8
use DBIx::Custom::Query;
9

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
10
__PACKAGE__->dual_attr('tag_processors', default => sub { {} },
cleanup
yuki-kimoto authored on 2010-01-21
11
                                         inherit   => 'hash');
cleanup
yuki-kimoto authored on 2009-12-22
12

            
cleanup
yuki-kimoto authored on 2010-01-21
13
__PACKAGE__->dual_attr('tag_start', default => '{', inherit => 'scalar');
14
__PACKAGE__->dual_attr('tag_end',   default => '}', inherit => 'scalar');
cleanup
yuki-kimoto authored on 2009-12-22
15

            
cleanup
yuki-kimoto authored on 2010-01-21
16
__PACKAGE__->dual_attr('tag_syntax', inherit => 'scalar');
cleanup
yuki-kimoto authored on 2009-12-22
17

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
18
__PACKAGE__->add_tag_processor(
cleanup
yuki-kimoto authored on 2009-12-17
19
    '?'      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
20
    '='      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
21
    '<>'     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
22
    '>'      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
23
    '<'      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
24
    '>='     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
25
    '<='     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
26
    'like'   => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
27
    'in'     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_in_tag,
28
    'insert' => \&DBIx::Custom::SQL::Template::TagProcessors::expand_insert_tag,
29
    'update' => \&DBIx::Custom::SQL::Template::TagProcessors::expand_update_tag
30
);
packaging one directory
yuki-kimoto authored on 2009-11-16
31

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
32
__PACKAGE__->tag_syntax(<< 'EOS');
packaging one directory
yuki-kimoto authored on 2009-11-16
33
[tag]                     [expand]
34
{? name}                  ?
35
{= name}                  name = ?
36
{<> name}                 name <> ?
37

            
38
{< name}                  name < ?
39
{> name}                  name > ?
40
{>= name}                 name >= ?
41
{<= name}                 name <= ?
42

            
43
{like name}               name like ?
44
{in name number}          name in [?, ?, ..]
45

            
46
{insert key1 key2} (key1, key2) values (?, ?)
47
{update key1 key2}    set key1 = ?, key2 = ?
48
EOS
49

            
50

            
51
# Add Tag processor
52
sub add_tag_processor {
53
    my $invocant = shift;
54
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
55
    $invocant->tag_processors({%{$invocant->tag_processors}, %{$tag_processors}});
packaging one directory
yuki-kimoto authored on 2009-11-16
56
    return $invocant;
57
}
58

            
59
# Clone
60
sub clone {
61
    my $self = shift;
62
    my $new = $self->new;
63
    
64
    $new->tag_start($self->tag_start);
65
    $new->tag_end($self->tag_end);
66
    $new->tag_syntax($self->tag_syntax);
67
    $new->tag_processors({%{$self->tag_processors || {}}});
68
    
69
    return $new;
70
}
71

            
72

            
73
### Object Methods
74

            
75
# Create Query
76
sub create_query {
77
    my ($self, $template)  = @_;
78
    
79
    # Parse template
80
    my $tree = $self->_parse_template($template);
81
    
82
    # Build query
83
    my $query = $self->_build_query($tree);
84
    
85
    return $query;
86
}
87

            
88
# Parse template
89
sub _parse_template {
90
    my ($self, $template) = @_;
91
    $template ||= '';
92
    
93
    my $tree = [];
94
    
95
    # Tags
96
    my $tag_start = quotemeta $self->tag_start;
97
    my $tag_end   = quotemeta $self->tag_end;
98
    
99
    # Tokenize
100
    my $state = 'text';
101
    
102
    # Save original template
103
    my $original_template = $template;
104
    
105
    # Parse template
106
    while ($template =~ s/([^$tag_start]*?)$tag_start([^$tag_end].*?)$tag_end//sm) {
107
        my $text = $1;
108
        my $tag  = $2;
109
        
110
        # Parse tree
111
        push @$tree, {type => 'text', tag_args => [$text]} if $text;
112
        
113
        if ($tag) {
114
            # Get tag name and arguments
115
            my ($tag_name, @tag_args) = split /\s+/, $tag;
116
            
117
            # Tag processor is exist?
118
            unless ($self->tag_processors->{$tag_name}) {
119
                my $tag_syntax = $self->tag_syntax;
120
                croak("Tag '{$tag}' in SQL template is not exist.\n\n" .
121
                      "<SQL template tag syntax>\n" .
122
                      "$tag_syntax\n" .
123
                      "<Your SQL template>\n" .
124
                      "$original_template\n\n");
125
            }
126
            
127
            # Check tag arguments
128
            foreach my $tag_arg (@tag_args) {
129
                # Cannot cantain placehosder '?'
130
                croak("Tag '{t }' arguments cannot contain '?'")
131
                  if $tag_arg =~ /\?/;
132
            }
133
            
134
            # Add tag to parsing tree
135
            push @$tree, {type => 'tag', tag_name => $tag_name, tag_args => [@tag_args]};
136
        }
137
    }
138
    
139
    # Add text to parsing tree 
140
    push @$tree, {type => 'text', tag_args => [$template]} if $template;
141
    
142
    return $tree;
143
}
144

            
145
# Build SQL from parsing tree
146
sub _build_query {
147
    my ($self, $tree) = @_;
148
    
149
    # SQL
150
    my $sql = '';
151
    
152
    # All parameter key infomation
153
    my $all_key_infos = [];
154
    
155
    # Build SQL 
156
    foreach my $node (@$tree) {
157
        
158
        # Get type, tag name, and arguments
159
        my $type     = $node->{type};
160
        my $tag_name = $node->{tag_name};
161
        my $tag_args = $node->{tag_args};
162
        
163
        # Text
164
        if ($type eq 'text') {
165
            # Join text
166
            $sql .= $tag_args->[0];
167
        }
168
        
169
        # Tag
170
        elsif ($type eq 'tag') {
171
            
172
            # Get tag processor
173
            my $tag_processor = $self->tag_processors->{$tag_name};
174
            
175
            # Tag processor is code ref?
176
            croak("Tag processor '$tag_name' must be code reference")
177
              unless ref $tag_processor eq 'CODE';
178
            
179
            # Expand tag using tag processor
180
            my ($expand, $key_infos)
181
              = $tag_processor->($tag_name, $tag_args);
182
            
183
            # Check tag processor return value
184
            croak("Tag processor '$tag_name' must return (\$expand, \$key_infos)")
185
              if !defined $expand || ref $key_infos ne 'ARRAY';
186
            
187
            # Check placeholder count
188
            croak("Placeholder count in SQL created by tag processor '$tag_name' " .
189
                  "must be same as key informations count")
190
              unless $self->_placeholder_count($expand) eq @$key_infos;
191
            
192
            # Add key information
193
            push @$all_key_infos, @$key_infos;
194
            
195
            # Join expand tag to SQL
196
            $sql .= $expand;
197
        }
198
    }
199
    
200
    # Add semicolon
201
    $sql .= ';' unless $sql =~ /;$/;
202
    
203
    # Query
cleanup and update docment
yuki-kimoto authored on 2009-11-19
204
    my $query = DBIx::Custom::Query->new(sql => $sql, key_infos => $all_key_infos);
packaging one directory
yuki-kimoto authored on 2009-11-16
205
    
206
    return $query;
207
}
208

            
209
# Get placeholder count
210
sub _placeholder_count {
211
    my ($self, $expand) = @_;
212
    $expand ||= '';
213
    
214
    my $count = 0;
215
    my $pos   = -1;
216
    while (($pos = index($expand, '?', $pos + 1)) != -1) {
217
        $count++;
218
    }
219
    return $count;
220
}
221

            
cleanup
yuki-kimoto authored on 2009-12-17
222
1;
packaging one directory
yuki-kimoto authored on 2009-11-16
223

            
224

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
225
package DBIx::Custom::SQL::Template::TagProcessors;
226

            
packaging one directory
yuki-kimoto authored on 2009-11-16
227
use strict;
228
use warnings;
229
use Carp 'croak';
230

            
231
# Expand tag '?', '=', '<>', '>', '<', '>=', '<=', 'like'
232
sub expand_basic_tag {
233
    my ($tag_name, $tag_args) = @_;
234
    my $original_key = $tag_args->[0];
235
    
236
    # Key is not exist
237
    croak("You must be pass key as argument to tag '{$tag_name }'")
238
      if !$original_key;
239
    
240
    # Expanded tag
241
    my $expand = $tag_name eq '?'
242
               ? '?'
243
               : "$original_key $tag_name ?";
244
    
245
    # Get table and clumn name
246
    my ($table, $column) = get_table_and_column($original_key);
247
    
248
    # Parameter key infomation
249
    my $key_info = {};
250
    
251
    # Original key
252
    $key_info->{original_key} = $original_key;
253
    
254
    # Table
255
    $key_info->{table}  = $table;
256
    
257
    # Column name
258
    $key_info->{column} = $column;
259
    
260
    # Access keys
261
    my $access_keys = [];
262
    push @$access_keys, [$original_key];
263
    push @$access_keys, [$table, $column] if $table && $column;
264
    $key_info->{access_keys} = $access_keys;
265
    
266
    # Add parameter key information
267
    my $key_infos = [];
268
    push @$key_infos, $key_info;
269
    
270
    return ($expand, $key_infos);
271
}
272

            
273
# Expand tag 'in'
274
sub expand_in_tag {
275
    my ($tag_name, $tag_args) = @_;
276
    my ($original_key, $placeholder_count) = @$tag_args;
277
    
278
    # Key must be specified
279
    croak("You must be pass key as first argument of tag '{$tag_name }'\n" . 
280
          "Usage: {$tag_name \$key \$placeholder_count}")
281
      unless $original_key;
282
      
283
    
284
    # Place holder count must be specified
285
    croak("You must be pass placeholder count as second argument of tag '{$tag_name }'\n" . 
286
          "Usage: {$tag_name \$key \$placeholder_count}")
287
      if !$placeholder_count || $placeholder_count =~ /\D/;
288

            
289
    # Expand tag
290
    my $expand = "$original_key $tag_name (";
291
    for (my $i = 0; $i < $placeholder_count; $i++) {
292
        $expand .= '?, ';
293
    }
294
    
295
    $expand =~ s/, $//;
296
    $expand .= ')';
297
    
298
    # Get table and clumn name
299
    my ($table, $column) = get_table_and_column($original_key);
300
    
301
    # Create parameter key infomations
302
    my $key_infos = [];
303
    for (my $i = 0; $i < $placeholder_count; $i++) {
304
        # Parameter key infomation
305
        my $key_info = {};
306
        
307
        # Original key
308
        $key_info->{original_key} = $original_key;
309
        
310
        # Table
311
        $key_info->{table}   = $table;
312
        
313
        # Column name
314
        $key_info->{column}  = $column;
315
        
316
        # Access keys
317
        my $access_keys = [];
318
        push @$access_keys, [$original_key, [$i]];
319
        push @$access_keys, [$table, $column, [$i]] if $table && $column;
320
        $key_info->{access_keys} = $access_keys;
321
        
322
        # Add parameter key infos
323
        push @$key_infos, $key_info;
324
    }
325
    
326
    return ($expand, $key_infos);
327
}
328

            
329
# Get table and column
330
sub get_table_and_column {
331
    my $key = shift;
332
    $key ||= '';
333
    
334
    return ('', $key) unless $key =~ /\./;
335
    
336
    my ($table, $column) = split /\./, $key;
337
    
338
    return ($table, $column);
339
}
340

            
341
# Expand tag 'insert'
342
sub expand_insert_tag {
343
    my ($tag_name, $tag_args) = @_;
344
    my $original_keys = $tag_args;
345
    
346
    # Insert key (k1, k2, k3, ..)
347
    my $insert_keys = '(';
348
    
349
    # placeholder (?, ?, ?, ..)
350
    my $place_holders = '(';
351
    
352
    foreach my $original_key (@$original_keys) {
353
        # Get table and column
354
        my ($table, $column) = get_table_and_column($original_key);
355
        
356
        # Join insert column
357
        $insert_keys   .= "$column, ";
358
        
359
        # Join place holder
360
        $place_holders .= "?, ";
361
    }
362
    
363
    # Delete last ', '
364
    $insert_keys =~ s/, $//;
365
    
366
    # Close 
367
    $insert_keys .= ')';
368
    $place_holders =~ s/, $//;
369
    $place_holders .= ')';
370
    
371
    # Expand tag
372
    my $expand = "$insert_keys values $place_holders";
373
    
374
    # Create parameter key infomations
375
    my $key_infos = [];
376
    foreach my $original_key (@$original_keys) {
377
        # Get table and clumn name
378
        my ($table, $column) = get_table_and_column($original_key);
379
        
380
        # Parameter key infomation
381
        my $key_info = {};
382
        
383
        # Original key
384
        $key_info->{original_key} = $original_key;
385
        
386
        # Table
387
        $key_info->{table}   = $table;
388
        
389
        # Column name
390
        $key_info->{column}  = $column;
391
        
392
        # Access keys
393
        my $access_keys = [];
394
        push @$access_keys, ['#insert', $original_key];
395
        push @$access_keys, ['#insert', $table, $column] if $table && $column;
396
        push @$access_keys, [$original_key];
397
        push @$access_keys, [$table, $column] if $table && $column;
398
        $key_info->{access_keys} = $access_keys;
399
        
400
        # Add parameter key infos
401
        push @$key_infos, $key_info;
402
    }
403
    
404
    return ($expand, $key_infos);
405
}
406

            
407
# Expand tag 'update'
408
sub expand_update_tag {
409
    my ($tag_name, $tag_args) = @_;
410
    my $original_keys = $tag_args;
411
    
412
    # Expanded tag
413
    my $expand = 'set ';
414
    
415
    # 
416
    foreach my $original_key (@$original_keys) {
417
        # Get table and clumn name
418
        my ($table, $column) = get_table_and_column($original_key);
419

            
420
        # Join key and placeholder
421
        $expand .= "$column = ?, ";
422
    }
423
    
424
    # Delete last ', '
425
    $expand =~ s/, $//;
426
    
427
    # Create parameter key infomations
428
    my $key_infos = [];
429
    foreach my $original_key (@$original_keys) {
430
        # Get table and clumn name
431
        my ($table, $column) = get_table_and_column($original_key);
432
        
433
        # Parameter key infomation
434
        my $key_info = {};
435
        
436
        # Original key
437
        $key_info->{original_key} = $original_key;
438
        
439
        # Table
440
        $key_info->{table}  = $table;
441
        
442
        # Column name
443
        $key_info->{column} = $column;
444
        
445
        # Access keys
446
        my $access_keys = [];
447
        push @$access_keys, ['#update', $original_key];
448
        push @$access_keys, ['#update', $table, $column] if $table && $column;
449
        push @$access_keys, [$original_key];
450
        push @$access_keys, [$table, $column] if $table && $column;
451
        $key_info->{access_keys} = $access_keys;
452
        
453
        # Add parameter key infos
454
        push @$key_infos, $key_info;
455
    }
456
    
457
    return ($expand, $key_infos);
458
}
459

            
460
1;
461

            
462
=head1 NAME
463

            
update document
yuki-kimoto authored on 2009-11-17
464
DBIx::Custom::SQL::Template - DBIx::Custom SQL Template
packaging one directory
yuki-kimoto authored on 2009-11-16
465

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
466
=head1 Synopsis
packaging one directory
yuki-kimoto authored on 2009-11-16
467
    
468
    my $sql_tmpl = DBIx::Custom::SQL::Template->new;
469
    
470
    my $tmpl   = "select from table {= k1} && {<> k2} || {like k3}";
471
    my $param = {k1 => 1, k2 => 2, k3 => 3};
472
    
473
    my $query = $sql_template->create_query($tmpl);
474

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
475
=head1 Accessors
packaging one directory
yuki-kimoto authored on 2009-11-16
476

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
477
=head2 tag_processors
packaging one directory
yuki-kimoto authored on 2009-11-16
478

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
479
Set and get tag processors
packaging one directory
yuki-kimoto authored on 2009-11-16
480

            
version 0.0901
yuki-kimoto authored on 2009-12-17
481
    $sql_tmpl       = $sql_tmpl->tag_processors($name1 => $tag_processor1
482
                                                $name2 => $tag_processor2);
483
    $tag_processors = $sql_tmpl->tag_processors;
packaging one directory
yuki-kimoto authored on 2009-11-16
484

            
485
=head2 tag_start
486

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
487
Set and get start tag
488
    
version 0.0901
yuki-kimoto authored on 2009-12-17
489
    $sql_tmpl  = $sql_tmpl->tag_start('{');
490
    $tag_start = $sql_tmpl->tag_start;
packaging one directory
yuki-kimoto authored on 2009-11-16
491

            
version 0.0901
yuki-kimoto authored on 2009-12-17
492
tag_start default is '{'
packaging one directory
yuki-kimoto authored on 2009-11-16
493

            
494
=head2 tag_end
495

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
496
Set and get end tag
497
    
version 0.0901
yuki-kimoto authored on 2009-12-17
498
    $sql_tmpl    = $sql_tmpl->tag_start('}');
499
    $tag_end = $sql_tmpl->tag_start;
packaging one directory
yuki-kimoto authored on 2009-11-16
500

            
version 0.0901
yuki-kimoto authored on 2009-12-17
501
tag_start default is '}'
packaging one directory
yuki-kimoto authored on 2009-11-16
502
    
503
=head2 tag_syntax
504
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
505
Set and get tag syntax
506
    
version 0.0901
yuki-kimoto authored on 2009-12-17
507
    $sql_tmpl   = $sql_tmpl->tag_syntax($tag_syntax);
508
    $tag_syntax = $sql_tmpl->tag_syntax;
packaging one directory
yuki-kimoto authored on 2009-11-16
509

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
510
=head1 Methods
packaging one directory
yuki-kimoto authored on 2009-11-16
511

            
512
=head2 create_query
513
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
514
Create L<DBIx::Custom::Query> object parsing SQL template
515

            
version 0.0901
yuki-kimoto authored on 2009-12-17
516
    $query = $sql_tmpl->create_query($tmpl);
packaging one directory
yuki-kimoto authored on 2009-11-16
517
    
518
    # Sample
519
    $query = $sql_tmpl->create_sql(
520
         "select * from table where {= title} && {like author} || {<= price}")
521
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
522
    # Expanded
523
    $qeury->sql : "select * from table where title = ? && author like ? price <= ?;"
524
    $query->key_infos : [['title'], ['author'], ['price']]
packaging one directory
yuki-kimoto authored on 2009-11-16
525
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
526
    # Sample with table name
packaging one directory
yuki-kimoto authored on 2009-11-16
527
    ($sql, @bind_values) = $sql_tmpl->create_sql(
528
            "select * from table where {= table.title} && {like table.author}",
529
            {table => {title => 'Perl', author => '%Taro%'}}
530
        )
531
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
532
    # Expanded
533
    $query->sql : "select * from table where table.title = ? && table.title like ?;"
534
    $query->key_infos :[ [['table.title'],['table', 'title']],
535
                         [['table.author'],['table', 'author']] ]
packaging one directory
yuki-kimoto authored on 2009-11-16
536

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
537
This method create query using by L<DBIx::Custom>.
538
query has two infomation
packaging one directory
yuki-kimoto authored on 2009-11-16
539

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
540
    1. sql       : SQL
541
    2. key_infos : Parameter access key information
packaging one directory
yuki-kimoto authored on 2009-11-16
542

            
543
=head2 add_tag_processor
544

            
545
Add tag processor
cleanup and update docment
yuki-kimoto authored on 2009-11-19
546
    
version 0.0901
yuki-kimoto authored on 2009-12-17
547
    $sql_tmpl = $sql_tmpl->add_tag_processor($tag_processor);
548

            
549
The following is add_tag_processor sample
550

            
packaging one directory
yuki-kimoto authored on 2009-11-16
551
    $sql_tmpl->add_tag_processor(
552
        '?' => sub {
553
            my ($tag_name, $tag_args) = @_;
554
            
555
            my $key1 = $tag_args->[0];
556
            my $key2 = $tag_args->[1];
557
            
558
            my $key_infos = [];
559
            
560
            # Expand tag and create key informations
561
            
562
            # Return expand tags and key informations
563
            return ($expand, $key_infos);
564
        }
565
    );
566

            
567
Tag processor recieve 2 argument
568

            
569
    1. Tag name            (?, =, <>, or etc)
570
    2. Tag arguments       (arg1 and arg2 in {tag_name arg1 arg2})
571

            
572
Tag processor return 2 value
573

            
574
    1. Expanded Tag (For exsample, '{= title}' is expanded to 'title = ?')
575
    2. Key infomations
576
    
577
You must be return expanded tag and key infomations.
578

            
579
Key information is a little complex. so I will explan this in future.
580

            
581
If you want to know more, Please see DBIx::Custom::SQL::Template source code.
582

            
583
=head2 clone
584

            
cleanup and update docment
yuki-kimoto authored on 2009-11-19
585
Clone DBIx::Custom::SQL::Template object
586

            
version 0.0901
yuki-kimoto authored on 2009-12-17
587
    $clone = $sql_tmpl->clone;
packaging one directory
yuki-kimoto authored on 2009-11-16
588
    
589
=head1 Available Tags
590
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
591
Available Tags
592

            
packaging one directory
yuki-kimoto authored on 2009-11-16
593
    [tag]            [expand]
594
    {? name}         ?
595
    {= name}         name = ?
596
    {<> name}        name <> ?
597
    
598
    {< name}         name < ?
599
    {> name}         name > ?
600
    {>= name}        name >= ?
601
    {<= name}        name <= ?
602
    
603
    {like name}      name like ?
604
    {in name}        name in [?, ?, ..]
605
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
606
    {insert}         (key1, key2, key3) values (?, ?, ?)
607
    {update}         set key1 = ?, key2 = ?, key3 = ?
packaging one directory
yuki-kimoto authored on 2009-11-16
608
    
version 0.0901
yuki-kimoto authored on 2009-12-17
609

            
610
The following is insert SQL sample
611

            
packaging one directory
yuki-kimoto authored on 2009-11-16
612
    $query = $sql_tmpl->create_sql(
613
        "insert into table {insert key1 key2}"
614
    );
version 0.0901
yuki-kimoto authored on 2009-12-17
615
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
616
    # Expanded
617
    $query->sql : "insert into table (key1, key2) values (?, ?)"
version 0.0901
yuki-kimoto authored on 2009-12-17
618

            
619
The following is update SQL sample
packaging one directory
yuki-kimoto authored on 2009-11-16
620
    
621
    $query = $sql_tmpl->create_sql(
622
        "update table {update key1 key2} where {= key3}"
623
    );
624
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
625
    # Expanded
626
    $query->sql : "update table set key1 = ?, key2 = ? where key3 = ?;"
packaging one directory
yuki-kimoto authored on 2009-11-16
627
    
628
=head1 AUTHOR
629

            
630
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
631

            
632
Github 
633
L<http://github.com/yuki-kimoto>
634
L<http://github.com/yuki-kimoto/DBIx-Custom-SQL-Template>
635

            
636
Please let know me bag if you find
637
Please request me if you want to do something
638

            
639
=head1 COPYRIGHT & LICENSE
640

            
641
Copyright 2009 Yuki Kimoto, all rights reserved.
642

            
643
This program is free software; you can redistribute it and/or modify it
644
under the same terms as Perl itself.
645

            
646

            
647
=cut
648

            
649
1; # End of DBIx::Custom::SQL::Template