Newer Older
536 lines | 14.672kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::SQL::Template;
2

            
update document
yuki-kimoto authored on 2009-11-17
3
use strict;
4
use warnings;
packaging one directory
yuki-kimoto authored on 2009-11-16
5

            
update document
yuki-kimoto authored on 2010-01-30
6
use base 'Object::Simple';
7
use Carp 'croak';
cleanup and update docment
yuki-kimoto authored on 2009-11-19
8
use DBIx::Custom::Query;
9

            
Simplify key search
yuki-kimoto authored on 2010-02-11
10
__PACKAGE__->attr('table');
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
11
__PACKAGE__->dual_attr('tag_processors', default => sub { {} },
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-22
12
                                         inherit => 'hash_copy');
cleanup
yuki-kimoto authored on 2009-12-22
13

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-22
14
__PACKAGE__->dual_attr('tag_start', default => '{', inherit => 'scalar_copy');
15
__PACKAGE__->dual_attr('tag_end',   default => '}', inherit => 'scalar_copy');
cleanup
yuki-kimoto authored on 2009-12-22
16

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-22
17
__PACKAGE__->dual_attr('tag_syntax', inherit => 'scalar_copy');
cleanup
yuki-kimoto authored on 2009-12-22
18

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
19
__PACKAGE__->add_tag_processor(
cleanup
yuki-kimoto authored on 2009-12-17
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
    '<='     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
27
    'like'   => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
28
    'in'     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_in_tag,
29
    'insert' => \&DBIx::Custom::SQL::Template::TagProcessors::expand_insert_tag,
30
    'update' => \&DBIx::Custom::SQL::Template::TagProcessors::expand_update_tag
31
);
packaging one directory
yuki-kimoto authored on 2009-11-16
32

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

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

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

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

            
51

            
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
sub clone {
60
    my $self = shift;
61
    my $new = $self->new;
62
    
63
    $new->tag_start($self->tag_start);
64
    $new->tag_end($self->tag_end);
65
    $new->tag_syntax($self->tag_syntax);
66
    $new->tag_processors({%{$self->tag_processors || {}}});
67
    
68
    return $new;
69
}
70

            
71
sub create_query {
72
    my ($self, $template)  = @_;
73
    
74
    # Parse template
75
    my $tree = $self->_parse_template($template);
76
    
77
    # Build query
78
    my $query = $self->_build_query($tree);
79
    
80
    return $query;
81
}
82

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

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

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

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

            
packaging one directory
yuki-kimoto authored on 2009-11-16
224
use strict;
225
use warnings;
add DBIx::Custom::Column
yuki-kimoto authored on 2010-02-11
226

            
packaging one directory
yuki-kimoto authored on 2009-11-16
227
use Carp 'croak';
Simplify key search
yuki-kimoto authored on 2010-02-11
228
use DBIx::Custom::KeyInfo;
packaging one directory
yuki-kimoto authored on 2009-11-16
229

            
230
sub expand_basic_tag {
Simplify key search
yuki-kimoto authored on 2010-02-11
231
    my ($tag_name, $tag_args, $table) = @_;
232
    
233
    # Key
234
    my $key = $tag_args->[0];
packaging one directory
yuki-kimoto authored on 2009-11-16
235
    
236
    # Key is not exist
237
    croak("You must be pass key as argument to tag '{$tag_name }'")
Simplify key search
yuki-kimoto authored on 2010-02-11
238
      unless $key;
packaging one directory
yuki-kimoto authored on 2009-11-16
239
    
many change
yuki-kimoto authored on 2010-02-11
240
    # Key info
241
    my $key_info = DBIx::Custom::KeyInfo->new($key);
242
    $key_info->table($table) unless $key_info->table;
243

            
packaging one directory
yuki-kimoto authored on 2009-11-16
244
    # Expanded tag
many change
yuki-kimoto authored on 2010-02-11
245
    my $column = $key_info->table
246
               ? $key_info->table . '.' . $key_info->column
247
               : $key_info->column;
packaging one directory
yuki-kimoto authored on 2009-11-16
248
    my $expand = $tag_name eq '?'
249
               ? '?'
many change
yuki-kimoto authored on 2010-02-11
250
               : "$column $tag_name ?";
251

            
Simplify key search
yuki-kimoto authored on 2010-02-11
252
    return ($expand, [$key_info]);
packaging one directory
yuki-kimoto authored on 2009-11-16
253
}
254

            
255
sub expand_in_tag {
Simplify key search
yuki-kimoto authored on 2010-02-11
256
    my ($tag_name, $tag_args, $table) = @_;
257
    my ($key, $placeholder_count) = @$tag_args;
packaging one directory
yuki-kimoto authored on 2009-11-16
258
    
259
    # Key must be specified
260
    croak("You must be pass key as first argument of tag '{$tag_name }'\n" . 
261
          "Usage: {$tag_name \$key \$placeholder_count}")
Simplify key search
yuki-kimoto authored on 2010-02-11
262
      unless $key;
packaging one directory
yuki-kimoto authored on 2009-11-16
263
    
264
    # Place holder count must be specified
265
    croak("You must be pass placeholder count as second argument of tag '{$tag_name }'\n" . 
266
          "Usage: {$tag_name \$key \$placeholder_count}")
267
      if !$placeholder_count || $placeholder_count =~ /\D/;
268

            
269
    # Expand tag
many change
yuki-kimoto authored on 2010-02-11
270
    my $key_info = DBIx::Custom::KeyInfo->new($key);
271
    my $column = $key_info->table
272
               ? $key_info->table . '.' . $key_info->column
273
               : $key_info->column;
274

            
275
    my $expand = "$column $tag_name (";
packaging one directory
yuki-kimoto authored on 2009-11-16
276
    for (my $i = 0; $i < $placeholder_count; $i++) {
277
        $expand .= '?, ';
278
    }
279
    
280
    $expand =~ s/, $//;
281
    $expand .= ')';
282
    
283
    # Create parameter key infomations
284
    my $key_infos = [];
285
    for (my $i = 0; $i < $placeholder_count; $i++) {
286
        
287
        # Add parameter key infos
Simplify key search
yuki-kimoto authored on 2010-02-11
288
        my $key_info = DBIx::Custom::KeyInfo->new($key);
289
        $key_info->table($table) unless $key_info->table;
290
        $key_info->pos($i);
packaging one directory
yuki-kimoto authored on 2009-11-16
291
        push @$key_infos, $key_info;
292
    }
293
    
294
    return ($expand, $key_infos);
295
}
296

            
297
sub expand_insert_tag {
Simplify key search
yuki-kimoto authored on 2010-02-11
298
    my ($tag_name, $tag_args, $table) = @_;
299
    my $keys = $tag_args;
packaging one directory
yuki-kimoto authored on 2009-11-16
300
    
301
    # Insert key (k1, k2, k3, ..)
302
    my $insert_keys = '(';
303
    
304
    # placeholder (?, ?, ?, ..)
305
    my $place_holders = '(';
306
    
Simplify key search
yuki-kimoto authored on 2010-02-11
307
    foreach my $key (@$keys) {
add DBIx::Custom::Column
yuki-kimoto authored on 2010-02-11
308
        # Get table and clumn name
Simplify key search
yuki-kimoto authored on 2010-02-11
309
        my $key_info = DBIx::Custom::KeyInfo->new($key);
310
        my $column   = $key_info->column;
packaging one directory
yuki-kimoto authored on 2009-11-16
311
        
312
        # Join insert column
313
        $insert_keys   .= "$column, ";
314
        
315
        # Join place holder
316
        $place_holders .= "?, ";
317
    }
318
    
319
    # Delete last ', '
320
    $insert_keys =~ s/, $//;
321
    
322
    # Close 
323
    $insert_keys .= ')';
324
    $place_holders =~ s/, $//;
325
    $place_holders .= ')';
326
    
327
    # Expand tag
328
    my $expand = "$insert_keys values $place_holders";
329
    
330
    # Create parameter key infomations
331
    my $key_infos = [];
Simplify key search
yuki-kimoto authored on 2010-02-11
332
    foreach my $key (@$keys) {
333
        my $key_info = DBIx::Custom::KeyInfo->new($key);
334
        $key_info->table($table) unless $key_info->table;
packaging one directory
yuki-kimoto authored on 2009-11-16
335
        push @$key_infos, $key_info;
336
    }
337
    
338
    return ($expand, $key_infos);
339
}
340

            
341
sub expand_update_tag {
Simplify key search
yuki-kimoto authored on 2010-02-11
342
    my ($tag_name, $tag_args, $table) = @_;
343
    my $keys = $tag_args;
packaging one directory
yuki-kimoto authored on 2009-11-16
344
    
345
    # Expanded tag
346
    my $expand = 'set ';
347
    
Simplify key search
yuki-kimoto authored on 2010-02-11
348
    foreach my $key (@$keys) {
packaging one directory
yuki-kimoto authored on 2009-11-16
349
        # Get table and clumn name
Simplify key search
yuki-kimoto authored on 2010-02-11
350
        my $key_info = DBIx::Custom::KeyInfo->new($key);
351
        my $column = $key_info->column;
packaging one directory
yuki-kimoto authored on 2009-11-16
352

            
353
        # Join key and placeholder
354
        $expand .= "$column = ?, ";
355
    }
356
    
357
    # Delete last ', '
358
    $expand =~ s/, $//;
359
    
360
    my $key_infos = [];
Simplify key search
yuki-kimoto authored on 2010-02-11
361
    foreach my $key (@$keys) {
362
        my $key_info = DBIx::Custom::KeyInfo->new($key);
363
        $key_info->table($table) unless $key_info->table;
packaging one directory
yuki-kimoto authored on 2009-11-16
364
        push @$key_infos, $key_info;
365
    }
366
    
367
    return ($expand, $key_infos);
368
}
369

            
update document
yuki-kimoto authored on 2010-01-30
370
package DBIx::Custom::SQL::Template;
371

            
packaging one directory
yuki-kimoto authored on 2009-11-16
372
1;
373

            
374
=head1 NAME
375

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

            
update document
yuki-kimoto authored on 2010-01-30
378
=head1 SYNOPSIS
packaging one directory
yuki-kimoto authored on 2009-11-16
379
    
