Newer Older
651 lines | 17.569kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::SQL::Template;
cleanup
yuki-kimoto authored on 2009-12-17
2
use Object::Simple; Object::Simple->build_class;
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

            
cleanup
yuki-kimoto authored on 2009-12-17
10
__PACKAGE__->add_tag_processor(
11
    '?'      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
12
    '='      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
13
    '<>'     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
14
    '>'      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
15
    '<'      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
16
    '>='     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
17
    '<='     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
18
    'like'   => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
19
    'in'     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_in_tag,
20
    'insert' => \&DBIx::Custom::SQL::Template::TagProcessors::expand_insert_tag,
21
    'update' => \&DBIx::Custom::SQL::Template::TagProcessors::expand_update_tag
22
);
packaging one directory
yuki-kimoto authored on 2009-11-16
23

            
cleanup
yuki-kimoto authored on 2009-12-17
24
__PACKAGE__->tag_syntax(<< 'EOS');
packaging one directory
yuki-kimoto authored on 2009-11-16
25
[tag]                     [expand]
26
{? name}                  ?
27
{= name}                  name = ?
28
{<> name}                 name <> ?
29

            
30
{< name}                  name < ?
31
{> name}                  name > ?
32
{>= name}                 name >= ?
33
{<= name}                 name <= ?
34

            
35
{like name}               name like ?
36
{in name number}          name in [?, ?, ..]
37

            
38
{insert key1 key2} (key1, key2) values (?, ?)
39
{update key1 key2}    set key1 = ?, key2 = ?
40
EOS
41

            
cleanup
yuki-kimoto authored on 2009-12-17
42
# Accessor is created by Object::Simple.
43

            
44
### Class-Object accessors
45

            
46

            
47
sub tag_start      : HybridAttr { build => '{', clone => 'scalar' }
48
sub tag_end        : HybridAttr { build => '}', clone => 'scalar' }
49
sub tag_syntax     : HybridAttr { clone => 'scalar' }
50
sub tag_processors : HybridAttr { type  => 'hash', build => sub {{}},
51
                                  clone => 'hash', deref => 1 }
packaging one directory
yuki-kimoto authored on 2009-11-16
52

            
53
# Add Tag processor
54
sub add_tag_processor {
55
    my $invocant = shift;
56
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
57
    $invocant->tag_processors(%{$invocant->tag_processors}, %{$tag_processors});
58
    return $invocant;
59
}
60

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

            
74

            
75
### Object Methods
76

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

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

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

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

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

            
226

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

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

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

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

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

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

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

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

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

            
462
1;
463

            
464
=head1 NAME
465

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

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

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

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

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

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

            
487
=head2 tag_start
488

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

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

            
496
=head2 tag_end
497

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

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

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

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

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

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

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

            
545
=head2 add_tag_processor
546

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

            
551
The following is add_tag_processor sample
552

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

            
569
Tag processor recieve 2 argument
570

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

            
574
Tag processor return 2 value
575

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

            
581
Key information is a little complex. so I will explan this in future.
582

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

            
585
=head2 clone
586

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

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

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

            
612
The following is insert SQL sample
613

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

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

            
632
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
633

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

            
638
Please let know me bag if you find
639
Please request me if you want to do something
640

            
641
=head1 COPYRIGHT & LICENSE
642

            
643
Copyright 2009 Yuki Kimoto, all rights reserved.
644

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

            
648

            
649
=cut
650

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