DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3641 lines | 88.835kb
cleanup
yuki-kimoto authored on 2009-12-22
1
package DBIx::Custom;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
2
use Object::Simple -base;
cleanup
yuki-kimoto authored on 2009-12-22
3

            
- renamed DBIx::Custom::Resu...
Yuki Kimoto authored on 2012-01-20
4
our $VERSION = '0.2106';
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
5
use 5.008001;
cleanup
yuki-kimoto authored on 2009-12-22
6

            
packaging one directory
yuki-kimoto authored on 2009-11-16
7
use Carp 'croak';
8
use DBI;
9
use DBIx::Custom::Result;
cleanup
yuki-kimoto authored on 2010-02-11
10
use DBIx::Custom::Query;
cleanup
yuki-kimoto authored on 2010-08-05
11
use DBIx::Custom::QueryBuilder;
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
12
use DBIx::Custom::Where;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
13
use DBIx::Custom::Model;
cleanup
Yuki Kimoto authored on 2011-01-25
14
use DBIx::Custom::Tag;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
15
use DBIx::Custom::Order;
cleanup
Yuki Kimoto authored on 2011-04-25
16
use DBIx::Custom::Util qw/_array_to_hash _subname/;
added tests
Yuki Kimoto authored on 2011-08-26
17
use DBIx::Custom::Mapper;
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
18
use DBIx::Custom::NotExists;
improved debug message
Yuki Kimoto authored on 2011-05-23
19
use Encode qw/encode encode_utf8 decode_utf8/;
cleanup
Yuki Kimoto authored on 2011-08-13
20
use Scalar::Util qw/weaken/;
added experimental use_next_...
Yuki Kimoto authored on 2011-11-16
21

            
packaging one directory
yuki-kimoto authored on 2009-11-16
22

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
23
has [qw/connector dsn password quote user exclude_table user_table_info
cleanup
Yuki Kimoto authored on 2012-01-20
24
     user_column_info safety_character/],
25
  cache => 0,
26
  cache_method => sub {
27
    sub {
28
      my $self = shift;
29
      $self->{_cached} ||= {};
30
      if (@_ > 1) { $self->{_cached}{$_[0]} = $_[1] }
31
      else { return $self->{_cached}{$_[0]} }
32
    }
33
  },
34
  option => sub { {} },
35
  default_option => sub {
36
    {
37
      RaiseError => 1,
38
      PrintError => 0,
39
      AutoCommit => 1
40
    }
41
  },
42
  filters => sub {
43
    {
44
      encode_utf8 => sub { encode_utf8($_[0]) },
45
      decode_utf8 => sub { decode_utf8($_[0]) }
46
    }
47
  },
48
  last_sql => '',
49
  models => sub { {} },
50
  now => sub {
51
    sub {
52
      my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
53
      $mon++;
54
      $year += 1900;
55
      my $now = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
56
        $year, $mon, $mday, $hour, $min, $sec);
57
      return $now;
58
    }
59
  },
60
  query_builder => sub {
61
    my $self = shift;
62
    my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
63
    weaken $builder->{dbi};
64
    return $builder;
65
  },
66
  result_class  => 'DBIx::Custom::Result',
67
  separator => '.',
68
  stash => sub { {} };
cleanup
yuki-kimoto authored on 2010-10-17
69

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
70
sub available_datatype {
cleanup
Yuki Kimoto authored on 2012-01-20
71
  my $self = shift;
72
  
73
  my $data_types = '';
74
  for my $i (-1000 .. 1000) {
75
     my $type_info = $self->dbh->type_info($i);
76
     my $data_type = $type_info->{DATA_TYPE};
77
     my $type_name = $type_info->{TYPE_NAME};
78
     $data_types .= "$data_type ($type_name)\n"
79
       if defined $data_type;
80
  }
81
  return "Data Type maybe equal to Type Name" unless $data_types;
82
  $data_types = "Data Type (Type name)\n" . $data_types;
83
  return $data_types;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
84
}
85

            
86
sub available_typename {
cleanup
Yuki Kimoto authored on 2012-01-20
87
  my $self = shift;
88
  
89
  # Type Names
90
  my $type_names = {};
91
  $self->each_column(sub {
92
    my ($self, $table, $column, $column_info) = @_;
93
    $type_names->{$column_info->{TYPE_NAME}} = 1
94
      if $column_info->{TYPE_NAME};
95
  });
96
  my @output = sort keys %$type_names;
97
  unshift @output, "Type Name";
98
  return join "\n", @output;
test cleanup
Yuki Kimoto authored on 2011-08-10
99
}
100

            
added helper method
yuki-kimoto authored on 2010-10-17
101
our $AUTOLOAD;
102
sub AUTOLOAD {
cleanup
Yuki Kimoto authored on 2012-01-20
103
  my $self = shift;
added helper method
yuki-kimoto authored on 2010-10-17
104

            
cleanup
Yuki Kimoto authored on 2012-01-20
105
  # Method name
106
  my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
added helper method
yuki-kimoto authored on 2010-10-17
107

            
cleanup
Yuki Kimoto authored on 2012-01-20
108
  # Call method
109
  $self->{_methods} ||= {};
110
  if (my $method = $self->{_methods}->{$mname}) {
111
    return $self->$method(@_)
112
  }
113
  elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
114
    $self->dbh->$dbh_method(@_);
115
  }
116
  else {
117
    croak qq{Can't locate object method "$mname" via "$package" }
118
      . _subname;
119
  }
added helper method
yuki-kimoto authored on 2010-10-17
120
}
121

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
122
sub assign_clause {
cleanup
Yuki Kimoto authored on 2012-01-20
123
  my ($self, $param, $opts) = @_;
124
  
125
  my $wrap = $opts->{wrap} || {};
126
  my ($q, $p) = split //, $self->q('');
127
  
128
  # Assign clause (performance is important)
129
  join(
130
    ', ',
131
    map {
132
      ref $param->{$_} eq 'SCALAR' ? "$q$_$p = " . ${$param->{$_}}
133
      : $wrap->{$_} ? "$q$_$p = " . $wrap->{$_}->(":$_")
134
      : "$q$_$p = :$_";
135
    } sort keys %$param
136
  );
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
137
}
138

            
cleanup
Yuki Kimoto authored on 2011-03-21
139
sub column {
cleanup
Yuki Kimoto authored on 2012-01-20
140
  my $self = shift;
141
  my $option = pop if ref $_[-1] eq 'HASH';
142
  my $real_table = shift;
143
  my $columns = shift;
144
  my $table = $option->{alias} || $real_table;
145
  
146
  # Columns
147
  unless (defined $columns) {
148
    $columns ||= $self->model($real_table)->columns;
149
  }
150
  
151
  # Separator
152
  my $separator = $self->separator;
153
  
154
  # Column clause
155
  my @column;
156
  $columns ||= [];
157
  push @column, $self->q($table) . "." . $self->q($_) .
158
    " as " . $self->q("${table}${separator}$_")
159
    for @$columns;
160
  
161
  return join (', ', @column);
added helper method
yuki-kimoto authored on 2010-10-17
162
}
163

            
packaging one directory
yuki-kimoto authored on 2009-11-16
164
sub connect {
cleanup
Yuki Kimoto authored on 2012-01-20
165
  my $self = ref $_[0] ? shift : shift->new(@_);
166
  
167
  my $connector = $self->connector;
168
  
169
  if (!ref $connector && $connector) {
170
    require DBIx::Connector;
171
    
172
    my $dsn = $self->dsn;
173
    my $user = $self->user;
174
    my $password = $self->password;
175
    my $option = $self->_option;
176
    my $connector = DBIx::Connector->new($dsn, $user, $password,
177
      {%{$self->default_option} , %$option});
178
    $self->connector($connector);
179
  }
180
  
181
  # Connect
182
  $self->dbh;
183
  
184
  return $self;
packaging one directory
yuki-kimoto authored on 2009-11-16
185
}
186

            
- renamed DBIx::Custom::Resu...
Yuki Kimoto authored on 2012-01-20
187
sub count { shift->select(column => 'count(*)', @_)->fetch_one->[0] }
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
188

            
update pod
Yuki Kimoto authored on 2011-03-13
189
sub dbh {
cleanup
Yuki Kimoto authored on 2012-01-20
190
  my $self = shift;
191
  
192
  # Set
193
  if (@_) {
194
    $self->{dbh} = $_[0];
cleanup
Yuki Kimoto authored on 2011-04-02
195
    
cleanup
Yuki Kimoto authored on 2012-01-20
196
    return $self;
197
  }
198
  
199
  # Get
200
  else {
201
    # From Connction manager
202
    if (my $connector = $self->connector) {
203
      croak "connector must have dbh() method " . _subname
204
        unless ref $connector && $connector->can('dbh');
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
205
        
cleanup
Yuki Kimoto authored on 2012-01-20
206
      $self->{dbh} = $connector->dbh;
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
207
    }
208
    
cleanup
Yuki Kimoto authored on 2012-01-20
209
    # Connect
210
    $self->{dbh} ||= $self->_connect;
211
    
212
    # Quote
213
    if (!defined $self->reserved_word_quote && !defined $self->quote) {
214
      my $driver = $self->_driver;
215
      my $quote =  $driver eq 'odbc' ? '[]'
216
        : $driver eq 'ado' ? '[]'
217
        : $driver eq 'mysql' ? '`'
218
        : '"';
219
      $self->quote($quote);
update pod
Yuki Kimoto authored on 2011-03-13
220
    }
cleanup
Yuki Kimoto authored on 2012-01-20
221
    
222
    return $self->{dbh};
223
  }
update pod
Yuki Kimoto authored on 2011-03-13
224
}
225

            
cleanup
Yuki Kimoto authored on 2011-10-21
226
sub delete {
cleanup
Yuki Kimoto authored on 2012-01-20
227
  my ($self, %opt) = @_;
228
  warn "delete method where_param option is DEPRECATED!"
229
    if $opt{where_param};
230
  
231
  # Don't allow delete all rows
232
  croak qq{delete method where or id option must be specified } . _subname
233
    if !$opt{where} && !defined $opt{id} && !$opt{allow_delete_all};
234
  
235
  # Where
236
  my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
237
    delete $opt{id}, $opt{primary_key}, $opt{table});
238

            
239
  # Delete statement
240
  my $sql = "delete ";
241
  $sql .= "$opt{prefix} " if defined $opt{prefix};
242
  $sql .= "from " . $self->q($opt{table}) . " $w->{clause} ";
243
  
244
  # Execute query
245
  $opt{statement} = 'delete';
246
  $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
247
}
248

            
cleanup
Yuki Kimoto authored on 2011-11-01
249
sub delete_all { shift->delete(@_, allow_delete_all => 1) }
packaging one directory
yuki-kimoto authored on 2009-11-16
250

            
added memory leak check test
Yuki Kimoto authored on 2011-08-15
251
sub DESTROY {}
added helper method
yuki-kimoto authored on 2010-10-17
252

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
253
sub create_model {
cleanup
Yuki Kimoto authored on 2012-01-20
254
  my $self = shift;
255
  
256
  # Options
257
  my $opt = ref $_[0] eq 'HASH' ? $_[0] : {@_};
258
  $opt->{dbi} = $self;
259
  my $model_class = delete $opt->{model_class} || 'DBIx::Custom::Model';
260
  my $model_name  = delete $opt->{name};
261
  my $model_table = delete $opt->{table};
262
  $model_name ||= $model_table;
263
  
264
  # Create model
265
  my $model = $model_class->new($opt);
266
  weaken $model->{dbi};
267
  $model->name($model_name) unless $model->name;
268
  $model->table($model_table) unless $model->table;
269
  
270
  # Apply filter(DEPRECATED logic)
271
  if ($model->{filter}) {
272
    my $filter = ref $model->filter eq 'HASH'
273
      ? [%{$model->filter}]
274
      : $model->filter;
275
    $filter ||= [];
276
    warn "DBIx::Custom::Model filter method is DEPRECATED!"
277
      if @$filter;
278
    $self->_apply_filter($model->table, @$filter);
279
  }
280
  
281
  # Set model
282
  $self->model($model->name, $model);
283
  
284
  return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
285
}
286

            
287
sub each_column {
cleanup
Yuki Kimoto authored on 2012-01-20
288
  my ($self, $cb, %options) = @_;
289

            
290
  my $user_column_info = $self->user_column_info;
291
  
292
  if ($user_column_info) {
293
    $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
294
  }
295
  else {
296
    my $re = $self->exclude_table || $options{exclude_table};
297
    # Tables
298
    my %tables;
299
    $self->each_table(sub { $tables{$_[1]}++ });
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
300

            
cleanup
Yuki Kimoto authored on 2012-01-20
301
    # Iterate all tables
302
    my @tables = sort keys %tables;
303
    for (my $i = 0; $i < @tables; $i++) {
304
      my $table = $tables[$i];
305
      
306
      # Iterate all columns
307
      my $sth_columns;
308
      eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
309
      next if $@;
310
      while (my $column_info = $sth_columns->fetchrow_hashref) {
311
        my $column = $column_info->{COLUMN_NAME};
312
        $self->$cb($table, $column, $column_info);
313
      }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
314
    }
cleanup
Yuki Kimoto authored on 2012-01-20
315
  }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
316
}
317

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
318
sub each_table {
cleanup
Yuki Kimoto authored on 2012-01-20
319
  my ($self, $cb, %option) = @_;
320
  
321
  my $user_table_infos = $self->user_table_info;
322
  
323
  # Iterate tables
324
  if ($user_table_infos) {
325
      $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
326
  }
327
  else {
328
    my $re = $self->exclude_table || $option{exclude};
329
    my $sth_tables = $self->dbh->table_info;
330
    while (my $table_info = $sth_tables->fetchrow_hashref) {
331
      # Table
332
      my $table = $table_info->{TABLE_NAME};
333
      next if defined $re && $table =~ /$re/;
334
      $self->$cb($table, $table_info);
335
    }
336
  }
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
337
}
338

            
cleanup
Yuki Kimoto authored on 2011-04-02
339
sub execute {
cleanup
Yuki Kimoto authored on 2012-01-20
340
  my $self = shift;
341
  my $sql = shift;
342

            
343
  # Options
344
  my $params;
345
  $params = shift if @_ % 2;
346
  my %opt = @_;
347
  warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
348
  $params ||= $opt{param} || {};
349
  my $tables = $opt{table} || [];
350
  $tables = [$tables] unless ref $tables eq 'ARRAY';
351
  my $filter = ref $opt{filter} eq 'ARRAY' ?
352
    _array_to_hash($opt{filter}) : $opt{filter};
353
  
354
  # Merge second parameter
355
  my @cleanup;
356
  my $saved_param;
357
  if (($opt{statement} || '') ne 'insert' && ref $params eq 'ARRAY') {
358
    my $params2 = $params->[1];
359
    $params = $params->[0];
360
    for my $column (keys %$params2) {
361
      if (!exists $params->{$column}) {
362
        $params->{$column} = $params2->{$column};
363
        push @cleanup, $column;
364
      }
365
      else {
366
        delete $params->{$_} for @cleanup;
367
        @cleanup = ();
368
        $saved_param  = $params;
369
        $params = $self->merge_param($params, $params2);
370
        delete $saved_param->{$_} for (@{$opt{cleanup} || []});
371
        last;
372
      }
373
    }
374
  }
375
  $params = [$params] unless ref $params eq 'ARRAY';
376
  
377
  # Append
378
  $sql .= $opt{append} if defined $opt{append} && !ref $sql;
379
  
380
  # Query
381
  my $query;
382
  if (ref $sql) {
383
    $query = $sql;
384
    warn "execute method receiving query object as first parameter is DEPRECATED!" .
385
      "because this is very buggy.";
386
  }
387
  else {
388
    $query = $opt{reuse}->{$sql} if $opt{reuse};
389
    unless ($query) {
390
      my $c = $self->{safety_character};
391
      # Check unsafety keys
392
      unless ((join('', keys %{$params->[0]}) || '') =~ /^[$c\.]+$/) {
393
        for my $column (keys %{$params->[0]}) {
394
          croak qq{"$column" is not safety column name } . _subname
395
            unless $column =~ /^[$c\.]+$/;
micro optimization
Yuki Kimoto authored on 2011-11-16
396
        }
cleanup
Yuki Kimoto authored on 2012-01-20
397
      }
398
      $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter});
399
    }
400
    $query->{statement} = $opt{statement} || '';
401
    $opt{reuse}->{$sql} = $query if $opt{reuse};
402
  }
403
      
404
  # Save query
405
  $self->{last_sql} = $query->{sql};
406

            
407
  # Return query
408
  if ($opt{query}) {
409
    for my $column (@cleanup, @{$opt{cleanup} || []}) {
410
      delete $_->{$column} for @$params;
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
411
    }
cleanup
Yuki Kimoto authored on 2012-01-20
412
    return $query;
413
  };
414
  
415
  # Merge query filter(DEPRECATED!)
416
  $filter ||= $query->{filter} || {};
417
  
418
  # Tables
419
  unshift @$tables, @{$query->{tables} || []};
420
  my $main_table = @{$tables}[-1];
421

            
422
  # Merge id to parameter
423
  if (defined $opt{id}) {
424
    my $statement = $query->{statement};
425
    warn "execute method id option is DEPRECATED!" unless $statement;
426
    croak "execute id option must be specified with primary_key option"
427
      unless $opt{primary_key};
428
    $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
429
    $opt{id} = [$opt{id}] unless ref $opt{id};
430
    for (my $i = 0; $i < @{$opt{id}}; $i++) {
431
      my $key = $opt{primary_key}->[$i];
432
      $key = "$main_table.$key" if $statement eq 'update' ||
433
        $statement eq 'delete' || $statement eq 'select';
434
      next if exists $params->[0]->{$key};
435
      $params->[0]->{$key} = $opt{id}->[$i];
436
      push @cleanup, $key;1
437
    }
438
  }
439
  
440
  # Cleanup tables(DEPRECATED!)
441
  $tables = $self->_remove_duplicate_table($tables, $main_table)
442
    if @$tables > 1;
443
  
444
  # Type rule
445
  my $type_filters = {};
446
  my $type_rule_off = !$self->{_type_rule_is_called} || $opt{type_rule_off};
447
  unless ($type_rule_off) {
448
    my $type_rule_off_parts = {
449
      1 => $opt{type_rule1_off},
450
      2 => $opt{type_rule2_off}
cleanup
Yuki Kimoto authored on 2011-11-16
451
    };
cleanup
Yuki Kimoto authored on 2012-01-20
452
    for my $i (1, 2) {
453
      unless ($type_rule_off_parts->{$i}) {
454
        $type_filters->{$i} = {};
455
        my $table_alias = $opt{table_alias} || {};
456
        for my $alias (keys %$table_alias) {
457
          my $table = $table_alias->{$alias};
458
          
459
          for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
460
            $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
461
          }
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
462
        }
cleanup
Yuki Kimoto authored on 2012-01-20
463
        $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
464
          if $main_table;
465
      }
466
    }
467
  }
468
  
469
  # Applied filter(DEPRECATED!)
470
  if ($self->{filter}{on}) {
471
    my $applied_filter = {};
472
    for my $table (@$tables) {
473
      $applied_filter = {
474
        %$applied_filter,
475
        %{$self->{filter}{out}->{$table} || {}}
476
      }
477
    }
478
    $filter = {%$applied_filter, %$filter};
479
  }
480
  
481
  # Replace filter name to code