380
    my $sql_tmpl = DBIx::Custom::SQL::Template->new;
381
    
382
    my $tmpl   = "select from table {= k1} && {<> k2} || {like k3}";
383
    my $param = {k1 => 1, k2 => 2, k3 => 3};
384
    
385
    my $query = $sql_template->create_query($tmpl);
386

            
update document
yuki-kimoto authored on 2010-01-30
387
=head1 ATTRIBUTES
packaging one directory
yuki-kimoto authored on 2009-11-16
388

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
391
    $sql_tmpl       = $sql_tmpl->tag_processors($name1 => $tag_processor1
392
                                                $name2 => $tag_processor2);
393
    $tag_processors = $sql_tmpl->tag_processors;
packaging one directory
yuki-kimoto authored on 2009-11-16
394

            
395
=head2 tag_start
cleanup and update docment
yuki-kimoto authored on 2009-11-19
396
    
version 0.0901
yuki-kimoto authored on 2009-12-17
397
    $sql_tmpl  = $sql_tmpl->tag_start('{');
398
    $tag_start = $sql_tmpl->tag_start;
packaging one directory
yuki-kimoto authored on 2009-11-16
399

            
update document
yuki-kimoto authored on 2010-01-30
400
Default is '{'
packaging one directory
yuki-kimoto authored on 2009-11-16
401

            
402
=head2 tag_end
cleanup and update docment
yuki-kimoto authored on 2009-11-19
403
    
version 0.0901
yuki-kimoto authored on 2009-12-17
404
    $sql_tmpl    = $sql_tmpl->tag_start('}');
405
    $tag_end = $sql_tmpl->tag_start;
packaging one directory
yuki-kimoto authored on 2009-11-16
406

            
update document
yuki-kimoto authored on 2010-01-30
407
Default is '}'
packaging one directory
yuki-kimoto authored on 2009-11-16
408
    
409
=head2 tag_syntax
410
    
version 0.0901
yuki-kimoto authored on 2009-12-17
411
    $sql_tmpl   = $sql_tmpl->tag_syntax($tag_syntax);
412
    $tag_syntax = $sql_tmpl->tag_syntax;
packaging one directory
yuki-kimoto authored on 2009-11-16
413

            
update document
yuki-kimoto authored on 2010-01-30
414
=head1 METHODS
415

            
416
This class is L<Object::Simple> subclass.
417
You can use all methods of L<Object::Simple>
packaging one directory
yuki-kimoto authored on 2009-11-16
418

            
419
=head2 create_query
420
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
421
Create L<DBIx::Custom::Query> object parsing SQL template
422

            
version 0.0901
yuki-kimoto authored on 2009-12-17
423
    $query = $sql_tmpl->create_query($tmpl);
packaging one directory
yuki-kimoto authored on 2009-11-16
424
    
425
    # Sample