482
  for my $column (keys %$filter) {
483
    my $name = $filter->{$column};
484
    if (!defined $name) {
485
      $filter->{$column} = undef;
486
    }
487
    elsif (ref $name ne 'CODE') {
488
      croak qq{Filter "$name" is not registered" } . _subname
489
        unless exists $self->filters->{$name};
490
      $filter->{$column} = $self->filters->{$name};
491
    }
492
  }
493

            
494
  # Execute
495
  my $sth = $query->{sth};
496
  my $affected;
497
  if ((!$query->{duplicate} || $opt{bulk_insert}) && $type_rule_off
498
    && !keys %$filter && !$self->{default_out_filter}
499
    && !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG})
500
  {
501
    eval {
502
      if ($opt{bulk_insert}) {
503
        my %count;
504
        my $param = $params->[0];
505
        $affected = $sth->execute(map { $param->{$_}->[++$count{$_} - 1] }
506
          @{$query->{columns}});
507
      }
508
      else {
- insert method can receive ...
Yuki Kimoto authored on 2011-11-25
509
        for my $param (@$params) {
cleanup
Yuki Kimoto authored on 2012-01-20
510
          $affected = $sth->execute(map { $param->{$_} }
511
            @{$query->{columns}});
- insert method can receive ...
Yuki Kimoto authored on 2011-11-25
512
        }
cleanup
Yuki Kimoto authored on 2012-01-20
513
      }
514
    };
515
  }