426
    $query = $sql_tmpl->create_sql(
427
         "select * from table where {= title} && {like author} || {<= price}")
428
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
429
    # Expanded
430
    $qeury->sql : "select * from table where title = ? && author like ? price <= ?;"
431
    $query->key_infos : [['title'], ['author'], ['price']]
packaging one directory
yuki-kimoto authored on 2009-11-16
432
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
433
    # Sample with table name
packaging one directory
yuki-kimoto authored on 2009-11-16
434
    ($sql, @bind_values) = $sql_tmpl->create_sql(
435
            "select * from table where {= table.title} && {like table.author}",
436
            {table => {title => 'Perl', author => '%Taro%'}}
437
        )
438
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
439
    # Expanded
440
    $query->sql : "select * from table where table.title = ? && table.title like ?;"
441
    $query->key_infos :[ [['table.title'],['table', 'title']],
442
                         [['table.author'],['table', 'author']] ]
packaging one directory
yuki-kimoto authored on 2009-11-16
443

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

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

            
450
=head2 add_tag_processor
451

            
452
Add tag processor
cleanup and update docment
yuki-kimoto authored on 2009-11-19
453
    
version 0.0901
yuki-kimoto authored on 2009-12-17
454
    $sql_tmpl = $sql_tmpl->add_tag_processor($tag_processor);
455

            
456
The following is add_tag_processor sample
457

            
packaging one directory
yuki-kimoto authored on 2009-11-16
458
    $sql_tmpl->add_tag_processor(
459
        '?' => sub {
460
            my ($tag_name, $tag_args) = @_;
461
            
462
            my $key1 = $tag_args->[0];
463
            my $key2 = $tag_args->[1];
464
            
465
            my $key_infos = [];
466
            
467
            # Expand tag and create key informations
468
            
469
            # Return expand tags and key informations
470
            return ($expand, $key_infos);
471
        }
472
    );
473

            
474
Tag processor recieve 2 argument
475

            
476
    1. Tag name            (?, =, <>, or etc)
477
    2. Tag arguments       (arg1 and arg2 in {tag_name arg1 arg2})
478

            
479
Tag processor return 2 value
480

            
481
    1. Expanded Tag (For exsample, '{= title}' is expanded to 'title = ?')
482
    2. Key infomations
483
    
484
You must be return expanded tag and key infomations.
485

            
486
Key information is a little complex. so I will explan this in future.
487

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

            
490
=head2 clone
491

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
494
    $clone = $sql_tmpl->clone;
packaging one directory
yuki-kimoto authored on 2009-11-16
495
    
496
=head1 Available Tags
497
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
498
Available Tags
499

            
packaging one directory
yuki-kimoto authored on 2009-11-16
500
    [tag]            [expand]
501
    {? name}         ?
502
    {= name}         name = ?
503
    {<> name}        name <> ?
504
    
505
    {< name}         name < ?
506
    {> name}         name > ?
507
    {>= name}        name >= ?
508
    {<= name}        name <= ?
509
    
510
    {like name}      name like ?
511
    {in name}        name in [?, ?, ..]
512
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
513
    {insert}         (key1, key2, key3) values (?, ?, ?)
514
    {update}         set key1 = ?, key2 = ?, key3 = ?
packaging one directory
yuki-kimoto authored on 2009-11-16
515
    
version 0.0901
yuki-kimoto authored on 2009-12-17
516

            
517
The following is insert SQL sample
518

            
packaging one directory
yuki-kimoto authored on 2009-11-16
519
    $query = $sql_tmpl->create_sql(
520
        "insert into table {insert key1 key2}"
521
    );
version 0.0901
yuki-kimoto authored on 2009-12-17
522
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
523
    # Expanded
524
    $query->sql : "insert into table (key1, key2) values (?, ?)"
version 0.0901
yuki-kimoto authored on 2009-12-17
525

            
526
The following is update SQL sample
packaging one directory
yuki-kimoto authored on 2009-11-16
527
    
528
    $query = $sql_tmpl->create_sql(
529
        "update table {update key1 key2} where {= key3}"
530
    );
531
    
cleanup and update docment
yuki-kimoto authored on 2009-11-19
532
    # Expanded
533
    $query->sql : "update table set key1 = ?, key2 = ? where key3 = ?;"
packaging one directory
yuki-kimoto authored on 2009-11-16
534
    
535
=cut
Simplify key search
yuki-kimoto authored on 2010-02-11
536