516
  else {
517
    for my $param (@$params) {
518
      # Create bind values
519
      my ($bind, $bind_types) = $self->_create_bind_values($param, $query->{columns},
520
        $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
521

            
522
      # Execute
523
      eval {
524
        if ($opt{bind_type} || $opt{type}) {
525
          $sth->bind_param($_ + 1, $bind->[$_],
526
              $bind_types->[$_] ? $bind_types->[$_] : ())
527
            for (0 .. @$bind - 1);
528
          $affected = $sth->execute;
cleanup
Yuki Kimoto authored on 2011-01-12
529
        }
cleanup
Yuki Kimoto authored on 2012-01-20
530
        else { $affected = $sth->execute(@$bind) }
531

            
532
        # DEBUG message
533
        if ($ENV{DBIX_CUSTOM_DEBUG}) {
534
          warn "SQL:\n" . $query->{sql} . "\n";
535
          my @output;
536
          for my $value (@$bind) {
537
            $value = 'undef' unless defined $value;
538
            $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
539
              if utf8::is_utf8($value);
540
            push @output, $value;
541
          }
542
          warn "Bind values: " . join(', ', @output) . "\n\n";
543
        }
544
      };
545
    }
546
  }
547
  
548
  $self->_croak($@, qq{. Following SQL is executed.\n}
549
    . qq{$query->{sql}\n} . _subname) if $@;
550

            
551
  # Remove id from parameter
552
  for my $column (@cleanup, @{$opt{cleanup} || []}) {
553
    delete $_->{$column} for @$params;
554
  }
555
  
556
  # Not select statement
557
  return $affected unless $sth->{NUM_OF_FIELDS};
558

            
559
  # Filter(DEPRECATED!)
560
  my $infilter = {};
561
  if ($self->{filter}{on}) {
562
    $infilter->{in}  = {};
563
    $infilter->{end} = {};
564
    push @$tables, $main_table if $main_table;
565
    for my $table (@$tables) {
566
      for my $way (qw/in end/) {
567
        $infilter->{$way} = {%{$infilter->{$way}},
568
          %{$self->{filter}{$way}{$table} || {}}};
569
      }
570
    }
571
  }
572
  
573
  # Result
574
  $self->result_class->new(
575
    sth => $sth,
576
    dbi => $self,
577
    default_filter => $self->{default_in_filter},
578
    filter => $infilter->{in} || {},
579
    end_filter => $infilter->{end} || {},
580
    type_rule => {
581
      from1 => $self->type_rule->{from1},
582
      from2 => $self->type_rule->{from2}
583
    },
584
  );
cleanup
yuki-kimoto authored on 2010-10-17
585
}
586

            
added test
Yuki Kimoto authored on 2011-08-16
587
sub get_table_info {
cleanup
Yuki Kimoto authored on 2012-01-20
588
  my ($self, %opt) = @_;
589
  
590
  my $exclude = delete $opt{exclude};
591
  croak qq/"$_" is wrong option/ for keys %opt;
592
  
593
  my $table_info = [];
594
  $self->each_table(
595
    sub { push @$table_info, {table => $_[1], info => $_[2] } },
596
    exclude => $exclude
597
  );
598
  
599
  return [sort {$a->{table} cmp $b->{table} } @$table_info];
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
600
}
601

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
602
sub get_column_info {
cleanup
Yuki Kimoto authored on 2012-01-20
603
  my ($self, %opt) = @_;
604
  
605
  my $exclude_table = delete $opt{exclude_table};
606
  croak qq/"$_" is wrong option/ for keys %opt;
607
  
608
  my $column_info = [];
609
  $self->each_column(
610
    sub { push @$column_info, {table => $_[1], column => $_[2], info => $_[3] } },
611
    exclude_table => $exclude_table
612
  );
613
  
614
  return [
615
    sort {$a->{table} cmp $b->{table} || $a->{column} cmp $b->{column} }
616
      @$column_info];
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
617
}
618

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
619
sub helper {
cleanup
Yuki Kimoto authored on 2012-01-20
620
  my $self = shift;
621
  
622
  # Register method
623
  my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
624
  $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
625
  
626
  return $self;
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
627
}
628

            
cleanup
yuki-kimoto authored on 2010-10-17
629
sub insert {
cleanup
Yuki Kimoto authored on 2012-01-20
630
  my $self = shift;
631
  
632
  # Options
633
  my $params = @_ % 2 ? shift : undef;
634
  my %opt = @_;
635
  warn "insert method param option is DEPRECATED!" if $opt{param};
636
  $params ||= delete $opt{param} || {};
637
  
638
  my $multi;
639
  if (ref $params eq 'ARRAY') { $multi = 1 }
640
  else { $params = [$params] }
641
  
642
  # Timestamp(DEPRECATED!)
643
  if (!$multi && $opt{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
644
    warn "insert timestamp option is DEPRECATED! use created_at with now attribute";
645
    my $columns = $insert_timestamp->[0];
646
    $columns = [$columns] unless ref $columns eq 'ARRAY';
647
    my $value = $insert_timestamp->[1];
648
    $value = $value->() if ref $value eq 'CODE';
649
    $params->[0]->{$_} = $value for @$columns;
650
  }
651

            
652
  # Created time and updated time
653
  my @timestamp_cleanup;
654
  if (defined $opt{created_at} || defined $opt{updated_at}) {
655
    my $now = $self->now;
656
    $now = $now->() if ref $now eq 'CODE';
657
    if (defined $opt{created_at}) {
658
      $_->{$opt{created_at}} = $now for @$params;
659
      push @timestamp_cleanup, $opt{created_at};
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
660
    }
cleanup
Yuki Kimoto authored on 2012-01-20
661
    if (defined $opt{updated_at}) {
662
      $_->{$opt{updated_at}} = $now for @$params;
663
      push @timestamp_cleanup, $opt{updated_at};
664
    }
665
  }
666
  
667
  # Merge id to parameter
668
  my @cleanup;
669
  my $id_param = {};
670
  if (defined $opt{id} && !$multi) {
671
    croak "insert id option must be specified with primary_key option"
672
      unless $opt{primary_key};
673
    $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
674
    $opt{id} = [$opt{id}] unless ref $opt{id};
675
    for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
676
      my $key = $opt{primary_key}->[$i];
677
      next if exists $params->[0]->{$key};
678
      $params->[0]->{$key} = $opt{id}->[$i];
679
      push @cleanup, $key;
680
    }
681
  }
682
  
683
  # Insert statement
684
  my $sql = "insert ";
685
  $sql .= "$opt{prefix} " if defined $opt{prefix};
686
  $sql .= "into " . $self->q($opt{table}) . " ";
687
  if ($opt{bulk_insert}) {
688
    $sql .= $self->_multi_values_clause($params, {wrap => $opt{wrap}}) . " ";
689
    my $new_param = {};
690
    $new_param->{$_} = [] for keys %{$params->[0]};
691
    for my $param (@$params) {
692
      push @{$new_param->{$_}}, $param->{$_} for keys %$param;
693
    }
694
    $params = [$new_param];
695
  }
696
  else {
697
    $sql .= $self->values_clause($params->[0], {wrap => $opt{wrap}}) . " ";
698
  }
699

            
700
  # Remove id from parameter
701
  delete $params->[0]->{$_} for @cleanup;
702
  
703
  # Execute query
704
  $opt{statement} = 'insert';
705
  $opt{cleanup} = \@timestamp_cleanup;
706
  $self->execute($sql, $params, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
707
}
708

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
709
sub insert_timestamp {
cleanup
Yuki Kimoto authored on 2012-01-20
710
  my $self = shift;
711
  
712
  warn "insert_timestamp method is DEPRECATED! use now attribute";
713
  
714
  if (@_) {
715
    $self->{insert_timestamp} = [@_];
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
716
    
cleanup
Yuki Kimoto authored on 2012-01-20
717
    return $self;
718
  }
719
  return $self->{insert_timestamp};
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
720
}
721

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
722
sub include_model {
cleanup
Yuki Kimoto authored on 2012-01-20
723
  my ($self, $name_space, $model_infos) = @_;
724
  
725
  # Name space
726
  $name_space ||= '';
727
  
728
  # Get Model infomations
729
  unless ($model_infos) {
730

            
731
    # Load name space module
732
    croak qq{"$name_space" is invalid class name } . _subname
733
      if $name_space =~ /[^\w:]/;
734
    eval "use $name_space";
735
    croak qq{Name space module "$name_space.pm" is needed. $@ }
736
        . _subname
737
      if $@;
738
    
739
    # Search model modules
740
    my $path = $INC{"$name_space.pm"};
741
    $path =~ s/\.pm$//;
742
    opendir my $dh, $path
743
      or croak qq{Can't open directory "$path": $! } . _subname
744
    $model_infos = [];
745
    while (my $module = readdir $dh) {
746
      push @$model_infos, $module
747
        if $module =~ s/\.pm$//;
748
    }
749
    close $dh;
750
  }
751
  
752
  # Include models
753
  for my $model_info (@$model_infos) {
754
    
755
    # Load model
756
    my $model_class;
757
    my $model_name;
758
    my $model_table;
759
    if (ref $model_info eq 'HASH') {
760
      $model_class = $model_info->{class};
761
      $model_name  = $model_info->{name};
762
      $model_table = $model_info->{table};
763
      
764
      $model_name  ||= $model_class;
765
      $model_table ||= $model_name;
766
    }
767
    else { $model_class = $model_name = $model_table = $model_info }
768
    my $mclass = "${name_space}::$model_class";
769
    croak qq{"$mclass" is invalid class name } . _subname
770
      if $mclass =~ /[^\w:]/;
771
    unless ($mclass->can('isa')) {
772
      eval "use $mclass";
773
      croak "$@ " . _subname if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
774
    }
775
    
cleanup
Yuki Kimoto authored on 2012-01-20
776
    # Create model
777
    my $opt = {};
778
    $opt->{model_class} = $mclass if $mclass;
779
    $opt->{name}        = $model_name if $model_name;
780
    $opt->{table}       = $model_table if $model_table;
781
    $self->create_model($opt);
782
  }
783
  
784
  return $self;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
785
}
786

            
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
787
sub like_value { sub { "%$_[0]%" } }
788

            
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
789
sub mapper {
cleanup
Yuki Kimoto authored on 2012-01-20
790
  my $self = shift;
791
  return DBIx::Custom::Mapper->new(@_);
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
792
}
793

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
794
sub merge_param {
cleanup
Yuki Kimoto authored on 2012-01-20
795
  my ($self, @params) = @_;
796
  
797
  # Merge parameters
798
  my $merge = {};
799
  for my $param (@params) {
800
    for my $column (keys %$param) {
801
      my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
802
      
803
      if (exists $merge->{$column}) {
804
        $merge->{$column} = [$merge->{$column}]
805
          unless ref $merge->{$column} eq 'ARRAY';
806
        push @{$merge->{$column}},
807
          ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
808
      }
809
      else { $merge->{$column} = $param->{$column} }
810
    }
811
  }
812
  
813
  return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
814
}
815

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
816
sub model {
cleanup
Yuki Kimoto authored on 2012-01-20
817
  my ($self, $name, $model) = @_;
818
  
819
  # Set model
820
  if ($model) {
821
    $self->models->{$name} = $model;
822
    return $self;
823
  }
824
  
825
  # Check model existance
826
  croak qq{Model "$name" is not included } . _subname
827
    unless $self->models->{$name};
828
  
829
  # Get model
830
  return $self->models->{$name};
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
831
}
832

            
cleanup
Yuki Kimoto authored on 2011-03-21
833
sub mycolumn {
cleanup
Yuki Kimoto authored on 2012-01-20
834
  my ($self, $table, $columns) = @_;
835
  
836
  # Create column clause
837
  my @column;
838
  $columns ||= [];
839
  push @column, $self->q($table) . "." . $self->q($_) . " as " . $self->q($_)
840
    for @$columns;
841
  
842
  return join (', ', @column);
cleanup
Yuki Kimoto authored on 2011-03-21
843
}
844

            
added dbi_options attribute
kimoto authored on 2010-12-20
845
sub new {
cleanup
Yuki Kimoto authored on 2012-01-20
846
  my $self = shift->SUPER::new(@_);
847
  
848
  # Check attributes
849
  my @attrs = keys %$self;
850
  for my $attr (@attrs) {
851
    croak qq{Invalid attribute: "$attr" } . _subname
852
      unless $self->can($attr);
853
  }
854
  
855
  $self->{safety_character} = 'a-zA-Z0-9_'
856
    unless exists $self->{safety_character};
857

            
858
  # DEPRECATED
859
  $self->{_tags} = {
860
    '?'     => \&DBIx::Custom::Tag::placeholder,
861
    '='     => \&DBIx::Custom::Tag::equal,
862
    '<>'    => \&DBIx::Custom::Tag::not_equal,
863
    '>'     => \&DBIx::Custom::Tag::greater_than,
864
    '<'     => \&DBIx::Custom::Tag::lower_than,
865
    '>='    => \&DBIx::Custom::Tag::greater_than_equal,
866
    '<='    => \&DBIx::Custom::Tag::lower_than_equal,
867
    'like'  => \&DBIx::Custom::Tag::like,
868
    'in'    => \&DBIx::Custom::Tag::in,
869
    'insert_param' => \&DBIx::Custom::Tag::insert_param,
870
    'update_param' => \&DBIx::Custom::Tag::update_param
871
  };
872
  $self->{tag_parse} = 1 unless exists $self->{tag_parse};
873
  $self->{cache} = 0 unless exists $self->{cache};
874
  
875
  return $self;
cleanup
Yuki Kimoto authored on 2011-08-13
876
}
877

            
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
878
sub not_exists { DBIx::Custom::NotExists->singleton }
cleanup
Yuki Kimoto authored on 2011-08-13
879

            
880
sub order {
cleanup
Yuki Kimoto authored on 2012-01-20
881
  my $self = shift;
882
  return DBIx::Custom::Order->new(dbi => $self, @_);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
883
}
884

            
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
885
sub q {
cleanup
Yuki Kimoto authored on 2012-01-20
886
  my ($self, $value, $quotemeta) = @_;
887
  
888
  my $quote = $self->{reserved_word_quote}
889
    || $self->{quote} || $self->quote || '';
890
  return "$quote$value$quote"
891
    if !$quotemeta && ($quote eq '`' || $quote eq '"');
892
  
893
  my $q = substr($quote, 0, 1) || '';
894
  my $p;
895
  if (defined $quote && length $quote > 1) {
896
    $p = substr($quote, 1, 1);
897
  }
898
  else { $p = $q }
899
  
900
  if ($quotemeta) {
901
    $q = quotemeta($q);
902
    $p = quotemeta($p);
903
  }
904
  
905
  return "$q$value$p";
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
906
}
907

            
cleanup
yuki-kimoto authored on 2010-10-17
908
sub register_filter {
cleanup
Yuki Kimoto authored on 2012-01-20
909
  my $self = shift;
910
  
911
  # Register filter
912
  my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
913
  $self->filters({%{$self->filters}, %$filters});
914
  
915
  return $self;
cleanup
yuki-kimoto authored on 2010-10-17
916
}
packaging one directory
yuki-kimoto authored on 2009-11-16
917

            
918
sub select {
cleanup
Yuki Kimoto authored on 2012-01-20
919
  my $self = shift;
920
  my $column = shift if @_ % 2;
921
  my %opt = @_;
922
  $opt{column} = $column if defined $column;
923

            
924
  # Options
925
  my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
926
    : defined $opt{table} ? [$opt{table}]
927
    : [];
928
  $opt{table} = $tables;
929
  my $where_param = $opt{where_param} || delete $opt{param} || {};
930
  warn "select method where_param option is DEPRECATED!"
931
    if $opt{where_param};
932
  
933
  # Add relation tables(DEPRECATED!);
934
  if ($opt{relation}) {
935
    warn "select() relation option is DEPRECATED!";
936
    $self->_add_relation_table($tables, $opt{relation});
937
  }
938
  
939
  # Select statement
940
  my $sql = 'select ';
941
  
942
  # Prefix
943
  $sql .= "$opt{prefix} " if defined $opt{prefix};
944
  
945
  # Column
946
  if (defined $opt{column}) {
947
    my $columns
948
      = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
949
    for my $column (@$columns) {
950
      if (ref $column eq 'HASH') {
951
        $column = $self->column(%$column) if ref $column eq 'HASH';
952
      }
953
      elsif (ref $column eq 'ARRAY') {
954
        warn "select column option [COLUMN => ALIAS] syntax is DEPRECATED!" .
955
          "use q method to quote the value";
956
        if (@$column == 3 && $column->[1] eq 'as') {
957
          warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
958
          splice @$column, 1, 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
959
        }
cleanup
Yuki Kimoto authored on 2012-01-20
960
        
961
        $column = join(' ', $column->[0], 'as', $self->q($column->[1]));
962
      }
963
      unshift @$tables, @{$self->_search_tables($column)};
964
      $sql .= "$column, ";
packaging one directory
yuki-kimoto authored on 2009-11-16
965
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
966
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2012-01-20
967
  }
968
  else { $sql .= '* ' }
969
  
970
  # Table
971
  $sql .= 'from ';
972
  if ($opt{relation}) {
973
    my $found = {};
974
    for my $table (@$tables) {
975
      $sql .= $self->q($table) . ', ' unless $found->{$table};
976
      $found->{$table} = 1;
977
    }
978
  }
979
  else { $sql .= $self->q($tables->[-1] || '') . ' ' }
980
  $sql =~ s/, $/ /;
981
  croak "select method table option must be specified " . _subname
982
    unless defined $tables->[-1];
983

            
984
  # Add tables in parameter
985
  unshift @$tables,
986
    @{$self->_search_tables(join(' ', keys %$where_param) || '')};
987
  
988
  # Where
989
  my $w = $self->_where_clause_and_param($opt{where}, $where_param,
990
    delete $opt{id}, $opt{primary_key}, $tables->[-1]);
991
  
992
  # Add table names in where clause
993
  unshift @$tables, @{$self->_search_tables($w->{clause})};
994
  
995
  # Join statement
996
  $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
997
  
998
  # Add where clause
999
  $sql .= "$w->{clause} ";
1000
  
1001
  # Relation(DEPRECATED!);
1002
  $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
1003
    if $opt{relation};
1004
  
1005
  # Execute query
1006
  $opt{statement} = 'select';
1007
  my $result = $self->execute($sql, $w->{param}, %opt);
1008
  
1009
  $result;
packaging one directory
yuki-kimoto authored on 2009-11-16
1010
}
1011

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
1012
sub setup_model {
cleanup
Yuki Kimoto authored on 2012-01-20
1013
  my $self = shift;
1014
  
1015
  # Setup model
1016
  $self->each_column(
1017
    sub {
1018
      my ($self, $table, $column, $column_info) = @_;
1019
      if (my $model = $self->models->{$table}) {
1020
        push @{$model->columns}, $column;
1021
      }
1022
    }
1023
  );
1024
  return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
1025
}
1026

            
update pod
Yuki Kimoto authored on 2011-08-10
1027
sub show_datatype {
cleanup
Yuki Kimoto authored on 2012-01-20
1028
  my ($self, $table) = @_;
1029
  croak "Table name must be specified" unless defined $table;
1030
  print "$table\n";
1031
  
1032
  my $result = $self->select(table => $table, where => "'0' <> '0'");
1033
  my $sth = $result->sth;
1034

            
1035
  my $columns = $sth->{NAME};
1036
  my $data_types = $sth->{TYPE};
1037
  
1038
  for (my $i = 0; $i < @$columns; $i++) {
1039
    my $column = $columns->[$i];
1040
    my $data_type = lc $data_types->[$i];
1041
    print "$column: $data_type\n";
1042
  }
update pod
Yuki Kimoto authored on 2011-08-10
1043
}
1044

            
1045
sub show_typename {
cleanup
Yuki Kimoto authored on 2012-01-20
1046
  my ($self, $t) = @_;
1047
  croak "Table name must be specified" unless defined $t;
1048
  print "$t\n";
1049
  
1050
  $self->each_column(sub {
1051
    my ($self, $table, $column, $infos) = @_;
1052
    return unless $table eq $t;
1053
    my $typename = lc $infos->{TYPE_NAME};
1054
    print "$column: $typename\n";
1055
  });
1056
  
1057
  return $self;
update pod
Yuki Kimoto authored on 2011-08-10
1058
}
1059

            
test cleanup
Yuki Kimoto authored on 2011-08-15
1060
sub show_tables {
cleanup
Yuki Kimoto authored on 2012-01-20
1061
  my $self = shift;
1062
  
1063
  my %tables;
1064
  $self->each_table(sub { $tables{$_[1]}++ });
1065
  print join("\n", sort keys %tables) . "\n";
1066
  return $self;
test cleanup
Yuki Kimoto authored on 2011-08-15
1067
}
1068

            
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1069
sub type_rule {
cleanup
Yuki Kimoto authored on 2012-01-20
1070
  my $self = shift;
1071

            
1072
  $self->{_type_rule_is_called} = 1;
1073
  
1074
  if (@_) {
1075
    my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1076
    
1077
    # Into
1078
    for my $i (1 .. 2) {
1079
      my $into = "into$i";
1080
      my $exists_into = exists $type_rule->{$into};
1081
      $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1082
      $self->{type_rule} = $type_rule;
1083
      $self->{"_$into"} = {};
1084
      for my $type_name (keys %{$type_rule->{$into} || {}}) {
1085
        croak qq{type name of $into section must be lower case}
1086
          if $type_name =~ /[A-Z]/;
1087
      }
1088
      
1089
      $self->each_column(sub {
1090
        my ($dbi, $table, $column, $column_info) = @_;
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1091
        
cleanup
Yuki Kimoto authored on 2012-01-20
1092
        my $type_name = lc $column_info->{TYPE_NAME};
1093
        if ($type_rule->{$into} &&
1094
            (my $filter = $type_rule->{$into}->{$type_name}))
1095
        {
1096
          return unless exists $type_rule->{$into}->{$type_name};
1097
          if (defined $filter && ref $filter ne 'CODE') 
1098
          {
1099
            my $fname = $filter;
1100
            croak qq{Filter "$fname" is not registered" } . _subname
1101
              unless exists $self->filters->{$fname};
cleanup
Yuki Kimoto authored on 2011-08-16
1102
            
cleanup
Yuki Kimoto authored on 2012-01-20
1103
            $filter = $self->filters->{$fname};
1104
          }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1105

            
cleanup
Yuki Kimoto authored on 2012-01-20
1106
          $self->{"_$into"}{key}{$table}{$column} = $filter;
1107
          $self->{"_$into"}{dot}{"$table.$column"} = $filter;
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1108
        }
cleanup
Yuki Kimoto authored on 2012-01-20
1109
      });
1110
    }
1111

            
1112
    # From
1113
    for my $i (1 .. 2) {
1114
      $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
1115
      for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
1116
        croak qq{data type of from$i section must be lower case or number}
1117
          if $data_type =~ /[A-Z]/;
1118
        my $fname = $type_rule->{"from$i"}{$data_type};
1119
        if (defined $fname && ref $fname ne 'CODE') {
1120
          croak qq{Filter "$fname" is not registered" } . _subname
1121
            unless exists $self->filters->{$fname};
1122
          
1123
          $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
1124
        }
1125
      }
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1126
    }
1127
    
cleanup
Yuki Kimoto authored on 2012-01-20
1128
    return $self;
1129
  }
1130
  
1131
  return $self->{type_rule} || {};
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1132
}
1133

            
cleanup
yuki-kimoto authored on 2010-10-17
1134
sub update {
cleanup
Yuki Kimoto authored on 2012-01-20
1135
  my $self = shift;
1136

            
1137
  # Options
1138
  my $param = @_ % 2 ? shift : undef;
1139
  my %opt = @_;
1140
  warn "update param option is DEPRECATED!" if $opt{param};
1141
  warn "update method where_param option is DEPRECATED!"
1142
    if $opt{where_param};
1143
  $param ||= $opt{param} || {};
1144
  
1145
  # Don't allow update all rows
1146
  croak qq{update method where option must be specified } . _subname
1147
    if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1148
  
1149
  # Timestamp(DEPRECATED!)
1150
  if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
1151
    warn "update timestamp option is DEPRECATED! use updated_at and now method";
1152
    my $columns = $update_timestamp->[0];
1153
    $columns = [$columns] unless ref $columns eq 'ARRAY';
1154
    my $value = $update_timestamp->[1];
1155
    $value = $value->() if ref $value eq 'CODE';
1156
    $param->{$_} = $value for @$columns;
1157
  }
1158

            
1159
  # Created time and updated time
1160
  my @timestamp_cleanup;
1161
  if (defined $opt{updated_at}) {
1162
    my $now = $self->now;
1163
    $now = $now->() if ref $now eq 'CODE';
1164
    $param->{$opt{updated_at}} = $self->now->();
1165
    push @timestamp_cleanup, $opt{updated_at};
1166
  }
1167

            
1168
  # Assign clause
1169
  my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
1170
  
1171
  # Where
1172
  my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
1173
    delete $opt{id}, $opt{primary_key}, $opt{table});
1174
  
1175
  # Update statement
1176
  my $sql = "update ";
1177
  $sql .= "$opt{prefix} " if defined $opt{prefix};
1178
  $sql .= $self->q($opt{table}) . " set $assign_clause $w->{clause} ";
1179
  
1180
  # Execute query
1181
  $opt{statement} = 'update';
1182
  $opt{cleanup} = \@timestamp_cleanup;
1183
  $self->execute($sql, [$param, $w->{param}], %opt);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1184
}
1185

            
cleanup
Yuki Kimoto authored on 2011-11-01
1186
sub update_all { shift->update(@_, allow_update_all => 1) };
cleanup
yuki-kimoto authored on 2010-10-17
1187

            
cleanup
Yuki Kimoto authored on 2011-10-21
1188
sub update_or_insert {
cleanup
Yuki Kimoto authored on 2012-01-20
1189
  my ($self, $param, %opt) = @_;
1190
  croak "update_or_insert method need primary_key and id option "
1191
    unless defined $opt{id} && defined $opt{primary_key};
1192
  my $statement_opt = $opt{option} || {};
1193

            
1194
  my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
1195
  if (@$rows == 0) {
1196
    return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
1197
  }
1198
  elsif (@$rows == 1) {
1199
    return 0 unless keys %$param;
1200
    return $self->update($param, %opt, %{$statement_opt->{update} || {}});
1201
  }
1202
  else { croak "selected row must be one " . _subname }
cleanup
Yuki Kimoto authored on 2011-10-21
1203
}
1204

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1205
sub update_timestamp {
cleanup
Yuki Kimoto authored on 2012-01-20
1206
  my $self = shift;
1207
  
1208
  warn "update_timestamp method is DEPRECATED! use now method";
1209
  
1210
  if (@_) {
1211
    $self->{update_timestamp} = [@_];
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1212
    
cleanup
Yuki Kimoto authored on 2012-01-20
1213
    return $self;
1214
  }
1215
  return $self->{update_timestamp};
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1216
}
1217

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1218
sub values_clause {
cleanup
Yuki Kimoto authored on 2012-01-20
1219
  my ($self, $param, $opts) = @_;
1220
  
1221
  my $wrap = $opts->{wrap} || {};
1222
  
1223
  # Create insert parameter tag
1224
  my ($q, $p) = split //, $self->q('');
1225
  
1226
  # values clause(performance is important)
1227
  '(' .
1228
  join(
1229
    ', ',
1230
    map { "$q$_$p" } sort keys %$param
1231
  ) .
1232
  ') values (' .
1233
  join(
1234
    ', ',
1235
    map {
1236
      ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1237
      $wrap->{$_} ? $wrap->{$_}->(":$_") :
1238
      ":$_";
1239
    } sort keys %$param
1240
  ) .
1241
  ')'
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1242
}
1243

            
added EXPERIMENTAL bulk_inse...
Yuki Kimoto authored on 2011-11-27
1244
sub _multi_values_clause {
cleanup
Yuki Kimoto authored on 2012-01-20
1245
  my ($self, $params, $opts) = @_;
1246
  
1247
  my $wrap = $opts->{wrap} || {};
1248
  
1249
  # Create insert parameter tag
1250
  my ($q, $p) = split //, $self->q('');
1251
  
1252
  # Multi values clause
1253
  my $clause = '(' . join(', ', map { "$q$_$p" } sort keys %{$params->[0]}) . ') values ';
1254
  
1255
  for (1 .. @$params) {
1256
    $clause .= '(' . join(', ', 
1257
      map {
1258
        ref $params->[0]->{$_} eq 'SCALAR' ? ${$params->[0]->{$_}} :
1259
        $wrap->{$_} ? $wrap->{$_}->(":$_") :
1260
        ":$_";
1261
      } sort keys %{$params->[0]}
1262
    ) . '), '
1263
  }
1264
  $clause =~ s/, $//;
1265
  return $clause;
added EXPERIMENTAL bulk_inse...
Yuki Kimoto authored on 2011-11-27
1266
}
1267

            
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
1268
sub where { DBIx::Custom::Where->new(dbi => shift, @_) }
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1269

            
updated pod
Yuki Kimoto authored on 2011-06-21
1270
sub _create_query {
cleanup
Yuki Kimoto authored on 2012-01-20
1271
  
1272
  my ($self, $source, $after_build_sql) = @_;
1273
  
1274
  # Cache
1275
  my $cache = $self->{cache};
1276
  
1277
  # Query
1278
  my $query;
1279
  
1280
  # Get cached query
1281
  if ($cache) {
1282
    
1283
    # Get query
1284
    my $q = $self->cache_method->($self, $source);
updated pod
Yuki Kimoto authored on 2011-06-21
1285
    
1286
    # Create query
cleanup
Yuki Kimoto authored on 2012-01-20
1287
    if ($q) {
1288
      $query = DBIx::Custom::Query->new($q);
1289
      $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1290
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1291
  }
1292
  
1293
  # Create query
1294
  unless ($query) {
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1295

            
cleanup
Yuki Kimoto authored on 2012-01-20
1296
    # Create query
1297
    my $tag_parse = exists $ENV{DBIX_CUSTOM_TAG_PARSE}
1298
      ? $ENV{DBIX_CUSTOM_TAG_PARSE} : $self->{tag_parse};
1299

            
1300
    my $sql = " " . $source || '';
1301
    if ($tag_parse && ($sql =~ /\s\{/)) {
1302
      $query = $self->query_builder->build_query($sql);
updated pod
Yuki Kimoto authored on 2011-06-21
1303
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1304
    else {
1305
      my @columns;
1306
      my $c = $self->{safety_character};
1307
      my $re = $c eq 'a-zA-Z0-9_'
1308
        ? qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/so
1309
        : qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s;
1310
      my %duplicate;
1311
      my $duplicate;
1312
      # Parameter regex
1313
      $sql =~ s/([0-9]):/$1\\:/g;
1314
      my $new_sql = '';
1315
      while ($sql =~ /$re/) {
1316
        push @columns, $2;
1317
        $duplicate = 1 if ++$duplicate{$columns[-1]} > 1;
1318
        ($new_sql, $sql) = defined $3 ?
1319
          ($new_sql . "$1$2 $3 ?", " $4") : ($new_sql . "$1?", " $4");
1320
      }
1321
      $new_sql .= $sql;
1322
      $new_sql =~ s/\\:/:/g if index($new_sql, "\\:") != -1;
1323

            
1324
      # Create query
1325
      $query = {sql => $new_sql, columns => \@columns, duplicate => $duplicate};
1326
    }
1327
    
1328
    # Save query to cache
1329
    $self->cache_method->(
1330
      $self, $source,
1331
      {
1332
        sql     => $query->{sql}, 
1333
        columns => $query->{columns},
1334
        tables  => $query->{tables} || []
1335
      }
1336
    ) if $cache;
1337
  }
1338

            
1339
  # Filter SQL
1340
  $query->{sql} = $after_build_sql->($query->{sql}) if $after_build_sql;
1341
  
1342
  # Save sql
1343
  $self->{last_sql} = $query->{sql};
1344
  
1345
  # Prepare statement handle
1346
  my $sth;
1347
  eval { $sth = $self->dbh->prepare($query->{sql}) };
1348
  
1349
  if ($@) {
1350
    $self->_croak($@, qq{. Following SQL is executed.\n}
1351
                    . qq{$query->{sql}\n} . _subname);
1352
  }
1353
  
1354
  # Set statement handle
1355
  $query->{sth} = $sth;
1356
  
1357
  # Set filters
1358
  $query->{filters} = $self->{filters} || $self->filters;
1359
  
1360
  return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1361
}
1362

            
cleanup
Yuki Kimoto authored on 2012-01-20
1363
sub _create_bind_values {
1364
  my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
1365
  
1366
  $bind_type = _array_to_hash($bind_type) if ref $bind_type eq 'ARRAY';
1367
  
1368
  # Create bind values
1369
  my @bind;
1370
  my @types;
1371
  my %count;
1372
  my %not_exists;
1373
  for my $column (@$columns) {
1374
    
1375
    # Bind value
1376
    if(ref $params->{$column} eq 'ARRAY') {
1377
      my $i = $count{$column} || 0;
1378
      $i += $not_exists{$column} || 0;
1379
      my $found;
1380
      for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1381
        if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
1382
            $not_exists{$column}++;
micro optimization
Yuki Kimoto authored on 2011-10-23
1383
        }
cleanup
Yuki Kimoto authored on 2012-01-20
1384
        else  {
1385
          push @bind, $params->{$column}->[$k];
1386
          $found = 1;
1387
          last
micro optimization
Yuki Kimoto authored on 2011-10-23
1388
        }
cleanup
Yuki Kimoto authored on 2012-01-20
1389
      }
1390
      next unless $found;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1391
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1392
    else { push @bind, $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1393
    
cleanup
Yuki Kimoto authored on 2012-01-20
1394
    # Filter
1395
    if (my $f = $filter->{$column} || $self->{default_out_filter} || '') {
1396
      $bind[-1] = $f->($bind[-1]);
1397
    }
improved error messages
Yuki Kimoto authored on 2011-04-18
1398
    
cleanup
Yuki Kimoto authored on 2012-01-20
1399
    # Type rule
1400
    if ($self->{_type_rule_is_called}) {
1401
      my $tf1 = $self->{"_into1"}->{dot}->{$column}
1402
        || $type_filters->{1}->{$column};
1403
      $bind[-1] = $tf1->($bind[-1]) if $tf1;
1404
      my $tf2 = $self->{"_into2"}->{dot}->{$column}
1405
        || $type_filters->{2}->{$column};
1406
      $bind[-1] = $tf2->($bind[-1]) if $tf2;
improved error messages
Yuki Kimoto authored on 2011-04-18
1407
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1408
   
1409
    # Bind types
1410
    push @types, $bind_type->{$column};
improved error messages
Yuki Kimoto authored on 2011-04-18
1411
    
cleanup
Yuki Kimoto authored on 2012-01-20
1412
    # Count up 
1413
    $count{$column}++;
1414
  }
1415
  
1416
  return (\@bind, \@types);
1417
}
1418

            
1419
sub _id_to_param {
1420
  my ($self, $id, $primary_keys, $table) = @_;
1421
  
1422
  # Check primary key
1423
  croak "primary_key option " .
1424
        "must be specified when id option is used" . _subname
1425
    unless defined $primary_keys;
1426
  $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
1427
  
1428
  # Create parameter
1429
  my $param = {};
1430
  if (defined $id) {
1431
    $id = [$id] unless ref $id;
1432
    for(my $i = 0; $i < @$id; $i++) {
1433
      my $key = $primary_keys->[$i];
1434
      $key = "$table." . $key if $table;
1435
      $param->{$key} = $id->[$i];
1436
    }
1437
  }
1438
  
1439
  return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1440
}
1441

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1442
sub _connect {
cleanup
Yuki Kimoto authored on 2012-01-20
1443
  my $self = shift;
1444
  
1445
  # Attributes
1446
  my $dsn = $self->data_source;
1447
  warn "data_source is DEPRECATED!\n"
1448
    if $dsn;
1449
  $dsn ||= $self->dsn;
1450
  croak qq{"dsn" must be specified } . _subname
1451
    unless $dsn;
1452
  my $user        = $self->user;
1453
  my $password    = $self->password;
1454
  my $option = $self->_option;
1455
  $option = {%{$self->default_option}, %$option};
1456
  
1457
  # Connect
1458
  my $dbh;
1459
  eval { $dbh = DBI->connect($dsn, $user, $password, $option) };
1460
  
1461
  # Connect error
1462
  croak "$@ " . _subname if $@;
1463
  
1464
  return $dbh;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1465
}
1466

            
cleanup
yuki-kimoto authored on 2010-10-17
1467
sub _croak {
cleanup
Yuki Kimoto authored on 2012-01-20
1468
  my ($self, $error, $append) = @_;
1469
  
1470
  # Append
1471
  $append ||= "";
1472
  
1473
  # Verbose
1474
  if ($Carp::Verbose) { croak $error }
1475
  
1476
  # Not verbose
1477
  else {
1478
    # Remove line and module infromation
1479
    my $at_pos = rindex($error, ' at ');
1480
    $error = substr($error, 0, $at_pos);
1481
    $error =~ s/\s+$//;
1482
    croak "$error$append";
1483
  }
cleanup
yuki-kimoto authored on 2010-10-17
1484
}
1485

            
prepare oracle test
Yuki Kimoto authored on 2011-08-15
1486
sub _driver { lc shift->{dbh}->{Driver}->{Name} }
1487

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1488
sub _need_tables {
cleanup
Yuki Kimoto authored on 2012-01-20
1489
  my ($self, $tree, $need_tables, $tables) = @_;
1490
  
1491
  # Get needed tables
1492
  for my $table (@$tables) {
1493
    if ($tree->{$table}) {
1494
      $need_tables->{$table} = 1;
1495
      $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1496
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1497
  }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1498
}
1499

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1500
sub _option {
cleanup
Yuki Kimoto authored on 2012-01-20
1501
  my $self = shift;
1502
  my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1503
  warn "dbi_options is DEPRECATED! use option instead\n"
1504
    if keys %{$self->dbi_options};
1505
  warn "dbi_option is DEPRECATED! use option instead\n"
1506
    if keys %{$self->dbi_option};
1507
  return $option;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1508
}
1509

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1510
sub _push_join {
cleanup
Yuki Kimoto authored on 2012-01-20
1511
  my ($self, $sql, $join, $join_tables) = @_;
1512
  
1513
  $join = [$join] unless ref $join eq 'ARRAY';
1514
  
1515
  # No join
1516
  return unless @$join;
1517
  
1518
  # Push join clause
1519
  my $tree = {};
1520
  for (my $i = 0; $i < @$join; $i++) {
1521
    
1522
    # Arrange
1523
    my $join_clause;;
1524
    my $option;
1525
    if (ref $join->[$i] eq 'HASH') {
1526
      $join_clause = $join->[$i]->{clause};
1527
      $option = {table => $join->[$i]->{table}};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1528
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1529
    else {
1530
      $join_clause = $join->[$i];
1531
      $option = {};
1532
    };
1533

            
1534
    # Find tables in join clause
1535
    my $table1;
1536
    my $table2;
1537
    if (my $table = $option->{table}) {
1538
      $table1 = $table->[0];
1539
      $table2 = $table->[1];
1540
    }
1541
    else {
1542
      my $q = $self->_quote;
1543
      my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1544
      $j_clause =~ s/'.+?'//g;
1545
      my $q_re = quotemeta($q);
1546
      $j_clause =~ s/[$q_re]//g;
1547
      
1548
      my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
1549
      my $c = $self->{safety_character};
1550
      my $join_re = qr/([$c]+)\.[$c]+[^$c].*?([$c]+)\.[$c]+/sm;
1551
      for my $clause (@j_clauses) {
1552
        if ($clause =~ $join_re) {
1553
          $table1 = $1;
1554
          $table2 = $2;
1555
          last;
1556
        }                
1557
      }
1558
    }
1559
    croak qq{join clause must have two table name after "on" keyword. } .
1560
        qq{"$join_clause" is passed }  . _subname
1561
      unless defined $table1 && defined $table2;
1562
    croak qq{right side table of "$join_clause" must be unique } . _subname
1563
      if exists $tree->{$table2};
1564
    croak qq{Same table "$table1" is specified} . _subname
1565
      if $table1 eq $table2;
1566
    $tree->{$table2}
1567
      = {position => $i, parent => $table1, join => $join_clause};
1568
  }
1569
  
1570
  # Search need tables
1571
  my $need_tables = {};
1572
  $self->_need_tables($tree, $need_tables, $join_tables);
1573
  my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} }
1574
    keys %$need_tables;
1575
  
1576
  # Add join clause
1577
  $$sql .= $tree->{$_}{join} . ' ' for @need_tables;
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1578
}
cleanup
Yuki Kimoto authored on 2011-03-08
1579

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1580
sub _quote {
cleanup
Yuki Kimoto authored on 2012-01-20
1581
  my $self = shift;
1582
  return $self->{reserved_word_quote} || $self->quote || '';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1583
}
1584

            
cleanup
Yuki Kimoto authored on 2011-04-02
1585
sub _remove_duplicate_table {
cleanup
Yuki Kimoto authored on 2012-01-20
1586
  my ($self, $tables, $main_table) = @_;
1587
  
1588
  # Remove duplicate table
1589
  my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1590
  delete $tables{$main_table} if $main_table;
1591
  
1592
  my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1593
  if (my $q = $self->_quote) {
1594
    $q = quotemeta($q);
1595
    $_ =~ s/[$q]//g for @$new_tables;
1596
  }
micro optimization
Yuki Kimoto authored on 2011-07-30
1597

            
cleanup
Yuki Kimoto authored on 2012-01-20
1598
  return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1599
}
1600

            
cleanup
Yuki Kimoto authored on 2011-04-02
1601
sub _search_tables {
cleanup
Yuki Kimoto authored on 2012-01-20
1602
  my ($self, $source) = @_;
1603
  
1604
  # Search tables
1605
  my $tables = [];
1606
  my $safety_character = $self->{safety_character};
1607
  my $q = $self->_quote;
1608
  my $quoted_safety_character_re = $self->q("?([$safety_character]+)", 1);
1609
  my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
1610
    : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
1611
  while ($source =~ /$table_re/g) { push @$tables, $1 }
1612
  return $tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1613
}
1614

            
cleanup
Yuki Kimoto authored on 2011-10-21
1615
sub _where_clause_and_param {
cleanup
Yuki Kimoto authored on 2012-01-20
1616
  my ($self, $where, $where_param, $id, $primary_key, $table) = @_;
1617

            
1618
  $where ||= {};
1619
  $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
1620
  $where_param ||= {};
1621
  my $w = {};
1622
  my $where_clause = '';
1623

            
1624
  my $obj;
1625
  
1626
  if (ref $where) {
1627
    if (ref $where eq 'HASH') {
1628
      my $clause = ['and'];
1629
      my $column_join = '';
1630
      for my $column (keys %$where) {
1631
        $column_join .= $column;
1632
        my $table;
1633
        my $c;
1634
        if ($column =~ /(?:(.*?)\.)?(.*)/) {
1635
          $table = $1;
1636
          $c = $2;
cleanup
Yuki Kimoto authored on 2011-10-25
1637
        }
1638
        
cleanup
Yuki Kimoto authored on 2012-01-20
1639
        my $table_quote;
1640
        $table_quote = $self->q($table) if defined $table;
1641
        my $column_quote = $self->q($c);
1642
        $column_quote = $table_quote . '.' . $column_quote
1643
          if defined $table_quote;
1644
        push @$clause, "$column_quote = :$column";
1645
      }
1646

            
1647
      # Check unsafety column
1648
      my $safety = $self->{safety_character};
1649
      unless ($column_join =~ /^[$safety\.]+$/) {
1650
        for my $column (keys %$where) {
1651
          croak qq{"$column" is not safety column name } . _subname
1652
            unless $column =~ /^[$safety\.]+$/;
1653
        }
1654
      }
1655
      
1656
      $obj = $self->where(clause => $clause, param => $where);
1657
    }
1658
    elsif (ref $where eq 'DBIx::Custom::Where') { $obj = $where }
1659
    elsif (ref $where eq 'ARRAY') {
1660
      $obj = $self->where(clause => $where->[0], param => $where->[1]);
1661
    }
1662
    
1663
    # Check where argument
1664
    croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1665
        . qq{or array reference, which contains where clause and parameter}
1666
        . _subname
1667
      unless ref $obj eq 'DBIx::Custom::Where';
1668

            
1669
    $w->{param} = keys %$where_param
1670
      ? $self->merge_param($where_param, $obj->param)
1671
      : $obj->param;
1672
    $w->{clause} = $obj->to_string;
1673
  }
1674
  elsif ($where) {
1675
    $w->{clause} = "where $where";
1676
    $w->{param} = $where_param;
1677
  }
1678
  
1679
  return $w;
cleanup
Yuki Kimoto authored on 2011-10-21
1680
}
1681

            
updated pod
Yuki Kimoto authored on 2011-06-21
1682
sub _apply_filter {
cleanup
Yuki Kimoto authored on 2012-01-20
1683
  my ($self, $table, @cinfos) = @_;
1684

            
1685
  # Initialize filters
1686
  $self->{filter} ||= {};
1687
  $self->{filter}{on} = 1;
1688
  $self->{filter}{out} ||= {};
1689
  $self->{filter}{in} ||= {};
1690
  $self->{filter}{end} ||= {};
1691
  
1692
  # Usage
1693
  my $usage = "Usage: \$dbi->apply_filter(" .
1694
    "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1695
    "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1696
  
1697
  # Apply filter
1698
  for (my $i = 0; $i < @cinfos; $i += 2) {
updated pod
Yuki Kimoto authored on 2011-06-21
1699
    
cleanup
Yuki Kimoto authored on 2012-01-20
1700
    # Column
1701
    my $column = $cinfos[$i];
1702
    if (ref $column eq 'ARRAY') {
1703
      for my $c (@$column) { push @cinfos, $c, $cinfos[$i + 1] }
1704
      next;
1705
    }
updated pod
Yuki Kimoto authored on 2011-06-21
1706
    
cleanup
Yuki Kimoto authored on 2012-01-20
1707
    # Filter infomation
1708
    my $finfo = $cinfos[$i + 1] || {};
1709
    croak "$usage (table: $table) " . _subname
1710
      unless  ref $finfo eq 'HASH';
1711
    for my $ftype (keys %$finfo) {
1712
      croak "$usage (table: $table) " . _subname
1713
        unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
updated pod
Yuki Kimoto authored on 2011-06-21
1714
    }
1715
    
cleanup
Yuki Kimoto authored on 2012-01-20
1716
    # Set filters
1717
    for my $way (qw/in out end/) {
1718
  
1719
      # Filter
1720
      my $filter = $finfo->{$way};
1721
      
1722
      # Filter state
1723
      my $state = !exists $finfo->{$way} ? 'not_exists'
1724
        : !defined $filter        ? 'not_defined'
1725
        : ref $filter eq 'CODE'   ? 'code'
1726
        : 'name';
1727
      
1728
      # Filter is not exists
1729
      next if $state eq 'not_exists';
1730
      
1731
      # Check filter name
1732
      croak qq{Filter "$filter" is not registered } . _subname
1733
        if  $state eq 'name' && ! exists $self->filters->{$filter};
1734
      
1735
      # Set filter
1736
      my $f = $state eq 'not_defined' ? undef
1737
        : $state eq 'code' ? $filter
1738
        : $self->filters->{$filter};
1739
      $self->{filter}{$way}{$table}{$column} = $f;
1740
      $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1741
      $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1742
      $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1743
    }
1744
  }
1745
  
1746
  return $self;
updated pod
Yuki Kimoto authored on 2011-06-21
1747
}
1748

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1749
# DEPRECATED!
1750
has 'data_source';
1751
has dbi_options => sub { {} };
1752
has filter_check  => 1;
1753
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1754
has dbi_option => sub { {} };
1755
has default_dbi_option => sub {
cleanup
Yuki Kimoto authored on 2012-01-20
1756
  warn "default_dbi_option is DEPRECATED! use default_option instead";
1757
  return shift->default_option;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1758
};
1759

            
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
1760
# DEPRECATED
1761
sub tag_parse {
cleanup
Yuki Kimoto authored on 2012-01-20
1762
 my $self = shift;
1763
 warn "tag_parse is DEPRECATED! use \$ENV{DBIX_CUSTOM_TAG_PARSE} " .
1764
   "environment variable";
1765
  if (@_) {
1766
    $self->{tag_parse} = $_[0];
1767
    return $self;
1768
  }
1769
  return $self->{tag_parse};
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
1770
}
1771

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1772
# DEPRECATED!
1773
sub method {
cleanup
Yuki Kimoto authored on 2012-01-20
1774
  warn "method is DEPRECATED! use helper instead";
1775
  return shift->helper(@_);
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1776
}
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1777

            
1778
# DEPRECATED!
1779
sub assign_param {
cleanup
Yuki Kimoto authored on 2012-01-20
1780
  my $self = shift;
1781
  warn "assing_param is DEPRECATED! use assign_clause instead";
1782
  return $self->assign_clause(@_);
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1783
}
1784

            
1785
# DEPRECATED
1786
sub update_param {
cleanup
Yuki Kimoto authored on 2012-01-20
1787
  my ($self, $param, $opts) = @_;
1788
  
1789
  warn "update_param is DEPRECATED! use assign_clause instead.";
1790
  
1791
  # Create update parameter tag
1792
  my $tag = $self->assign_clause($param, $opts);
1793
  $tag = "set $tag" unless $opts->{no_set};
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1794

            
cleanup
Yuki Kimoto authored on 2012-01-20
1795
  return $tag;
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1796
}
1797

            
updated pod
Yuki Kimoto authored on 2011-06-21
1798
# DEPRECATED!
1799
sub create_query {
cleanup
Yuki Kimoto authored on 2012-01-20
1800
  warn "create_query is DEPRECATED! use query option of each method";
1801
  shift->_create_query(@_);
updated pod
Yuki Kimoto authored on 2011-06-21
1802
}
1803

            
cleanup
Yuki Kimoto authored on 2011-06-13
1804
# DEPRECATED!
1805
sub apply_filter {
cleanup
Yuki Kimoto authored on 2012-01-20
1806
  my $self = shift;
1807
  
1808
  warn "apply_filter is DEPRECATED!";
1809
  return $self->_apply_filter(@_);
cleanup
Yuki Kimoto authored on 2011-06-13
1810
}
1811

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1812
# DEPRECATED!
1813
sub select_at {
cleanup
Yuki Kimoto authored on 2012-01-20
1814
  my ($self, %opt) = @_;
1815

            
1816
  warn "select_at is DEPRECATED! use select method id option instead";
1817

            
1818
  # Options
1819
  my $primary_keys = delete $opt{primary_key};
1820
  my $where = delete $opt{where};
1821
  my $param = delete $opt{param};
1822
  
1823
  # Table
1824
  croak qq{"table" option must be specified } . _subname
1825
    unless $opt{table};
1826
  my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
1827
  
1828
  # Create where parameter
1829
  my $where_param = $self->_id_to_param($where, $primary_keys);
1830
  
1831
  return $self->select(where => $where_param, %opt);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1832
}
1833

            
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1834
# DEPRECATED!
1835
sub delete_at {
cleanup
Yuki Kimoto authored on 2012-01-20
1836
  my ($self, %opt) = @_;
updated pod
Yuki Kimoto authored on 2011-06-08
1837

            
cleanup
Yuki Kimoto authored on 2012-01-20
1838
  warn "delete_at is DEPRECATED! use delete method id option instead";
1839
  
1840
  # Options
1841
  my $primary_keys = delete $opt{primary_key};
1842
  my $where = delete $opt{where};
1843
  
1844
  # Create where parameter
1845
  my $where_param = $self->_id_to_param($where, $primary_keys);
1846
  
1847
  return $self->delete(where => $where_param, %opt);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1848
}
1849

            
cleanup
Yuki Kimoto authored on 2011-06-08
1850
# DEPRECATED!
1851
sub update_at {
cleanup
Yuki Kimoto authored on 2012-01-20
1852
  my $self = shift;
1853

            
1854
  warn "update_at is DEPRECATED! use update method id option instead";
1855
  
1856
  # Options
1857
  my $param;
1858
  $param = shift if @_ % 2;
1859
  my %opt = @_;
1860
  my $primary_keys = delete $opt{primary_key};
1861
  my $where = delete $opt{where};
1862
  my $p = delete $opt{param} || {};
1863
  $param  ||= $p;
1864
  
1865
  # Create where parameter
1866
  my $where_param = $self->_id_to_param($where, $primary_keys);
1867
  
1868
  return $self->update(where => $where_param, param => $param, %opt);
cleanup
Yuki Kimoto authored on 2011-06-08
1869
}
1870

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1871
# DEPRECATED!
1872
sub insert_at {
cleanup
Yuki Kimoto authored on 2012-01-20
1873
  my $self = shift;
1874
  
1875
  warn "insert_at is DEPRECATED! use insert method id option instead";
1876
  
1877
  # Options
1878
  my $param;
1879
  $param = shift if @_ % 2;
1880
  my %opt = @_;
1881
  my $primary_key = delete $opt{primary_key};
1882
  $primary_key = [$primary_key] unless ref $primary_key;
1883
  my $where = delete $opt{where};
1884
  my $p = delete $opt{param} || {};
1885
  $param  ||= $p;
1886
  
1887
  # Create where parameter
1888
  my $where_param = $self->_id_to_param($where, $primary_key);
1889
  $param = $self->merge_param($where_param, $param);
1890
  
1891
  return $self->insert(param => $param, %opt);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1892
}
1893

            
added warnings
Yuki Kimoto authored on 2011-06-07
1894
# DEPRECATED!
1895
sub register_tag {
cleanup
Yuki Kimoto authored on 2012-01-20
1896
  my $self = shift;
1897
  
1898
  warn "register_tag is DEPRECATED!";
1899
  
1900
  # Merge tag
1901
  my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1902
  $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1903
  
1904
  return $self;
test cleanup
Yuki Kimoto authored on 2011-08-10
1905
}
1906

            
1907
# DEPRECATED!
1908
sub register_tag_processor {
cleanup
Yuki Kimoto authored on 2012-01-20
1909
  my $self = shift;
1910
  warn "register_tag_processor is DEPRECATED!";
1911
  # Merge tag
1912
  my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1913
  $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1914
  return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1915
}
1916

            
cleanup
Yuki Kimoto authored on 2011-01-25
1917
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1918
sub default_bind_filter {
cleanup
Yuki Kimoto authored on 2012-01-20
1919
  my $self = shift;
1920
  
1921
  warn "default_bind_filter is DEPRECATED!";
1922
  
1923
  if (@_) {
1924
    my $fname = $_[0];
added warnings
Yuki Kimoto authored on 2011-06-07
1925
    
cleanup
Yuki Kimoto authored on 2012-01-20
1926
    if (@_ && !$fname) {
1927
      $self->{default_out_filter} = undef;
cleanup
Yuki Kimoto authored on 2011-01-12
1928
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1929
    else {
1930
      croak qq{Filter "$fname" is not registered}
1931
        unless exists $self->filters->{$fname};
1932
  
1933
      $self->{default_out_filter} = $self->filters->{$fname};
1934
    }
1935
    return $self;
1936
  }
1937
  
1938
  return $self->{default_out_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1939
}
1940

            
cleanup
Yuki Kimoto authored on 2011-01-25
1941
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1942
sub default_fetch_filter {
cleanup
Yuki Kimoto authored on 2012-01-20
1943
  my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1944

            
cleanup
Yuki Kimoto authored on 2012-01-20
1945
  warn "default_fetch_filter is DEPRECATED!";
1946
  
1947
  if (@_) {
1948
    my $fname = $_[0];
many changed
Yuki Kimoto authored on 2011-01-23
1949

            
cleanup
Yuki Kimoto authored on 2012-01-20
1950
    if (@_ && !$fname) {
1951
      $self->{default_in_filter} = undef;
1952
    }
1953
    else {
1954
      croak qq{Filter "$fname" is not registered}
1955
        unless exists $self->filters->{$fname};
1956
  
1957
      $self->{default_in_filter} = $self->filters->{$fname};
cleanup
Yuki Kimoto authored on 2011-01-12
1958
    }
1959
    
cleanup
Yuki Kimoto authored on 2012-01-20
1960
    return $self;
1961
  }
1962
  
1963
  return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1964
}
1965

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1966
# DEPRECATED!
1967
sub insert_param {
cleanup
Yuki Kimoto authored on 2012-01-20
1968
  my $self = shift;
1969
  warn "insert_param is DEPRECATED! use values_clause instead";
1970
  return $self->values_clause(@_);
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1971
}
1972

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1973
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1974
sub insert_param_tag {
cleanup
Yuki Kimoto authored on 2012-01-20
1975
  warn "insert_param_tag is DEPRECATED! " .
1976
    "use insert_param instead!";
1977
  return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1978
}
1979

            
1980
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1981
sub update_param_tag {
cleanup
Yuki Kimoto authored on 2012-01-20
1982
  warn "update_param_tag is DEPRECATED! " .
1983
    "use update_param instead";
1984
  return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1985
}
cleanup
Yuki Kimoto authored on 2011-03-08
1986
# DEPRECATED!
1987
sub _push_relation {
cleanup
Yuki Kimoto authored on 2012-01-20
1988
  my ($self, $sql, $tables, $relation, $need_where) = @_;
1989
  
1990
  if (keys %{$relation || {}}) {
1991
    $$sql .= $need_where ? 'where ' : 'and ';
1992
    for my $rcolumn (keys %$relation) {
1993
      my $table1 = (split (/\./, $rcolumn))[0];
1994
      my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1995
      push @$tables, ($table1, $table2);
1996
      $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
cleanup
Yuki Kimoto authored on 2011-03-08
1997
    }
cleanup
Yuki Kimoto authored on 2012-01-20
1998
  }
1999
  $$sql =~ s/and $/ /;
cleanup
Yuki Kimoto authored on 2011-03-08
2000
}
2001

            
2002
# DEPRECATED!
2003
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2012-01-20
2004
  my ($self, $tables, $relation) = @_;
2005
  
2006
  if (keys %{$relation || {}}) {
2007
    for my $rcolumn (keys %$relation) {
2008
      my $table1 = (split (/\./, $rcolumn))[0];
2009
      my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
2010
      my $table1_exists;
2011
      my $table2_exists;
2012
      for my $table (@$tables) {
2013
        $table1_exists = 1 if $table eq $table1;
2014
        $table2_exists = 1 if $table eq $table2;
2015
      }
2016
      unshift @$tables, $table1 unless $table1_exists;
2017
      unshift @$tables, $table2 unless $table2_exists;
2018
    }
2019
  }
cleanup
Yuki Kimoto authored on 2011-03-08
2020
}
2021

            
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
2022
1;
2023

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
2024
=head1 NAME
2025

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
2026
DBIx::Custom - DBI extension to execute insert, update, delete, and select easily
removed reconnect method
yuki-kimoto authored on 2010-05-28
2027

            
fix heading typos
Terrence Brannon authored on 2011-08-17
2028
=head1 SYNOPSIS
cleanup
yuki-kimoto authored on 2010-08-05
2029

            
cleanup
Yuki Kimoto authored on 2012-01-20
2030
  use DBIx::Custom;
2031
  
2032
  # Connect
2033
  my $dbi = DBIx::Custom->connect(
2034
    dsn => "dbi:mysql:database=dbname",
2035
    user => 'ken',
2036
    password => '!LFKD%$&',
2037
    option => {mysql_enable_utf8 => 1}
2038
  );
2039

            
2040
  # Insert 
2041
  $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
2042
  
2043
  # Update 
2044
  $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
2045
    where  => {id => 5});
2046
  
2047
  # Delete
2048
  $dbi->delete(table  => 'book', where => {author => 'Ken'});
2049

            
2050
  # Select
2051
  my $result = $dbi->select(table  => 'book',
2052
    column => ['title', 'author'], where  => {author => 'Ken'});
2053

            
2054
  # Select, more complex
2055
  my $result = $dbi->select(
2056
    table  => 'book',
2057
    column => [
2058
      {book => [qw/title author/]},
2059
      {company => ['name']}
2060
    ],
2061
    where  => {'book.author' => 'Ken'},
2062
    join => ['left outer join company on book.company_id = company.id'],
2063
    append => 'order by id limit 5'
2064
  );
2065
  
2066
  # Fetch
2067
  while (my $row = $result->fetch) {
2068
      
2069
  }
2070
  
2071
  # Fetch as hash
2072
  while (my $row = $result->fetch_hash) {
2073
      
2074
  }
2075
  
2076
  # Execute SQL with parameter.
2077
  $dbi->execute(
2078
    "select id from book where author = :author and title like :title",
2079
    {author => 'ken', title => '%Perl%'}
2080
  );
2081
  
fix heading typos
Terrence Brannon authored on 2011-08-17
2082
=head1 DESCRIPTION
removed reconnect method
yuki-kimoto authored on 2010-05-28
2083

            
cleanup
Yuki Kimoto authored on 2011-07-29
2084
L<DBIx::Custom> is L<DBI> wrapper module to execute SQL easily.
updated pod
Yuki Kimoto authored on 2011-06-21
2085
This module have the following features.
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2086

            
updated pod
Yuki Kimoto authored on 2011-06-21
2087
=over 4
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2088

            
cleanup
Yuki Kimoto authored on 2011-07-29
2089
=item *
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2090

            
cleanup
Yuki Kimoto authored on 2011-07-29
2091
Execute C<insert>, C<update>, C<delete>, or C<select> statement easily
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2092

            
cleanup
Yuki Kimoto authored on 2011-07-29
2093
=item *
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2094

            
cleanup
Yuki Kimoto authored on 2011-07-29
2095
Create C<where> clause flexibly
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2096

            
cleanup
Yuki Kimoto authored on 2011-07-29
2097
=item *
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2098

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2099
Named place holder support
2100

            
2101
=item *
2102

            
cleanup
Yuki Kimoto authored on 2011-07-29
2103
Model support
2104

            
2105
=item *
2106

            
2107
Connection manager support
2108

            
2109
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2110

            
cleanup
Yuki Kimoto authored on 2011-07-30
2111
Choice your favorite relational database management system,
cleanup
Yuki Kimoto authored on 2011-07-29
2112
C<MySQL>, C<SQLite>, C<PostgreSQL>, C<Oracle>,
2113
C<Microsoft SQL Server>, C<Microsoft Access>, C<DB2> or anything, 
2114

            
2115
=item *
2116

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2117
Filtering by data type or column name
cleanup
Yuki Kimoto authored on 2011-07-29
2118

            
2119
=item *
2120

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2121
Create C<order by> clause flexibly
cleanup
Yuki Kimoto authored on 2011-07-29
2122

            
2123
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2124

            
fix heading typos
Terrence Brannon authored on 2011-08-17
2125
=head1 DOCUMENTATION
pod fix
Yuki Kimoto authored on 2011-01-21
2126

            
cleanup
Yuki Kimoto authored on 2011-07-29
2127
L<DBIx::Custom::Guide> - How to use L<DBIx::Custom>
pod fix
Yuki Kimoto authored on 2011-01-21
2128

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2129
L<DBIx::Custom Wiki|https://github.com/yuki-kimoto/DBIx-Custom/wiki>
cleanup
Yuki Kimoto authored on 2011-07-29
2130
- Theare are various examples.
2131

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2132
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2133
L<DBIx::Custom::Result>,
2134
L<DBIx::Custom::Query>,
2135
L<DBIx::Custom::Where>,
2136
L<DBIx::Custom::Model>,
2137
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2138

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

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2141
=head2 C<connector>
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2142

            
cleanup
Yuki Kimoto authored on 2012-01-20
2143
  my $connector = $dbi->connector;
2144
  $dbi = $dbi->connector($connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2145

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2146
Connection manager object. if C<connector> is set, you can get C<dbh>
2147
through connection manager. Conection manager object must have C<dbh> mehtod.
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2148

            
2149
This is L<DBIx::Connector> example. Please pass
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2150
C<default_option> to L<DBIx::Connector> C<new> method.
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2151

            
cleanup
Yuki Kimoto authored on 2012-01-20
2152
  my $connector = DBIx::Connector->new(
2153
    "dbi:mysql:database=$database",
2154
    $user,
2155
    $password,
2156
    DBIx::Custom->new->default_option
2157
  );
2158
  
2159
  my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2160

            
cleanup
Yuki Kimoto authored on 2011-08-16
2161
If C<connector> is set to 1 when connect method is called,
2162
L<DBIx::Connector> is automatically set to C<connector>
2163

            
cleanup
Yuki Kimoto authored on 2012-01-20
2164
  my $dbi = DBIx::Custom->connect(
2165
    dsn => $dsn, user => $user, password => $password, connector => 1);
2166
  
2167
  my $connector = $dbi->connector; # DBIx::Connector
cleanup
Yuki Kimoto authored on 2011-08-16
2168

            
2169
Note that L<DBIx::Connector> must be installed.
2170

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2171
=head2 C<dsn>
2172

            
cleanup
Yuki Kimoto authored on 2012-01-20
2173
  my $dsn = $dbi->dsn;
2174
  $dbi = $dbi->dsn("DBI:mysql:database=dbname");
packaging one directory
yuki-kimoto authored on 2009-11-16
2175

            
updated pod
Yuki Kimoto authored on 2011-06-21
2176
Data source name, used when C<connect> method is executed.
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
2177

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2178
=head2 C<default_option>
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
2179

            
cleanup
Yuki Kimoto authored on 2012-01-20
2180
  my $default_option = $dbi->default_option;
2181
  $dbi = $dbi->default_option($default_option);
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
2182

            
updated pod
Yuki Kimoto authored on 2011-06-21
2183
L<DBI> default option, used when C<connect> method is executed,
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2184
default to the following values.
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
2185

            
cleanup
Yuki Kimoto authored on 2012-01-20
2186
  {
2187
    RaiseError => 1,
2188
    PrintError => 0,
2189
    AutoCommit => 1,
2190
  }
packaging one directory
yuki-kimoto authored on 2009-11-16
2191

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2192
=head2 C<exclude_table>
2193

            
cleanup
Yuki Kimoto authored on 2012-01-20
2194
  my $exclude_table = $dbi->exclude_table;
2195
  $dbi = $dbi->exclude_table(qr/pg_/);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2196

            
2197
Excluded table regex.
2198
C<each_column>, C<each_table>, C<type_rule>,
2199
and C<setup_model> methods ignore matching tables.
2200

            
cleanup
yuki-kimoto authored on 2010-10-17
2201
=head2 C<filters>
bind_filter argument is chan...
yuki-kimoto authored on 2009-11-19
2202

            
cleanup
Yuki Kimoto authored on 2012-01-20
2203
  my $filters = $dbi->filters;
2204
  $dbi = $dbi->filters(\%filters);
packaging one directory
yuki-kimoto authored on 2009-11-16
2205

            
updated pod
Yuki Kimoto authored on 2011-06-21
2206
Filters, registered by C<register_filter> method.
add models() attribute
Yuki Kimoto authored on 2011-02-21
2207

            
- removed EXPERIMENTAL statu...
Yuki Kimoto authored on 2011-07-26
2208
=head2 C<last_sql>
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
2209

            
cleanup
Yuki Kimoto authored on 2012-01-20
2210
  my $last_sql = $dbi->last_sql;
2211
  $dbi = $dbi->last_sql($last_sql);
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
2212

            
2213
Get last successed SQL executed by C<execute> method.
2214

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2215
=head2 C<now>
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2216

            
cleanup
Yuki Kimoto authored on 2012-01-20
2217
  my $now = $dbi->now;
2218
  $dbi = $dbi->now($now);
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2219

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2220
Code reference which return current time, default to the following code reference.
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2221

            
cleanup
Yuki Kimoto authored on 2012-01-20
2222
  sub {
2223
    my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2224
    $mon++;
2225
    $year += 1900;
2226
    return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2227
  }
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2228

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2229
This return the time like C<2011-10-14 05:05:27>.
2230

            
2231
This is used by C<insert> method's C<created_at> option and C<updated_at> option,
2232
and C<update> method's C<updated_at> option.
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2233

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2234
=head2 C<models>
add models() attribute
Yuki Kimoto authored on 2011-02-21
2235

            
cleanup
Yuki Kimoto authored on 2012-01-20
2236
  my $models = $dbi->models;
2237
  $dbi = $dbi->models(\%models);
add models() attribute
Yuki Kimoto authored on 2011-02-21
2238

            
updated pod
Yuki Kimoto authored on 2011-06-21
2239
Models, included by C<include_model> method.
add models() attribute
Yuki Kimoto authored on 2011-02-21
2240

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2241
=head2 C<option>
2242

            
cleanup
Yuki Kimoto authored on 2012-01-20
2243
  my $option = $dbi->option;
2244
  $dbi = $dbi->option($option);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2245

            
2246
L<DBI> option, used when C<connect> method is executed.
2247
Each value in option override the value of C<default_option>.
2248

            
cleanup
yuki-kimoto authored on 2010-10-17
2249
=head2 C<password>
2250

            
cleanup
Yuki Kimoto authored on 2012-01-20
2251
  my $password = $dbi->password;
2252
  $dbi = $dbi->password('lkj&le`@s');
cleanup
yuki-kimoto authored on 2010-10-17
2253

            
updated pod
Yuki Kimoto authored on 2011-06-21
2254
Password, used when C<connect> method is executed.
update document
yuki-kimoto authored on 2010-01-30
2255

            
renamed update tag to update...
yuki-kimoto authored on 2010-08-09
2256
=head2 C<query_builder>
added commit method
yuki-kimoto authored on 2010-05-27
2257

            
cleanup
Yuki Kimoto authored on 2012-01-20
2258
  my $builder = $dbi->query_builder;
added commit method
yuki-kimoto authored on 2010-05-27
2259

            
test cleanup
Yuki Kimoto authored on 2011-08-10
2260
Creat query builder. This is L<DBIx::Custom::QueryBuilder>.
cleanup
yuki-kimoto authored on 2010-08-05
2261

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2262
=head2 C<quote>
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
2263

            
cleanup
Yuki Kimoto authored on 2012-01-20
2264
  my quote = $dbi->quote;
2265
  $dbi = $dbi->quote('"');
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
2266

            
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
2267
Reserved word quote.
2268
Default to double quote '"' except for mysql.
2269
In mysql, default to back quote '`'
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
2270

            
cleanup
Yuki Kimoto authored on 2011-07-30
2271
You can set quote pair.
2272

            
cleanup
Yuki Kimoto authored on 2012-01-20
2273
  $dbi->quote('[]');
cleanup
Yuki Kimoto authored on 2011-07-30
2274

            
cleanup
yuki-kimoto authored on 2010-10-17
2275
=head2 C<result_class>
cleanup
yuki-kimoto authored on 2010-08-05
2276

            
cleanup
Yuki Kimoto authored on 2012-01-20
2277
  my $result_class = $dbi->result_class;
2278
  $dbi = $dbi->result_class('DBIx::Custom::Result');
cleanup
yuki-kimoto authored on 2010-08-05
2279

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2280
Result class, default to L<DBIx::Custom::Result>.
cleanup
yuki-kimoto authored on 2010-08-05
2281

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2282
=head2 C<safety_character>
update pod
Yuki Kimoto authored on 2011-01-27
2283

            
cleanup
Yuki Kimoto authored on 2012-01-20
2284
  my $safety_character = $dbi->safety_character;
2285
  $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2286

            
update pod
Yuki Kimoto authored on 2011-03-13
2287
Regex of safety character for table and column name, default to '\w'.
cleanup
Yuki Kimoto authored on 2011-03-10
2288
Note that you don't have to specify like '[\w]'.
update pod
Yuki Kimoto authored on 2011-01-27
2289

            
cleanup test
Yuki Kimoto authored on 2011-08-10
2290
=head2 C<separator>
2291

            
cleanup
Yuki Kimoto authored on 2012-01-20
2292
  my $separator = $dbi->separator;
2293
  $dbi = $dbi->separator('-');
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
2294

            
2295
Separator which join table name and column name.
2296
This have effect to C<column> and C<mycolumn> method,
2297
and C<select> method's column option.
cleanup test
Yuki Kimoto authored on 2011-08-10
2298

            
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
2299
Default to C<.>.
cleanup test
Yuki Kimoto authored on 2011-08-10
2300

            
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
2301
=head2 C<tag_parse>
2302

            
cleanup
Yuki Kimoto authored on 2012-01-20
2303
  my $tag_parse = $dbi->tag_parse(0);
2304
  $dbi = $dbi->tag_parse;
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
2305

            
2306
Enable DEPRECATED tag parsing functionality, default to 1.
2307
If you want to disable tag parsing functionality, set to 0.
2308

            
cleanup
yuki-kimoto authored on 2010-10-17
2309
=head2 C<user>
cleanup
yuki-kimoto authored on 2010-08-05
2310

            
cleanup
Yuki Kimoto authored on 2012-01-20
2311
  my $user = $dbi->user;
2312
  $dbi = $dbi->user('Ken');
cleanup
yuki-kimoto authored on 2010-08-05
2313

            
updated pod
Yuki Kimoto authored on 2011-06-21
2314
User name, used when C<connect> method is executed.
update pod
Yuki Kimoto authored on 2011-01-27
2315

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2316
=head2 C<user_column_info>
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2317

            
cleanup
Yuki Kimoto authored on 2012-01-20
2318
  my $user_column_info = $dbi->user_column_info;
2319
  $dbi = $dbi->user_column_info($user_column_info);
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2320

            
improved join clause parsing
Yuki Kimoto authored on 2011-09-30
2321
You can set the date like the following one.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2322

            
cleanup
Yuki Kimoto authored on 2012-01-20
2323
  [
2324
    {table => 'book', column => 'title', info => {...}},
2325
    {table => 'author', column => 'name', info => {...}}
2326
  ]
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2327

            
improved join clause parsing
Yuki Kimoto authored on 2011-09-30
2328
Usually, you set return value of C<get_column_info>.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2329

            
cleanup
Yuki Kimoto authored on 2012-01-20
2330
  my $user_column_info
2331
    = $dbi->get_column_info(exclude_table => qr/^system/);
2332
  $dbi->user_column_info($user_column_info);
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2333

            
2334
If C<user_column_info> is set, C<each_column> use C<user_column_info>
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2335
to find column info. this is very fast.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2336

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2337
=head2 C<user_table_info>
added test
Yuki Kimoto authored on 2011-08-16
2338

            
cleanup
Yuki Kimoto authored on 2012-01-20
2339
  my $user_table_info = $dbi->user_table_info;
2340
  $dbi = $dbi->user_table_info($user_table_info);
added test
Yuki Kimoto authored on 2011-08-16
2341

            
2342
You can set the following data.
2343

            
cleanup
Yuki Kimoto authored on 2012-01-20
2344
  [
2345
    {table => 'book', info => {...}},
2346
    {table => 'author', info => {...}}
2347
  ]
added test
Yuki Kimoto authored on 2011-08-16
2348

            
2349
Usually, you can set return value of C<get_table_info>.
2350

            
cleanup
Yuki Kimoto authored on 2012-01-20
2351
  my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2352
  $dbi->user_table_info($user_table_info);
added test
Yuki Kimoto authored on 2011-08-16
2353

            
2354
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2355
to find table info.
2356

            
cleanup
yuki-kimoto authored on 2010-10-17
2357
=head1 METHODS
added commit method
yuki-kimoto authored on 2010-05-27
2358

            
cleanup
yuki-kimoto authored on 2010-10-17
2359
L<DBIx::Custom> inherits all methods from L<Object::Simple>
cleanup
Yuki Kimoto authored on 2011-03-10
2360
and use all methods of L<DBI>
cleanup
yuki-kimoto authored on 2010-10-17
2361
and implements the following new ones.
added check_filter attribute
yuki-kimoto authored on 2010-08-08
2362

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2363
=head2 C<available_datatype>
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2364

            
cleanup
Yuki Kimoto authored on 2012-01-20
2365
  print $dbi->available_datatype;
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2366

            
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2367
Get available data types. You can use these data types
updated pod
Yuki Kimoto authored on 2011-06-21
2368
in C<type rule>'s C<from1> and C<from2> section.
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2369

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2370
=head2 C<available_typename>
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2371

            
cleanup
Yuki Kimoto authored on 2012-01-20
2372
  print $dbi->available_typename;
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2373

            
2374
Get available type names. You can use these type names in
updated pod
Yuki Kimoto authored on 2011-06-21
2375
C<type_rule>'s C<into1> and C<into2> section.
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2376

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2377
=head2 C<assign_clause>
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2378

            
cleanup
Yuki Kimoto authored on 2012-01-20
2379
  my $assign_clause = $dbi->assign_clause({title => 'a', age => 2});
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2380

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2381
Create assign clause
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2382

            
cleanup
Yuki Kimoto authored on 2012-01-20
2383
  title = :title, author = :author
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2384

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2385
This is used to create update clause.
2386

            
cleanup
Yuki Kimoto authored on 2012-01-20
2387
  "update book set " . $dbi->assign_clause({title => 'a', age => 2});
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2388

            
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2389
=head2 C<column>
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2390

            
cleanup
Yuki Kimoto authored on 2012-01-20
2391
  my $column = $dbi->column(book => ['author', 'title']);
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2392

            
2393
Create column clause. The follwoing column clause is created.
2394

            
cleanup
Yuki Kimoto authored on 2012-01-20
2395
  book.author as "book.author",
2396
  book.title as "book.title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2397

            
cleanup test
Yuki Kimoto authored on 2011-08-10
2398
You can change separator by C<separator> attribute.
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2399

            
cleanup
Yuki Kimoto authored on 2012-01-20
2400
  # Separator is hyphen
2401
  $dbi->separator('-');
2402
  
2403
  book.author as "book-author",
2404
  book.title as "book-title"
2405
  
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2406
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2407

            
cleanup
Yuki Kimoto authored on 2012-01-20
2408
  my $dbi = DBIx::Custom->connect(
2409
    dsn => "dbi:mysql:database=dbname",
2410
    user => 'ken',
2411
    password => '!LFKD%$&',
2412
    option => {mysql_enable_utf8 => 1}
2413
  );
update pod
Yuki Kimoto authored on 2011-03-13
2414

            
2415
Connect to the database and create a new L<DBIx::Custom> object.
bind_filter argument is chan...
yuki-kimoto authored on 2009-11-19
2416

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
2417
L<DBIx::Custom> is a wrapper of L<DBI>.
cleanup
yuki-kimoto authored on 2010-08-09
2418
C<AutoCommit> and C<RaiseError> options are true, 
update pod
Yuki Kimoto authored on 2011-03-13
2419
and C<PrintError> option is false by default.
packaging one directory
yuki-kimoto authored on 2009-11-16
2420

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2421
=head2 C<count>
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
2422

            
cleanup
Yuki Kimoto authored on 2012-01-20
2423
  my $count = $dbi->count(table => 'book');
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
2424

            
2425
Get rows count.
2426

            
2427
Options is same as C<select> method's ones.
2428

            
2429
=head2 C<create_model>
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2430

            
cleanup
Yuki Kimoto authored on 2012-01-20
2431
  my $model = $dbi->create_model(
2432
    table => 'book',
2433
    primary_key => 'id',
2434
    join => [
2435
      'inner join company on book.comparny_id = company.id'
2436
    ],
2437
  );
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2438

            
2439
Create L<DBIx::Custom::Model> object and initialize model.
updated pod
Yuki Kimoto authored on 2011-06-21
2440
the module is also used from C<model> method.
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2441

            
cleanup
Yuki Kimoto authored on 2012-01-20
2442
 $dbi->model('book')->select(...);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2443

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2444
=head2 C<dbh>
2445

            
cleanup
Yuki Kimoto authored on 2012-01-20
2446
  my $dbh = $dbi->dbh;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2447

            
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2448
Get L<DBI> database handle. if C<connector> is set, you can get
updated pod
Yuki Kimoto authored on 2011-06-21
2449
database handle through C<connector> object.
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2450

            
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2451
=head2 C<delete>
2452

            
cleanup
Yuki Kimoto authored on 2012-01-20
2453
  $dbi->delete(table => 'book', where => {title => 'Perl'});
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2454

            
2455
Execute delete statement.
2456

            
2457
The following opitons are available.
2458

            
cleanup
Yuki Kimoto authored on 2011-10-20
2459
B<OPTIONS>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2460

            
cleanup
Yuki Kimoto authored on 2011-10-20
2461
C<delete> method use all of C<execute> method's options,
2462
and use the following new ones.
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2463

            
cleanup
Yuki Kimoto authored on 2011-10-20
2464
=over 4
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2465

            
2466
=item C<id>
2467

            
cleanup
Yuki Kimoto authored on 2012-01-20
2468
  id => 4
2469
  id => [4, 5]
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2470

            
2471
ID corresponding to C<primary_key>.
2472
You can delete rows by C<id> and C<primary_key>.
2473

            
cleanup
Yuki Kimoto authored on 2012-01-20
2474
  $dbi->delete(
2475
    primary_key => ['id1', 'id2'],
2476
    id => [4, 5],
2477
    table => 'book',
2478
  );
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2479

            
2480
The above is same as the followin one.
2481

            
cleanup
Yuki Kimoto authored on 2012-01-20
2482
  $dbi->delete(where => {id1 => 4, id2 => 5}, table => 'book');
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2483

            
2484
=item C<prefix>
2485

            
cleanup
Yuki Kimoto authored on 2012-01-20
2486
  prefix => 'some'
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2487

            
2488
prefix before table name section.
2489

            
cleanup
Yuki Kimoto authored on 2012-01-20
2490
  delete some from book
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2491

            
2492
=item C<table>
2493

            
cleanup
Yuki Kimoto authored on 2012-01-20
2494
  table => 'book'
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2495

            
2496
Table name.
2497

            
2498
=item C<where>
2499

            
2500
Same as C<select> method's C<where> option.
2501

            
2502
=back
2503

            
2504
=head2 C<delete_all>
2505

            
cleanup
Yuki Kimoto authored on 2012-01-20
2506
  $dbi->delete_all(table => $table);
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2507

            
2508
Execute delete statement for all rows.
2509
Options is same as C<delete>.
2510

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2511
=head2 C<each_column>
2512

            
cleanup
Yuki Kimoto authored on 2012-01-20
2513
  $dbi->each_column(
2514
    sub {
2515
      my ($dbi, $table, $column, $column_info) = @_;
2516
      
2517
      my $type = $column_info->{TYPE_NAME};
2518
      
2519
      if ($type eq 'DATE') {
2520
          # ...
2521
      }
2522
    }
2523
  );
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2524

            
improved pod
Yuki Kimoto authored on 2011-10-14
2525
Iterate all column informations in database.
2526
Argument is callback which is executed when one column is found.
2527
Callback receive four arguments. C<DBIx::Custom object>, C<table name>,
2528
C<column name>, and C<column information>.
2529

            
2530
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2531
infromation, you can improve the performance of C<each_column> in
2532
the following way.
2533

            
cleanup
Yuki Kimoto authored on 2012-01-20
2534
  my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
2535
  $dbi->user_column_info($column_info);
2536
  $dbi->each_column(sub { ... });
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2537

            
- removed EXPERIMENTAL statu...
Yuki Kimoto authored on 2011-07-26
2538
=head2 C<each_table>
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
2539

            
cleanup
Yuki Kimoto authored on 2012-01-20
2540
  $dbi->each_table(
2541
    sub {
2542
      my ($dbi, $table, $table_info) = @_;
2543
      
2544
      my $table_name = $table_info->{TABLE_NAME};
2545
    }
2546
  );
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
2547

            
improved pod
Yuki Kimoto authored on 2011-10-14
2548
Iterate all table informationsfrom in database.
2549
Argument is callback which is executed when one table is found.
2550
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2551
C<table information>.
2552

            
2553
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2554
infromation, you can improve the performance of C<each_table> in
2555
the following way.
2556

            
cleanup
Yuki Kimoto authored on 2012-01-20
2557
  my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
2558
  $dbi->user_table_info($table_info);
2559
  $dbi->each_table(sub { ... });
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
2560

            
cleanup
yuki-kimoto authored on 2010-10-17
2561
=head2 C<execute>
packaging one directory
yuki-kimoto authored on 2009-11-16
2562

            
cleanup
Yuki Kimoto authored on 2012-01-20
2563
  my $result = $dbi->execute(
2564
    "select * from book where title = :title and author like :author",
2565
    {title => 'Perl', author => '%Ken%'}
2566
  );
updated pod
Yuki Kimoto authored on 2011-06-21
2567

            
cleanup
Yuki Kimoto authored on 2012-01-20
2568
  my $result = $dbi->execute(
2569
    "select * from book where title = :book.title and author like :book.author",
2570
    {'book.title' => 'Perl', 'book.author' => '%Ken%'}
2571
  );
update pod
Yuki Kimoto authored on 2011-03-13
2572

            
updated pod
Yuki Kimoto authored on 2011-06-21
2573
Execute SQL. SQL can contain column parameter such as :author and :title.
2574
You can append table name to column name such as :book.title and :book.author.
2575
Second argunet is data, embedded into column parameter.
2576
Return value is L<DBIx::Custom::Result> object when select statement is executed,
2577
or the count of affected rows when insert, update, delete statement is executed.
update pod
Yuki Kimoto authored on 2011-03-13
2578

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2579
Named placeholder such as C<:title> is replaced by placeholder C<?>.
cleanup
Yuki Kimoto authored on 2012-01-20
2580
  
2581
  # Original
2582
  select * from book where title = :title and author like :author
2583
  
2584
  # Replaced
2585
  select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2586

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2587
You can specify operator with named placeholder
fixed pod
Yuki Kimoto authored on 2011-10-20
2588
by C<name{operator}> syntax.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2589

            
cleanup
Yuki Kimoto authored on 2012-01-20
2590
  # Original
2591
  select * from book where :title{=} and :author{like}
2592
  
2593
  # Replaced
2594
  select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2595

            
fixed named placeholder bug ...
Yuki Kimoto authored on 2011-08-01
2596
Note that colons in time format such as 12:13:15 is exeption,
2597
it is not parsed as named placeholder.
2598
If you want to use colon generally, you must escape it by C<\\>
2599

            
cleanup
Yuki Kimoto authored on 2012-01-20
2600
  select * from where title = "aa\\:bb";
fixed named placeholder bug ...
Yuki Kimoto authored on 2011-08-01
2601

            
cleanup
Yuki Kimoto authored on 2011-10-20
2602
B<OPTIONS>
2603

            
updated pod
Yuki Kimoto authored on 2011-06-09
2604
The following opitons are available.
update pod
Yuki Kimoto authored on 2011-03-13
2605

            
2606
=over 4
2607

            
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2608
=item C<after_build_sql> 
2609

            
2610
You can filter sql after the sql is build.
2611

            
cleanup
Yuki Kimoto authored on 2012-01-20
2612
  after_build_sql => $code_ref
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2613

            
2614
The following one is one example.
2615

            
cleanup
Yuki Kimoto authored on 2012-01-20
2616
  $dbi->select(
2617
    table => 'book',
2618
    column => 'distinct(name)',
2619
    after_build_sql => sub {
2620
      "select count(*) from ($_[0]) as t1"
2621
    }
2622
  );
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2623

            
2624
The following SQL is executed.
2625

            
cleanup
Yuki Kimoto authored on 2012-01-20
2626
  select count(*) from (select distinct(name) from book) as t1;
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2627

            
cleanup
Yuki Kimoto authored on 2011-10-20
2628
=item C<append>
2629

            
cleanup
Yuki Kimoto authored on 2012-01-20
2630
  append => 'order by name'
cleanup
Yuki Kimoto authored on 2011-10-20
2631

            
2632
Append some statement after SQL.
2633

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2634
=item C<bind_type>
2635

            
2636
Specify database bind data type.
2637

            
cleanup
Yuki Kimoto authored on 2012-01-20
2638
  bind_type => [image => DBI::SQL_BLOB]
2639
  bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2640

            
2641
This is used to bind parameter by C<bind_param> of statment handle.
2642

            
cleanup
Yuki Kimoto authored on 2012-01-20
2643
  $sth->bind_param($pos, $value, DBI::SQL_BLOB);
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2644

            
update pod
Yuki Kimoto authored on 2011-03-13
2645
=item C<filter>
cleanup
Yuki Kimoto authored on 2012-01-20
2646
  
2647
  filter => {
2648
    title  => sub { uc $_[0] }
2649
    author => sub { uc $_[0] }
2650
  }
2651

            
2652
  # Filter name
2653
  filter => {
2654
    title  => 'upper_case',
2655
    author => 'upper_case'
2656
  }
2657
      
2658
  # At once
2659
  filter => [
2660
    [qw/title author/]  => sub { uc $_[0] }
2661
  ]
updated pod
Yuki Kimoto authored on 2011-06-09
2662

            
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2663
Filter. You can set subroutine or filter name
updated pod
Yuki Kimoto authored on 2011-06-21
2664
registered by by C<register_filter>.
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2665
This filter is executed before data is saved into database.
2666
and before type rule filter is executed.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2667

            
updated document
Yuki Kimoto authored on 2011-06-09
2668
=item C<query>
2669

            
cleanup
Yuki Kimoto authored on 2012-01-20
2670
  query => 1
updated document
Yuki Kimoto authored on 2011-06-09
2671

            
DBIx::Custom::Query is DEPRE...
Yuki Kimoto authored on 2011-11-15
2672
C<execute> method return hash reference which contain SQL and column
2673
infromation
updated pod
Yuki Kimoto authored on 2011-06-21
2674

            
cleanup
Yuki Kimoto authored on 2012-01-20
2675
  my $sql = $query->{sql};
2676
  my $columns = $query->{columns};
2677
  
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
2678
=item C<reuse>
cleanup
Yuki Kimoto authored on 2012-01-20
2679
  
2680
  reuse => $hash_ref
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
2681

            
2682
Reuse query object if the hash reference variable is set.
cleanup
Yuki Kimoto authored on 2012-01-20
2683
  
2684
  my $queries = {};
2685
  $dbi->execute($sql, $param, reuse => $queries);
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
2686

            
2687
This will improved performance when you want to execute same query repeatedly
2688
because generally creating query object is slow.
2689

            
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2690
=item C<primary_key>
2691

            
cleanup
Yuki Kimoto authored on 2012-01-20
2692
  primary_key => 'id'
2693
  primary_key => ['id1', 'id2']
cleanup
Yuki Kimoto authored on 2011-10-20
2694

            
execute method id option is ...
Yuki Kimoto authored on 2011-10-27
2695
Priamry key. This is used for C<id> option.
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2696

            
updated pod
Yuki Kimoto authored on 2011-06-09
2697
=item C<table>
cleanup
Yuki Kimoto authored on 2012-01-20
2698
  
2699
  table => 'author'
updated pod
Yuki Kimoto authored on 2011-06-09
2700

            
updated pod
Yuki Kimoto authored on 2011-06-21
2701
If you want to omit table name in column name
2702
and enable C<into1> and C<into2> type filter,
2703
You must set C<table> option.
updated pod
Yuki Kimoto authored on 2011-06-09
2704

            
cleanup
Yuki Kimoto authored on 2012-01-20
2705
  $dbi->execute("select * from book where title = :title and author = :author",
2706
    {title => 'Perl', author => 'Ken', table => 'book');
updated pod
Yuki Kimoto authored on 2011-06-09
2707

            
cleanup
Yuki Kimoto authored on 2012-01-20
2708
  # Same
2709
  $dbi->execute(
2710
    "select * from book where title = :book.title and author = :book.author",
2711
    {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2712

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2713
=item C<table_alias>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
2714

            
cleanup
Yuki Kimoto authored on 2012-01-20
2715
  table_alias => {user => 'worker'}
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
2716

            
2717
Table alias. Key is real table name, value is alias table name.
2718
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2719
on alias table name.
2720

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2721
=item C<type_rule_off>
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2722

            
cleanup
Yuki Kimoto authored on 2012-01-20
2723
  type_rule_off => 1
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2724

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2725
Turn C<into1> and C<into2> type rule off.
2726

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2727
=item C<type_rule1_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2728

            
cleanup
Yuki Kimoto authored on 2012-01-20
2729
  type_rule1_off => 1
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2730

            
2731
Turn C<into1> type rule off.
2732

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2733
=item C<type_rule2_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2734

            
cleanup
Yuki Kimoto authored on 2012-01-20
2735
  type_rule2_off => 1
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2736

            
2737
Turn C<into2> type rule off.
update document
yuki-kimoto authored on 2009-11-19
2738

            
update pod
Yuki Kimoto authored on 2011-03-13
2739
=back
version 0.0901
yuki-kimoto authored on 2009-12-17
2740

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2741
=head2 C<get_column_info>
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2742

            
cleanup
Yuki Kimoto authored on 2012-01-20
2743
  my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2744

            
2745
get column infomation except for one which match C<exclude_table> pattern.
2746

            
cleanup
Yuki Kimoto authored on 2012-01-20
2747
  [
2748
    {table => 'book', column => 'title', info => {...}},
2749
    {table => 'author', column => 'name' info => {...}}
2750
  ]
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2751

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2752
=head2 C<get_table_info>
added test
Yuki Kimoto authored on 2011-08-16
2753

            
cleanup
Yuki Kimoto authored on 2012-01-20
2754
  my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
update pod
Yuki Kimoto authored on 2011-03-13
2755

            
added test
Yuki Kimoto authored on 2011-08-16
2756
get table infomation except for one which match C<exclude> pattern.
2757

            
cleanup
Yuki Kimoto authored on 2012-01-20
2758
  [
2759
    {table => 'book', info => {...}},
2760
    {table => 'author', info => {...}}
2761
  ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2762

            
added test
Yuki Kimoto authored on 2011-08-16
2763
You can set this value to C<user_table_info>.
update pod
Yuki Kimoto authored on 2011-03-13
2764

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2765
=head2 C<helper>
2766

            
cleanup
Yuki Kimoto authored on 2012-01-20
2767
  $dbi->helper(
2768
    find_or_create   => sub {
2769
      my $self = shift;
2770
      
2771
      # Process
2772
    },
2773
    ...
2774
  );
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2775

            
2776
Register helper. These helper is called directly from L<DBIx::Custom> object.
2777

            
cleanup
Yuki Kimoto authored on 2012-01-20
2778
  $dbi->find_or_create;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2779

            
cleanup
yuki-kimoto authored on 2010-10-17
2780
=head2 C<insert>
2781

            
cleanup
Yuki Kimoto authored on 2012-01-20
2782
  $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
update pod
Yuki Kimoto authored on 2011-03-13
2783

            
updated pod
Yuki Kimoto authored on 2011-06-21
2784
Execute insert statement. First argument is row data. Return value is
2785
affected row count.
update pod
Yuki Kimoto authored on 2011-03-13
2786

            
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
2787
If you want to set constant value to row data, use scalar reference
2788
as parameter value.
2789

            
cleanup
Yuki Kimoto authored on 2012-01-20
2790
  {date => \"NOW()"}
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
2791

            
updated pod
Yuki Kimoto authored on 2011-11-25
2792
You can pass multiple parameters, this is very fast.
2793
This is EXPERIMETNAL.
2794

            
cleanup
Yuki Kimoto authored on 2012-01-20
2795
  $dbi->insert(
2796
    [
2797
      {title => 'Perl', author => 'Ken'},
2798
      {title => 'Ruby', author => 'Tom'}
2799
    ],
2800
    table  => 'book'
2801
  );
updated pod
Yuki Kimoto authored on 2011-11-25
2802

            
2803
In multiple insert, you can't use C<id> option.
2804
and only first parameter is used by creating sql.
2805

            
cleanup
Yuki Kimoto authored on 2011-10-20
2806
B<options>
2807

            
cleanup
Yuki Kimoto authored on 2011-10-20
2808
C<insert> method use all of C<execute> method's options,
cleanup
Yuki Kimoto authored on 2011-10-20
2809
and use the following new ones.
update pod
Yuki Kimoto authored on 2011-03-13
2810

            
cleanup
Yuki Kimoto authored on 2011-06-09
2811
=over 4
improved bulk_insert perform...
Yuki Kimoto authored on 2011-11-29
2812
b
added EXPERIMENTAL bulk_inse...
Yuki Kimoto authored on 2011-11-27
2813
=item C<bulk_insert> EXPERIMENTAL
2814

            
cleanup
Yuki Kimoto authored on 2012-01-20
2815
  bulk_insert => 1
added EXPERIMENTAL bulk_inse...
Yuki Kimoto authored on 2011-11-27
2816

            
2817
bulk insert is executed if database support bulk insert and 
2818
multiple parameters is passed to C<insert>.
2819
The SQL like the following one is executed.
2820

            
cleanup
Yuki Kimoto authored on 2012-01-20
2821
  insert into book (id, title) values (?, ?), (?, ?);
added EXPERIMENTAL bulk_inse...
Yuki Kimoto authored on 2011-11-27
2822

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2823
=item C<created_at>
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2824

            
cleanup
Yuki Kimoto authored on 2012-01-20
2825
  created_at => 'created_datetime'
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2826

            
2827
Created timestamp column name. time when row is created is set to the column.
2828
default time format is "YYYY-mm-dd HH:MM:SS", which can be changed by
2829
C<now> attribute.
2830

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2831
=item C<id>
2832

            
cleanup
Yuki Kimoto authored on 2012-01-20
2833
  id => 4
2834
  id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2835

            
updated document
Yuki Kimoto authored on 2011-06-09
2836
ID corresponding to C<primary_key>.
2837
You can insert a row by C<id> and C<primary_key>.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2838

            
cleanup
Yuki Kimoto authored on 2012-01-20
2839
  $dbi->insert(
2840
    {title => 'Perl', author => 'Ken'}
2841
    primary_key => ['id1', 'id2'],
2842
    id => [4, 5],
2843
    table => 'book'
2844
  );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2845

            
updated document
Yuki Kimoto authored on 2011-06-09
2846
The above is same as the followin one.
update pod
Yuki Kimoto authored on 2011-03-13
2847

            
cleanup
Yuki Kimoto authored on 2012-01-20
2848
  $dbi->insert(
2849
    {id1 => 4, id2 => 5, title => 'Perl', author => 'Ken'},
2850
    table => 'book'
2851
  );
update pod
Yuki Kimoto authored on 2011-03-13
2852

            
- removed EXPERIMENTAL statu...
Yuki Kimoto authored on 2011-07-26
2853
=item C<prefix>
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
2854

            
cleanup
Yuki Kimoto authored on 2012-01-20
2855
  prefix => 'or replace'
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
2856

            
2857
prefix before table name section
2858

            
cleanup
Yuki Kimoto authored on 2012-01-20
2859
  insert or replace into book
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
2860

            
updated document
Yuki Kimoto authored on 2011-06-09
2861
=item C<table>
2862

            
cleanup
Yuki Kimoto authored on 2012-01-20
2863
  table => 'book'
updated document
Yuki Kimoto authored on 2011-06-09
2864

            
2865
Table name.
2866

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2867
=item C<updated_at>
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2868

            
2869
This option is same as C<update> method C<updated_at> option.
2870

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2871
=item C<wrap>
updated pod
Yuki Kimoto authored on 2011-09-02
2872

            
cleanup
Yuki Kimoto authored on 2012-01-20
2873
  wrap => {price => sub { "max($_[0])" }}
updated pod
Yuki Kimoto authored on 2011-09-02
2874

            
2875
placeholder wrapped string.
2876

            
2877
If the following statement
2878

            
cleanup
Yuki Kimoto authored on 2012-01-20
2879
  $dbi->insert({price => 100}, table => 'book',
2880
    {price => sub { "$_[0] + 5" }});
updated pod
Yuki Kimoto authored on 2011-09-02
2881

            
2882
is executed, the following SQL is executed.
2883

            
cleanup
Yuki Kimoto authored on 2012-01-20
2884
  insert into book price values ( ? + 5 );
updated pod
Yuki Kimoto authored on 2011-09-02
2885

            
update pod
Yuki Kimoto authored on 2011-03-13
2886
=back
2887

            
2888
=over 4
2889

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2890
=head2 C<include_model>
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2891

            
cleanup
Yuki Kimoto authored on 2012-01-20
2892
  $dbi->include_model('MyModel');
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2893

            
update pod
Yuki Kimoto authored on 2011-03-13
2894
Include models from specified namespace,
2895
the following layout is needed to include models.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2896

            
cleanup
Yuki Kimoto authored on 2012-01-20
2897
  lib / MyModel.pm
2898
      / MyModel / book.pm
2899
                / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2900

            
update pod
Yuki Kimoto authored on 2011-03-13
2901
Name space module, extending L<DBIx::Custom::Model>.
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2902

            
update pod
Yuki Kimoto authored on 2011-03-13
2903
B<MyModel.pm>
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2904

            
cleanup
Yuki Kimoto authored on 2012-01-20
2905
  package MyModel;
2906
  use DBIx::Custom::Model -base;
2907
  
2908
  1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2909

            
update pod
Yuki Kimoto authored on 2011-03-13
2910
Model modules, extending name space module.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2911

            
update pod
Yuki Kimoto authored on 2011-03-13
2912
B<MyModel/book.pm>
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2913

            
cleanup
Yuki Kimoto authored on 2012-01-20
2914
  package MyModel::book;
2915
  use MyModel -base;
2916
  
2917
  1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2918

            
update pod
Yuki Kimoto authored on 2011-03-13
2919
B<MyModel/company.pm>
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2920

            
cleanup
Yuki Kimoto authored on 2012-01-20
2921
  package MyModel::company;
2922
  use MyModel -base;
2923
  
2924
  1;
2925
  
updated pod
Yuki Kimoto authored on 2011-06-21
2926
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2927

            
updated pod
Yuki Kimoto authored on 2011-06-21
2928
You can get model object by C<model>.
update pod
Yuki Kimoto authored on 2011-03-13
2929

            
cleanup
Yuki Kimoto authored on 2012-01-20
2930
  my $book_model = $dbi->model('book');
2931
  my $company_model = $dbi->model('company');
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2932

            
update pod
Yuki Kimoto authored on 2011-03-13
2933
See L<DBIx::Custom::Model> to know model features.
2934

            
cleanup
Yuki Kimoto authored on 2011-10-20
2935
=head2 C<like_value>
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
2936

            
cleanup
Yuki Kimoto authored on 2012-01-20
2937
  my $like_value = $dbi->like_value
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
2938

            
cleanup
Yuki Kimoto authored on 2011-10-20
2939
Code reference which return a value for the like value.
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
2940

            
cleanup
Yuki Kimoto authored on 2012-01-20
2941
  sub { "%$_[0]%" }
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
2942

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2943
=head2 C<mapper>
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
2944

            
cleanup
Yuki Kimoto authored on 2012-01-20
2945
  my $mapper = $dbi->mapper(param => $param);
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
2946

            
2947
Create a new L<DBIx::Custom::Mapper> object.
2948

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2949
=head2 C<merge_param>
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2950

            
cleanup
Yuki Kimoto authored on 2012-01-20
2951
  my $param = $dbi->merge_param({key1 => 1}, {key1 => 1, key2 => 2});
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2952

            
cleanup
Yuki Kimoto authored on 2011-10-20
2953
Merge parameters. The following new parameter is created.
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2954

            
cleanup
Yuki Kimoto authored on 2012-01-20
2955
  {key1 => [1, 1], key2 => 2}
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2956

            
cleanup
Yuki Kimoto authored on 2011-10-20
2957
If same keys contains, the value is converted to array reference.
2958

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2959
=head2 C<model>
update pod
Yuki Kimoto authored on 2011-03-13
2960

            
cleanup
Yuki Kimoto authored on 2012-01-20
2961
  my $model = $dbi->model('book');
update pod
Yuki Kimoto authored on 2011-03-13
2962

            
cleanup
Yuki Kimoto authored on 2011-10-20
2963
Get a L<DBIx::Custom::Model> object
2964
create by C<create_model> or C<include_model>
update pod
Yuki Kimoto authored on 2011-03-13
2965

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2966
=head2 C<mycolumn>
cleanup
Yuki Kimoto authored on 2011-03-21
2967

            
cleanup
Yuki Kimoto authored on 2012-01-20
2968
  my $column = $dbi->mycolumn(book => ['author', 'title']);
cleanup
Yuki Kimoto authored on 2011-03-21
2969

            
2970
Create column clause for myself. The follwoing column clause is created.
2971

            
cleanup
Yuki Kimoto authored on 2012-01-20
2972
  book.author as author,
2973
  book.title as title
cleanup
Yuki Kimoto authored on 2011-03-21
2974

            
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2975
=head2 C<new>
2976

            
cleanup
Yuki Kimoto authored on 2012-01-20
2977
  my $dbi = DBIx::Custom->new(
2978
    dsn => "dbi:mysql:database=dbname",
2979
    user => 'ken',
2980
    password => '!LFKD%$&',
2981
    option => {mysql_enable_utf8 => 1}
2982
  );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2983

            
2984
Create a new L<DBIx::Custom> object.
2985

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2986
=head2 C<not_exists>
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2987

            
cleanup
Yuki Kimoto authored on 2012-01-20
2988
  my $not_exists = $dbi->not_exists;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2989

            
update pod
Yuki Kimoto authored on 2011-03-13
2990
DBIx::Custom::NotExists object, indicating the column is not exists.
cleanup
Yuki Kimoto authored on 2011-10-20
2991
This is used in C<param> of L<DBIx::Custom::Where> .
experimental extended select...
Yuki Kimoto authored on 2011-01-17
2992

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2993
=head2 C<order>
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
2994

            
cleanup
Yuki Kimoto authored on 2012-01-20
2995
  my $order = $dbi->order;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
2996

            
2997
Create a new L<DBIx::Custom::Order> object.
2998

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2999
=head2 C<q>
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
3000

            
cleanup
Yuki Kimoto authored on 2012-01-20
3001
  my $quooted = $dbi->q("title");
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
3002

            
3003
Quote string by value of C<quote>.
3004

            
cleanup
yuki-kimoto authored on 2010-10-17
3005
=head2 C<register_filter>
3006

            
cleanup
Yuki Kimoto authored on 2012-01-20
3007
  $dbi->register_filter(
3008
    # Time::Piece object to database DATE format
3009
    tp_to_date => sub {
3010
      my $tp = shift;
3011
      return $tp->strftime('%Y-%m-%d');
3012
    },
3013
    # database DATE format to Time::Piece object
3014
    date_to_tp => sub {
3015
      my $date = shift;
3016
      return Time::Piece->strptime($date, '%Y-%m-%d');
3017
    }
3018
  );
3019
  
update pod
Yuki Kimoto authored on 2011-03-13
3020
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
3021

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
3022
=head2 C<select>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3023

            
cleanup
Yuki Kimoto authored on 2012-01-20
3024
  my $result = $dbi->select(
3025
    column => ['author', 'title'],
3026
    table  => 'book',
3027
    where  => {author => 'Ken'},
3028
  );
3029
  
updated document
Yuki Kimoto authored on 2011-06-09
3030
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3031

            
- select method can receive ...
Yuki Kimoto authored on 2011-11-18
3032
You can pass odd number arguments. first argument is C<column>.
3033
This is EXPERIMENTAL.
3034

            
cleanup
Yuki Kimoto authored on 2012-01-20
3035
  my $result = $dbi->select(['author', 'title'], table => 'book');
- select method can receive ...
Yuki Kimoto authored on 2011-11-18
3036

            
cleanup
Yuki Kimoto authored on 2011-10-20
3037
B<OPTIONS>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3038

            
cleanup
Yuki Kimoto authored on 2011-10-20
3039
C<select> method use all of C<execute> method's options,
3040
and use the following new ones.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3041

            
cleanup
Yuki Kimoto authored on 2011-10-20
3042
=over 4
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3043

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3044
=item C<column>
cleanup
Yuki Kimoto authored on 2012-01-20
3045
  
3046
  column => 'author'
3047
  column => ['author', 'title']
updated document
Yuki Kimoto authored on 2011-06-09
3048

            
3049
Column clause.
cleanup
Yuki Kimoto authored on 2012-01-20
3050
  
updated document
Yuki Kimoto authored on 2011-06-09
3051
if C<column> is not specified, '*' is set.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3052

            
cleanup
Yuki Kimoto authored on 2012-01-20
3053
  column => '*'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3054

            
- removed EXPERIMENTAL statu...
Yuki Kimoto authored on 2011-07-26
3055
You can specify hash of array reference.
updated pod
Yuki Kimoto authored on 2011-06-07
3056

            
cleanup
Yuki Kimoto authored on 2012-01-20
3057
  column => [
3058
    {book => [qw/author title/]},
3059
    {person => [qw/name age/]}
3060
  ]
updated pod
Yuki Kimoto authored on 2011-06-07
3061

            
updated pod
Yuki Kimoto authored on 2011-06-21
3062
This is expanded to the following one by using C<colomn> method.
- select() column option can...
Yuki Kimoto authored on 2011-06-08
3063

            
cleanup
Yuki Kimoto authored on 2012-01-20
3064
  book.author as "book.author",
3065
  book.title as "book.title",
3066
  person.name as "person.name",
3067
  person.age as "person.age"
- select() column option can...
Yuki Kimoto authored on 2011-06-08
3068

            
- select method column optio...
Yuki Kimoto authored on 2011-07-11
3069
You can specify array of array reference, first argument is
3070
column name, second argument is alias.
- select() column option can...
Yuki Kimoto authored on 2011-06-08
3071

            
cleanup
Yuki Kimoto authored on 2012-01-20
3072
  column => [
3073
    ['date(book.register_datetime)' => 'book.register_date']
3074
  ];
- select() column option can...
Yuki Kimoto authored on 2011-06-08
3075

            
- select method column optio...
Yuki Kimoto authored on 2011-07-11
3076
Alias is quoted properly and joined.
- select() column option can...
Yuki Kimoto authored on 2011-06-08
3077

            
cleanup
Yuki Kimoto authored on 2012-01-20
3078
  date(book.register_datetime) as "book.register_date"
updated pod
Yuki Kimoto authored on 2011-06-07
3079

            
updated document
Yuki Kimoto authored on 2011-06-09
3080
=item C<id>
3081

            
cleanup
Yuki Kimoto authored on 2012-01-20
3082
  id => 4
3083
  id => [4, 5]
updated document
Yuki Kimoto authored on 2011-06-09
3084

            
3085
ID corresponding to C<primary_key>.
3086
You can select rows by C<id> and C<primary_key>.
3087

            
cleanup
Yuki Kimoto authored on 2012-01-20
3088
  $dbi->select(
3089
    primary_key => ['id1', 'id2'],
3090
    id => [4, 5],
3091
    table => 'book'
3092
  );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3093

            
updated document
Yuki Kimoto authored on 2011-06-09
3094
The above is same as the followin one.
3095

            
cleanup
Yuki Kimoto authored on 2012-01-20
3096
  $dbi->select(
3097
    where => {id1 => 4, id2 => 5},
3098
    table => 'book'
3099
  );
3100
  
cleanup
Yuki Kimoto authored on 2011-10-20
3101
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3102

            
cleanup
Yuki Kimoto authored on 2012-01-20
3103
  param => {'table2.key3' => 5}
update pod
Yuki Kimoto authored on 2011-03-12
3104

            
updated document
Yuki Kimoto authored on 2011-06-09
3105
Parameter shown before where clause.
cleanup
Yuki Kimoto authored on 2012-01-20
3106
  
updated document
Yuki Kimoto authored on 2011-06-09
3107
For example, if you want to contain tag in join clause, 
3108
you can pass parameter by C<param> option.
update pod
Yuki Kimoto authored on 2011-03-12
3109

            
cleanup
Yuki Kimoto authored on 2012-01-20
3110
  join  => ['inner join (select * from table2 where table2.key3 = :table2.key3)' . 
3111
            ' as table2 on table1.key1 = table2.key1']
updated document
Yuki Kimoto authored on 2011-06-09
3112

            
- removed EXPERIMENTAL statu...
Yuki Kimoto authored on 2011-07-26
3113
=itme C<prefix>
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
3114

            
cleanup
Yuki Kimoto authored on 2012-01-20
3115
  prefix => 'SQL_CALC_FOUND_ROWS'
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
3116

            
3117
Prefix of column cluase
3118

            
cleanup
Yuki Kimoto authored on 2012-01-20
3119
  select SQL_CALC_FOUND_ROWS title, author from book;
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
3120

            
updated document
Yuki Kimoto authored on 2011-06-09
3121
=item C<join>
3122

            
cleanup
Yuki Kimoto authored on 2012-01-20
3123
  join => [
3124
    'left outer join company on book.company_id = company_id',
3125
    'left outer join location on company.location_id = location.id'
3126
  ]
3127
      
updated document
Yuki Kimoto authored on 2011-06-09
3128
Join clause. If column cluase or where clause contain table name like "company.name",
3129
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3130

            
cleanup
Yuki Kimoto authored on 2012-01-20
3131
  $dbi->select(
3132
    table => 'book',
3133
    column => ['company.location_id as location_id'],
3134
    where => {'company.name' => 'Orange'},
3135
    join => [
3136
      'left outer join company on book.company_id = company.id',
3137
      'left outer join location on company.location_id = location.id'
3138
    ]
3139
  );
update pod
Yuki Kimoto authored on 2011-03-12
3140

            
updated document
Yuki Kimoto authored on 2011-06-09
3141
In above select, column and where clause contain "company" table,
3142
the following SQL is created
update pod
Yuki Kimoto authored on 2011-03-12
3143

            
cleanup
Yuki Kimoto authored on 2012-01-20
3144
  select company.location_id as location_id
3145
  from book
3146
    left outer join company on book.company_id = company.id
3147
  where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3148

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3149
You can specify two table by yourself. This is useful when join parser can't parse
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3150
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3151

            
cleanup
Yuki Kimoto authored on 2012-01-20
3152
  $dbi->select(
3153
    table => 'book',
3154
    column => ['company.location_id as location_id'],
3155
    where => {'company.name' => 'Orange'},
3156
    join => [
3157
      {
3158
        clause => 'left outer join location on company.location_id = location.id',
3159
        table => ['company', 'location']
3160
      }
3161
    ]
3162
  );
added join new syntax
Yuki Kimoto authored on 2011-07-28
3163

            
updated document
Yuki Kimoto authored on 2011-06-09
3164
=item C<table>
updated pod
Yuki Kimoto authored on 2011-06-08
3165

            
cleanup
Yuki Kimoto authored on 2012-01-20
3166
  table => 'book'
updated pod
Yuki Kimoto authored on 2011-06-08
3167

            
updated document
Yuki Kimoto authored on 2011-06-09
3168
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3169

            
updated document
Yuki Kimoto authored on 2011-06-09
3170
=item C<where>
cleanup
Yuki Kimoto authored on 2012-01-20
3171
  
3172
  # Hash refrence
3173
  where => {author => 'Ken', 'title' => 'Perl'}
3174
  
3175
  # DBIx::Custom::Where object
3176
  where => $dbi->where(
3177
    clause => ['and', ':author{=}', ':title{like}'],
3178
    param  => {author => 'Ken', title => '%Perl%'}
3179
  );
3180
  
3181
  # Array reference, this is same as above
3182
  where => [
3183
    ['and', ':author{=}', ':title{like}'],
3184
    {author => 'Ken', title => '%Perl%'}
3185
  ];
3186
  
3187
  # String
3188
  where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3189

            
cleanup
Yuki Kimoto authored on 2011-10-20
3190
Where clause. See L<DBIx::Custom::Where>.
cleanup
Yuki Kimoto authored on 2012-01-20
3191
  
update pod
Yuki Kimoto authored on 2011-03-12
3192
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3193

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3194
=head2 C<setup_model>
3195

            
cleanup
Yuki Kimoto authored on 2012-01-20
3196
  $dbi->setup_model;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3197

            
3198
Setup all model objects.
3199
C<columns> of model object is automatically set, parsing database information.
3200

            
3201
=head2 C<type_rule>
3202

            
cleanup
Yuki Kimoto authored on 2012-01-20
3203
  $dbi->type_rule(
3204
    into1 => {
3205
      date => sub { ... },
3206
      datetime => sub { ... }
3207
    },
3208
    into2 => {
3209
      date => sub { ... },
3210
      datetime => sub { ... }
3211
    },
3212
    from1 => {
3213
      # DATE
3214
      9 => sub { ... },
3215
      # DATETIME or TIMESTAMP
3216
      11 => sub { ... },
3217
    }
3218
    from2 => {
3219
      # DATE
3220
      9 => sub { ... },
3221
      # DATETIME or TIMESTAMP
3222
      11 => sub { ... },
3223
    }
3224
  );
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3225

            
3226
Filtering rule when data is send into and get from database.
3227
This has a little complex problem.
3228

            
3229
In C<into1> and C<into2> you can specify
3230
type name as same as type name defined
3231
by create table, such as C<DATETIME> or C<DATE>.
3232

            
3233
Note that type name and data type don't contain upper case.
3234
If these contain upper case charactor, you convert it to lower case.
3235

            
3236
C<into2> is executed after C<into1>.
3237

            
3238
Type rule of C<into1> and C<into2> is enabled on the following
3239
column name.
3240

            
3241
=over 4
3242

            
3243
=item 1. column name
3244

            
cleanup
Yuki Kimoto authored on 2012-01-20
3245
  issue_date
3246
  issue_datetime
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3247

            
3248
This need C<table> option in each method.
3249

            
3250
=item 2. table name and column name, separator is dot
3251

            
cleanup
Yuki Kimoto authored on 2012-01-20
3252
  book.issue_date
3253
  book.issue_datetime
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3254

            
3255
=back
3256

            
3257
You get all type name used in database by C<available_typename>.
3258

            
cleanup
Yuki Kimoto authored on 2012-01-20
3259
  print $dbi->available_typename;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3260

            
3261
In C<from1> and C<from2> you specify data type, not type name.
3262
C<from2> is executed after C<from1>.
3263
You get all data type by C<available_datatype>.
3264

            
cleanup
Yuki Kimoto authored on 2012-01-20
3265
  print $dbi->available_datatype;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3266

            
3267
You can also specify multiple types at once.
3268

            
cleanup
Yuki Kimoto authored on 2012-01-20
3269
  $dbi->type_rule(
3270
    into1 => [
3271
      [qw/DATE DATETIME/] => sub { ... },
3272
    ],
3273
  );
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3274

            
cleanup
yuki-kimoto authored on 2010-10-17
3275
=head2 C<update>
removed reconnect method
yuki-kimoto authored on 2010-05-28
3276

            
cleanup
Yuki Kimoto authored on 2012-01-20
3277
  $dbi->update({title => 'Perl'}, table  => 'book', where  => {id => 4});
removed reconnect method
yuki-kimoto authored on 2010-05-28
3278

            
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
3279
Execute update statement. First argument is update row data.
3280

            
3281
If you want to set constant value to row data, use scalar reference
3282
as parameter value.
3283

            
cleanup
Yuki Kimoto authored on 2012-01-20
3284
  {date => \"NOW()"}
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
3285

            
cleanup
Yuki Kimoto authored on 2011-10-20
3286
B<OPTIONS>
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3287

            
cleanup
Yuki Kimoto authored on 2011-10-20
3288
C<update> method use all of C<execute> method's options,
3289
and use the following new ones.
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3290

            
cleanup
Yuki Kimoto authored on 2011-10-20
3291
=over 4
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3292

            
updated document
Yuki Kimoto authored on 2011-06-09
3293
=item C<id>
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3294

            
cleanup
Yuki Kimoto authored on 2012-01-20
3295
  id => 4
3296
  id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3297

            
updated document
Yuki Kimoto authored on 2011-06-09
3298
ID corresponding to C<primary_key>.
3299
You can update rows by C<id> and C<primary_key>.
update pod
Yuki Kimoto authored on 2011-03-13
3300

            
cleanup
Yuki Kimoto authored on 2012-01-20
3301
  $dbi->update(
3302
    {title => 'Perl', author => 'Ken'}
3303
    primary_key => ['id1', 'id2'],
3304
    id => [4, 5],
3305
    table => 'book'
3306
  );
update pod
Yuki Kimoto authored on 2011-03-13
3307

            
updated document
Yuki Kimoto authored on 2011-06-09
3308
The above is same as the followin one.
update pod
Yuki Kimoto authored on 2011-03-13
3309

            
cleanup
Yuki Kimoto authored on 2012-01-20
3310
  $dbi->update(
3311
    {title => 'Perl', author => 'Ken'}
3312
    where => {id1 => 4, id2 => 5},
3313
    table => 'book'
3314
  );
update pod
Yuki Kimoto authored on 2011-03-13
3315

            
- removed EXPERIMENTAL statu...
Yuki Kimoto authored on 2011-07-26
3316
=item C<prefix>
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
3317

            
cleanup
Yuki Kimoto authored on 2012-01-20
3318
  prefix => 'or replace'
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
3319

            
3320
prefix before table name section
3321

            
cleanup
Yuki Kimoto authored on 2012-01-20
3322
  update or replace book
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
3323

            
updated document
Yuki Kimoto authored on 2011-06-09
3324
=item C<table>
update pod
Yuki Kimoto authored on 2011-03-13
3325

            
cleanup
Yuki Kimoto authored on 2012-01-20
3326
  table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
3327

            
updated document
Yuki Kimoto authored on 2011-06-09
3328
Table name.
update pod
Yuki Kimoto authored on 2011-03-13
3329

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3330
=item C<where>
3331

            
3332
Same as C<select> method's C<where> option.
3333

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3334
=item C<wrap>
updated pod
Yuki Kimoto authored on 2011-09-02
3335

            
cleanup
Yuki Kimoto authored on 2012-01-20
3336
  wrap => {price => sub { "max($_[0])" }}
updated pod
Yuki Kimoto authored on 2011-09-02
3337

            
3338
placeholder wrapped string.
3339

            
3340
If the following statement
3341

            
cleanup
Yuki Kimoto authored on 2012-01-20
3342
  $dbi->update({price => 100}, table => 'book',
3343
    {price => sub { "$_[0] + 5" }});
updated pod
Yuki Kimoto authored on 2011-09-02
3344

            
3345
is executed, the following SQL is executed.
3346

            
cleanup
Yuki Kimoto authored on 2012-01-20
3347
  update book set price =  ? + 5;
updated pod
Yuki Kimoto authored on 2011-09-02
3348

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3349
=item C<updated_at>
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
3350

            
cleanup
Yuki Kimoto authored on 2012-01-20
3351
  updated_at => 'updated_datetime'
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
3352

            
3353
Updated timestamp column name. time when row is updated is set to the column.
3354
default time format is C<YYYY-mm-dd HH:MM:SS>, which can be changed by
3355
C<now> attribute.
3356

            
updated pod
Yuki Kimoto authored on 2011-06-08
3357
=back
update pod
Yuki Kimoto authored on 2011-03-13
3358

            
updated pod
Yuki Kimoto authored on 2011-06-08
3359
=head2 C<update_all>
update pod
Yuki Kimoto authored on 2011-03-13
3360

            
cleanup
Yuki Kimoto authored on 2012-01-20
3361
  $dbi->update_all({title => 'Perl'}, table => 'book', );
update pod
Yuki Kimoto authored on 2011-03-13
3362

            
updated document
Yuki Kimoto authored on 2011-06-09
3363
Execute update statement for all rows.
updated pod
Yuki Kimoto authored on 2011-06-21
3364
Options is same as C<update> method.
update pod
Yuki Kimoto authored on 2011-03-13
3365

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3366
=head2 C<update_or_insert>
cleanup
Yuki Kimoto authored on 2012-01-20
3367
  
3368
  # ID
3369
  $dbi->update_or_insert(
3370
    {title => 'Perl'},
3371
    table => 'book',
3372
    id => 1,
3373
    primary_key => 'id',
3374
    option => {
3375
      select => {
3376
         append => 'for update'
3377
      }
3378
    }
3379
  );
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3380

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3381
Update or insert.
3382

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3383
C<update_or_insert> method execute C<select> method first to find row.
3384
If the row is exists, C<update> is executed.
3385
If not, C<insert> is executed.
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3386

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3387
C<OPTIONS>
3388

            
3389
C<update_or_insert> method use all common option
3390
in C<select>, C<update>, C<delete>, and has the following new ones.
3391

            
3392
=over 4
3393

            
3394
=item C<option>
3395

            
cleanup
Yuki Kimoto authored on 2012-01-20
3396
  option => {
3397
    select => {
3398
      append => '...'
3399
    },
3400
    insert => {
3401
      prefix => '...'
3402
    },
3403
    update => {
3404
      filter => {}
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3405
    }
cleanup
Yuki Kimoto authored on 2012-01-20
3406
  }
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3407

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3408
If you want to pass option to each method,
3409
you can use C<option> option.
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3410

            
3411
=over 4
3412

            
3413
=item C<select_option>
3414

            
cleanup
Yuki Kimoto authored on 2012-01-20
3415
  select_option => {append => 'for update'}
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3416

            
3417
select method option,
3418
select method is used to check the row is already exists.
3419

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3420
=head2 C<show_datatype>
update pod
Yuki Kimoto authored on 2011-08-10
3421

            
cleanup
Yuki Kimoto authored on 2012-01-20
3422
  $dbi->show_datatype($table);
update pod
Yuki Kimoto authored on 2011-08-10
3423

            
3424
Show data type of the columns of specified table.
3425

            
cleanup
Yuki Kimoto authored on 2012-01-20
3426
  book
3427
  title: 5
3428
  issue_date: 91
update pod
Yuki Kimoto authored on 2011-08-10
3429

            
3430
This data type is used in C<type_rule>'s C<from1> and C<from2>.
3431

            
- removed EXPERIMENTAL the f...
Yuki Kimoto authored on 2011-09-12
3432
=head2 C<show_tables>
test cleanup
Yuki Kimoto authored on 2011-08-15
3433

            
cleanup
Yuki Kimoto authored on 2012-01-20
3434
  $dbi->show_tables;
test cleanup
Yuki Kimoto authored on 2011-08-15
3435

            
3436
Show tables.
3437

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3438
=head2 C<show_typename>
update pod
Yuki Kimoto authored on 2011-08-10
3439

            
cleanup
Yuki Kimoto authored on 2012-01-20
3440
  $dbi->show_typename($table);
update pod
Yuki Kimoto authored on 2011-08-10
3441

            
3442
Show type name of the columns of specified table.
3443

            
cleanup
Yuki Kimoto authored on 2012-01-20
3444
  book
3445
  title: varchar
3446
  issue_date: date
update pod
Yuki Kimoto authored on 2011-08-10
3447

            
3448
This type name is used in C<type_rule>'s C<into1> and C<into2>.
3449

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3450
=head2 C<values_clause>
3451

            
cleanup
Yuki Kimoto authored on 2012-01-20
3452
  my $values_clause = $dbi->values_clause({title => 'a', age => 2});
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3453

            
3454
Create values clause.
3455

            
cleanup
Yuki Kimoto authored on 2012-01-20
3456
  (title, author) values (title = :title, age = :age);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3457

            
3458
You can use this in insert statement.
3459

            
cleanup
Yuki Kimoto authored on 2012-01-20
3460
  my $insert_sql = "insert into book $values_clause";
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3461

            
3462
=head2 C<where>
3463

            
cleanup
Yuki Kimoto authored on 2012-01-20
3464
  my $where = $dbi->where(
3465
    clause => ['and', 'title = :title', 'author = :author'],
3466
    param => {title => 'Perl', author => 'Ken'}
3467
  );
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3468

            
3469
Create a new L<DBIx::Custom::Where> object.
3470

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
3471
=head1 ENVIRONMENTAL VARIABLES
3472

            
3473
=head2 C<DBIX_CUSTOM_DEBUG>
3474

            
3475
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3476
executed SQL and bind values are printed to STDERR.
3477

            
improved debug message
Yuki Kimoto authored on 2011-05-23
3478
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3479

            
3480
DEBUG output encoding. Default to UTF-8.
added environment variable D...
Yuki Kimoto authored on 2011-04-02
3481

            
- fixed bug DBIx::Custom::Re...
Yuki Kimoto authored on 2011-11-08
3482
=head2 C<DBIX_CUSTOM_TAG_PARSE>
3483

            
3484
If you set DBIX_CUSTOM_TAG_PARSE to 0, tag parsing is off.
3485

            
3486
=head2 C<DBIX_CUSTOM_DISABLE_MODEL_EXECUTE>
3487

            
3488
If you set DBIX_CUSTOM_DISABLE_MODEL_EXECUTE to 1,
3489
L<DBIx::Custom::Model> execute method call L<DBIx::Custom> execute.
3490

            
fix heading typos
Terrence Brannon authored on 2011-08-17
3491
=head1 DEPRECATED FUNCTIONALITY
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3492

            
3493
L<DBIx::Custom>
3494

            
cleanup
Yuki Kimoto authored on 2012-01-20
3495
  # Attribute methods
3496
  tag_parse # will be removed 2017/1/1
3497
  default_dbi_option # will be removed 2017/1/1
3498
  dbi_option # will be removed 2017/1/1
3499
  data_source # will be removed at 2017/1/1
3500
  dbi_options # will be removed at 2017/1/1
3501
  filter_check # will be removed at 2017/1/1
3502
  reserved_word_quote # will be removed at 2017/1/1
3503
  cache_method # will be removed at 2017/1/1
3504
  
3505
  # Methods
3506
  update_timestamp # will be removed at 2017/1/1
3507
  insert_timestamp # will be removed at 2017/1/1
3508
  method # will be removed at 2017/1/1
3509
  assign_param # will be removed at 2017/1/1
3510
  update_param # will be removed at 2017/1/1
3511
  insert_param # will be removed at 2017/1/1
3512
  create_query # will be removed at 2017/1/1
3513
  apply_filter # will be removed at 2017/1/1
3514
  select_at # will be removed at 2017/1/1
3515
  delete_at # will be removed at 2017/1/1
3516
  update_at # will be removed at 2017/1/1
3517
  insert_at # will be removed at 2017/1/1
3518
  register_tag # will be removed at 2017/1/1
3519
  default_bind_filter # will be removed at 2017/1/1
3520
  default_fetch_filter # will be removed at 2017/1/1
3521
  insert_param_tag # will be removed at 2017/1/1
3522
  register_tag # will be removed at 2017/1/1
3523
  register_tag_processor # will be removed at 2017/1/1
3524
  update_param_tag # will be removed at 2017/1/1
3525
  
3526
  # Options
3527
  select column option [COLUMN => ALIAS] syntax # will be removed 2017/1/1
3528
  execute method id option # will be removed 2017/1/1
3529
  update timestamp option # will be removed 2017/1/1
3530
  insert timestamp option # will be removed 2017/1/1
3531
  select method where_param option # will be removed 2017/1/1
3532
  delete method where_param option # will be removed 2017/1/1
3533
  update method where_param option # will be removed 2017/1/1
3534
  insert method param option # will be removed at 2017/1/1
3535
  insert method id option # will be removed at 2017/1/1
3536
  select method relation option # will be removed at 2017/1/1
3537
  select method column option [COLUMN, as => ALIAS] format
3538
    # will be removed at 2017/1/1
3539
  execute method's sqlfilter option # will be removed at 2017/1/1
3540
  
3541
  # Others
3542
  execute($query, ...) # execute method receiving query object.
3543
                       # this is removed at 2017/1/1
3544
  execute("select * from {= title}"); # execute method's
3545
                                      # tag parsing functionality
3546
                                      # will be removed at 2017/1/1
3547
  Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3548

            
3549
L<DBIx::Custom::Model>
3550

            
cleanup
Yuki Kimoto authored on 2012-01-20
3551
  # Attribute methods
3552
  execute # will be removed at 2017/1/1
3553
  method # will be removed at 2017/1/1
3554
  filter # will be removed at 2017/1/1
3555
  name # will be removed at 2017/1/1
3556
  type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3557

            
3558
L<DBIx::Custom::Query>
DBIx::Custom::Query is DEPRE...
Yuki Kimoto authored on 2011-11-15
3559

            
3560
This module is DEPRECATED! # will be removed at 2017/1/1
cleanup
Yuki Kimoto authored on 2012-01-20
3561
  
3562
  # Attribute methods
3563
  default_filter # will be removed at 2017/1/1
3564
  table # will be removed at 2017/1/1
3565
  filters # will be removed at 2017/1/1
3566
  
3567
  # Methods
3568
  filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3569

            
3570
L<DBIx::Custom::QueryBuilder>
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
3571

            
3572
This module is DEPRECATED! # will be removed at 2017/1/1
cleanup
Yuki Kimoto authored on 2012-01-20
3573
  
3574
  # Attribute methods
3575
  tags # will be removed at 2017/1/1
3576
  tag_processors # will be removed at 2017/1/1
3577
  
3578
  # Methods
3579
  register_tag # will be removed at 2017/1/1
3580
  register_tag_processor # will be removed at 2017/1/1
3581
  
3582
  # Others
3583
  build_query("select * from {= title}"); # tag parsing functionality
3584
                                          # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3585

            
3586
L<DBIx::Custom::Result>
cleanup
Yuki Kimoto authored on 2012-01-20
3587
  
3588
  # Attribute methods
3589
  filter_check # will be removed at 2017/1/1
3590
  
3591
  # Methods
3592
  fetch_first # will be removed at 2017/2/1
3593
  fetch_hash_first # will be removed 2017/2/1
3594
  filter_on # will be removed at 2017/1/1
3595
  filter_off # will be removed at 2017/1/1
3596
  end_filter # will be removed at 2017/1/1
3597
  remove_end_filter # will be removed at 2017/1/1
3598
  remove_filter # will be removed at 2017/1/1
3599
  default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3600

            
3601
L<DBIx::Custom::Tag>
3602

            
cleanup
Yuki Kimoto authored on 2012-01-20
3603
  This module is DEPRECATED! # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3604

            
micro optimization
Yuki Kimoto authored on 2011-11-07
3605
L<DBIx::Custom::Order>
3606

            
cleanup
Yuki Kimoto authored on 2012-01-20
3607
  # Other
3608
  prepend method array reference receiving
3609
    $order->prepend(['book', 'desc']); # will be removed 2017/1/1
micro optimization
Yuki Kimoto authored on 2011-11-07
3610

            
fix heading typos
Terrence Brannon authored on 2011-08-17
3611
=head1 BACKWARDS COMPATIBILITY POLICY
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3612

            
3613
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3614
except for attribute method.
3615
You can check all DEPRECATED functionalities by document.
3616
DEPRECATED functionality is removed after five years,
3617
but if at least one person use the functionality and tell me that thing
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3618
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3619

            
3620
EXPERIMENTAL functionality will be changed without warnings.
DBIx::Custom is now stable
yuki-kimoto authored on 2010-09-07
3621

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
3622
=head1 BUGS
3623

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
3624
Please tell me bugs if found.
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
3625

            
3626
C<< <kimoto.yuki at gmail.com> >>
3627

            
3628
L<http://github.com/yuki-kimoto/DBIx-Custom>
3629

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3630
=head1 AUTHOR
3631

            
3632
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
version 0.0901
yuki-kimoto authored on 2009-12-17
3633

            
packaging one directory
yuki-kimoto authored on 2009-11-16
3634
=head1 COPYRIGHT & LICENSE
3635

            
cleanup
Yuki Kimoto authored on 2011-01-25
3636
Copyright 2009-2011 Yuki Kimoto, all rights reserved.
packaging one directory
yuki-kimoto authored on 2009-11-16
3637

            
3638
This program is free software; you can redistribute it and/or modify it
3639
under the same terms as Perl itself.
3640

            
3641
=cut