DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3571 lines | 93.321kb
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

            
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
4
our $VERSION = '0.1738';
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/;
packaging one directory
yuki-kimoto authored on 2009-11-16
21

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
22
has [qw/connector dsn password quote user exclude_table user_table_info
23
        user_column_info/],
removed from cache() and cac...
Yuki Kimoto authored on 2011-03-29
24
    cache => 0,
many changed
Yuki Kimoto authored on 2011-01-23
25
    cache_method => sub {
26
        sub {
27
            my $self = shift;
28
            
29
            $self->{_cached} ||= {};
30
            
31
            if (@_ > 1) {
update pod
Yuki Kimoto authored on 2011-03-13
32
                $self->{_cached}{$_[0]} = $_[1];
many changed
Yuki Kimoto authored on 2011-01-23
33
            }
34
            else {
update pod
Yuki Kimoto authored on 2011-03-13
35
                return $self->{_cached}{$_[0]};
many changed
Yuki Kimoto authored on 2011-01-23
36
            }
37
        }
update pod
Yuki Kimoto authored on 2011-03-13
38
    },
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
39
    option => sub { {} },
40
    default_option => sub {
update pod
Yuki Kimoto authored on 2011-03-13
41
        {
42
            RaiseError => 1,
43
            PrintError => 0,
44
            AutoCommit => 1
45
        }
46
    },
fix tests
Yuki Kimoto authored on 2011-01-13
47
    filters => sub {
48
        {
49
            encode_utf8 => sub { encode_utf8($_[0]) },
50
            decode_utf8 => sub { decode_utf8($_[0]) }
51
        }
update pod
Yuki Kimoto authored on 2011-03-13
52
    },
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
53
    last_sql => '',
update pod
Yuki Kimoto authored on 2011-03-13
54
    models => sub { {} },
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
55
    now => sub {
56
        sub {
57
            my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
58
            $mon++;
59
            $year += 1900;
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
60
            my $now = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
61
              $year, $mon, $mday, $hour, $min, $sec);
62
            return $now;
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
63
        }
64
    },
cleanup
Yuki Kimoto authored on 2011-08-13
65
    query_builder => sub {
66
        my $self = shift;
67
        my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
68
        weaken $builder->{dbi};
69
        return $builder;
70
    },
update pod
Yuki Kimoto authored on 2011-03-13
71
    result_class  => 'DBIx::Custom::Result',
72
    safety_character => '\w',
cleanup test
Yuki Kimoto authored on 2011-08-10
73
    separator => '.',
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
74
    stash => sub { {} },
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
75
    tag_parse => 1;
cleanup
yuki-kimoto authored on 2010-10-17
76

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
77
sub available_datatype {
test cleanup
Yuki Kimoto authored on 2011-08-10
78
    my $self = shift;
79
    
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
80
    my $data_types = '';
cleanup
Yuki Kimoto authored on 2011-10-21
81
    for my $i (-1000 .. 1000) {
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
82
         my $type_info = $self->dbh->type_info($i);
83
         my $data_type = $type_info->{DATA_TYPE};
84
         my $type_name = $type_info->{TYPE_NAME};
85
         $data_types .= "$data_type ($type_name)\n"
86
           if defined $data_type;
87
    }
88
    return "Data Type maybe equal to Type Name" unless $data_types;
89
    $data_types = "Data Type (Type name)\n" . $data_types;
90
    return $data_types;
91
}
92

            
93
sub available_typename {
94
    my $self = shift;
95
    
96
    # Type Names
97
    my $type_names = {};
98
    $self->each_column(sub {
99
        my ($self, $table, $column, $column_info) = @_;
100
        $type_names->{$column_info->{TYPE_NAME}} = 1
101
          if $column_info->{TYPE_NAME};
102
    });
103
    my @output = sort keys %$type_names;
104
    unshift @output, "Type Name";
105
    return join "\n", @output;
test cleanup
Yuki Kimoto authored on 2011-08-10
106
}
107

            
added helper method
yuki-kimoto authored on 2010-10-17
108
our $AUTOLOAD;
109
sub AUTOLOAD {
110
    my $self = shift;
111

            
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
112
    # Method name
113
    my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
added helper method
yuki-kimoto authored on 2010-10-17
114

            
cleanup
Yuki Kimoto authored on 2011-04-02
115
    # Call method
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
116
    $self->{_methods} ||= {};
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
117
    if (my $method = $self->{_methods}->{$mname}) {
118
        return $self->$method(@_)
119
    }
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
120
    elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
121
        $self->dbh->$dbh_method(@_);
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
122
    }
123
    else {
cleanup
Yuki Kimoto authored on 2011-04-25
124
        croak qq{Can't locate object method "$mname" via "$package" }
125
            . _subname;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
126
    }
added helper method
yuki-kimoto authored on 2010-10-17
127
}
128

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
129
sub assign_clause {
updated pod
Yuki Kimoto authored on 2011-09-02
130
    my ($self, $param, $opts) = @_;
131
    
132
    my $wrap = $opts->{wrap} || {};
micro optimization
Yuki Kimoto authored on 2011-10-23
133
    my $safety = $self->{safety_character} || $self->safety_character;
fixed some quoted bug
Yuki Kimoto authored on 2011-10-22
134
    my $qp = $self->_q('');
135
    my $q = substr($qp, 0, 1) || '';
136
    my $p = substr($qp, 1, 1) || '';
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
137
    
micro optimization
Yuki Kimoto authored on 2011-10-23
138
    # Check unsafety keys
139
    unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
140
        for my $column (keys %$param) {
141
            croak qq{"$column" is not safety column name } . _subname
142
              unless $column =~ /^[$safety\.]+$/;
143
        }
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
144
    }
145
    
micro optimization
Yuki Kimoto authored on 2011-10-23
146
    # Assign clause (performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
147
    join(
148
      ', ',
149
      map {
150
          ref $param->{$_} eq 'SCALAR' ? "$q$_$p = " . ${$param->{$_}}
151
          : $wrap->{$_} ? "$q$_$p = " . $wrap->{$_}->(":$_")
152
          : "$q$_$p = :$_";
153
      } sort keys %$param
154
    );
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
155
}
156

            
cleanup
Yuki Kimoto authored on 2011-03-21
157
sub column {
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
158
    my $self = shift;
159
    my $option = pop if ref $_[-1] eq 'HASH';
160
    my $real_table = shift;
161
    my $columns = shift;
162
    my $table = $option->{alias} || $real_table;
163
    
164
    # Columns
165
    unless ($columns) {
166
        $columns ||= $self->model($real_table)->columns;
167
    }
added helper method
yuki-kimoto authored on 2010-10-17
168
    
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
169
    # Separator
170
    my $separator = $self->separator;
171
    
cleanup
Yuki Kimoto authored on 2011-04-02
172
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-21
173
    my @column;
cleanup
Yuki Kimoto authored on 2011-04-02
174
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
175
    push @column, $self->_q($table) . "." . $self->_q($_) .
176
      " as " . $self->_q("${table}${separator}$_")
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
177
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
178
    
179
    return join (', ', @column);
added helper method
yuki-kimoto authored on 2010-10-17
180
}
181

            
packaging one directory
yuki-kimoto authored on 2009-11-16
182
sub connect {
cleanup
Yuki Kimoto authored on 2011-08-16
183
    my $self = ref $_[0] ? shift : shift->new(@_);
184
    
185
    my $connector = $self->connector;
186
    
187
    if (!ref $connector && $connector) {
188
        require DBIx::Connector;
189
        
190
        my $dsn = $self->dsn;
191
        my $user = $self->user;
192
        my $password = $self->password;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
193
        my $option = $self->_option;
cleanup
Yuki Kimoto authored on 2011-08-16
194
        my $connector = DBIx::Connector->new($dsn, $user, $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
195
          {%{$self->default_option} , %$option});
cleanup
Yuki Kimoto authored on 2011-08-16
196
        $self->connector($connector);
197
    }
removed register_format()
yuki-kimoto authored on 2010-05-26
198
    
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
199
    # Connect
200
    $self->dbh;
update document
yuki-kimoto authored on 2010-01-30
201
    
packaging one directory
yuki-kimoto authored on 2009-11-16
202
    return $self;
203
}
204

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
205
sub count { shift->select(column => 'count(*)', @_)->fetch_first->[0] }
206

            
update pod
Yuki Kimoto authored on 2011-03-13
207
sub dbh {
208
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-04-02
209
    
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
210
    # Set
211
    if (@_) {
212
        $self->{dbh} = $_[0];
213
        
214
        return $self;
215
    }
216
    
217
    # Get
218
    else {
219
        # From Connction manager
220
        if (my $connector = $self->connector) {
cleanup
Yuki Kimoto authored on 2011-04-25
221
            croak "connector must have dbh() method " . _subname
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
222
              unless ref $connector && $connector->can('dbh');
223
              
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
224
            $self->{dbh} = $connector->dbh;
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
225
        }
226
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
227
        # Connect
228
        $self->{dbh} ||= $self->_connect;
229
        
230
        # Quote
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
231
        if (!defined $self->reserved_word_quote && !defined $self->quote) {
prepare oracle test
Yuki Kimoto authored on 2011-08-15
232
            my $driver = $self->_driver;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
233
            my $quote =  $driver eq 'odbc' ? '[]'
234
                       : $driver eq 'ado' ? '[]'
235
                       : $driver eq 'mysql' ? '`'
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
236
                       : '"';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
237
            $self->quote($quote);
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
238
        }
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
239
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
240
        return $self->{dbh};
update pod
Yuki Kimoto authored on 2011-03-13
241
    }
242
}
243

            
cleanup
Yuki Kimoto authored on 2011-10-21
244
sub delete {
245
    my ($self, %opt) = @_;
246
    warn "delete method where_param option is DEPRECATED!"
247
      if $opt{where_param};
248
    
cleanup
Yuki Kimoto authored on 2011-10-21
249
    # Don't allow delete all rows
cleanup
Yuki Kimoto authored on 2011-10-21
250
    croak qq{delete method where or id option must be specified } . _subname
251
      if !$opt{where} && !defined $opt{id} && !$opt{allow_delete_all};
252
    
253
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
254
    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
cleanup
Yuki Kimoto authored on 2011-10-25
255
      delete $opt{id}, $opt{primary_key}, $opt{table});
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
256

            
cleanup
Yuki Kimoto authored on 2011-04-02
257
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-10-21
258
    my $sql = "delete ";
cleanup
Yuki Kimoto authored on 2011-10-21
259
    $sql .= "$opt{prefix} " if defined $opt{prefix};
cleanup
Yuki Kimoto authored on 2011-10-25
260
    $sql .= "from " . $self->_q($opt{table}) . " $w->{clause} ";
packaging one directory
yuki-kimoto authored on 2009-11-16
261
    
262
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
263
    $opt{statement} = 'delete';
cleanup
Yuki Kimoto authored on 2011-10-25
264
    $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
265
}
266

            
cleanup
yuki-kimoto authored on 2010-10-17
267
sub delete_all { shift->delete(allow_delete_all => 1, @_) }
packaging one directory
yuki-kimoto authored on 2009-11-16
268

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
271
sub create_model {
272
    my $self = shift;
273
    
cleanup
Yuki Kimoto authored on 2011-10-21
274
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
275
    my $opt = ref $_[0] eq 'HASH' ? $_[0] : {@_};
276
    $opt->{dbi} = $self;
277
    my $model_class = delete $opt->{model_class} || 'DBIx::Custom::Model';
278
    my $model_name  = delete $opt->{name};
279
    my $model_table = delete $opt->{table};
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
280
    $model_name ||= $model_table;
281
    
cleanup
Yuki Kimoto authored on 2011-04-02
282
    # Create model
cleanup
Yuki Kimoto authored on 2011-10-21
283
    my $model = $model_class->new($opt);
cleanup
Yuki Kimoto authored on 2011-08-13
284
    weaken $model->{dbi};
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
285
    $model->name($model_name) unless $model->name;
286
    $model->table($model_table) unless $model->table;
287
    
micro optimization
Yuki Kimoto authored on 2011-07-30
288
    # Apply filter(DEPRECATED logic)
289
    if ($model->{filter}) {
290
        my $filter = ref $model->filter eq 'HASH'
291
                   ? [%{$model->filter}]
292
                   : $model->filter;
293
        $filter ||= [];
294
        warn "DBIx::Custom::Model filter method is DEPRECATED!"
295
          if @$filter;
296
        $self->_apply_filter($model->table, @$filter);
297
    }
298
    
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
299
    # Set model
300
    $self->model($model->name, $model);
301
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
302
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
303
}
304

            
305
sub each_column {
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
306
    my ($self, $cb, %options) = @_;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
307

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
308
    my $user_column_info = $self->user_column_info;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
309
    
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
310
    if ($user_column_info) {
311
        $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
312
    }
313
    else {
314
    
315
        my $re = $self->exclude_table || $options{exclude_table};
316
        # Tables
317
        my %tables;
318
        $self->each_table(sub { $tables{$_[1]}++ });
added SQL Server test
Yuki Kimoto authored on 2011-08-14
319

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
320
        # Iterate all tables
321
        my @tables = sort keys %tables;
322
        for (my $i = 0; $i < @tables; $i++) {
323
            my $table = $tables[$i];
324
            
325
            # Iterate all columns
326
            my $sth_columns;
327
            eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
328
            next if $@;
329
            while (my $column_info = $sth_columns->fetchrow_hashref) {
330
                my $column = $column_info->{COLUMN_NAME};
331
                $self->$cb($table, $column, $column_info);
332
            }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
333
        }
334
    }
335
}
336

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
337
sub each_table {
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
338
    my ($self, $cb, %option) = @_;
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
339
    
cleanup test
Yuki Kimoto authored on 2011-08-16
340
    my $user_table_infos = $self->user_table_info;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
341
    
added test
Yuki Kimoto authored on 2011-08-16
342
    # Iterate tables
343
    if ($user_table_infos) {
344
        $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
345
    }
346
    else {
347
        my $re = $self->exclude_table || $option{exclude};
348
        my $sth_tables = $self->dbh->table_info;
349
        while (my $table_info = $sth_tables->fetchrow_hashref) {
350
            
351
            # Table
352
            my $table = $table_info->{TABLE_NAME};
353
            next if defined $re && $table =~ /$re/;
354
            $self->$cb($table, $table_info);
355
        }
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
356
    }
357
}
358

            
cleanup
Yuki Kimoto authored on 2011-04-02
359
sub execute {
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
360
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-10-20
361
    my $sql = shift;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
362

            
363
    # Options
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
364
    my $param;
365
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
366
    my %opt = @_;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
367
    warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
368
    $param ||= $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-10-21
369
    my $tables = $opt{table} || [];
cleanup
Yuki Kimoto authored on 2011-04-02
370
    $tables = [$tables] unless ref $tables eq 'ARRAY';
micro optimization
Yuki Kimoto authored on 2011-10-23
371
    my $filter = ref $opt{filter} eq 'ARRAY' ?
372
      _array_to_hash($opt{filter}) : $opt{filter};
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
373
    
micro optimization and
Yuki Kimoto authored on 2011-10-25
374
    # Merge second parameter
375
    my @cleanup;
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
376
    my $saved_param;
micro optimization and
Yuki Kimoto authored on 2011-10-25
377
    if (ref $param eq 'ARRAY') {
378
        my $param2 = $param->[1];
379
        $param = $param->[0];
380
        for my $column (keys %$param2) {
381
            if (!exists $param->{$column}) {
382
                $param->{$column} = $param2->{$column};
383
                push @cleanup, $column;
384
            }
385
            else {
386
                delete $param->{$_} for @cleanup;
387
                @cleanup = ();
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
388
                $saved_param  = $param;
micro optimization and
Yuki Kimoto authored on 2011-10-25
389
                $param = $self->merge_param($param, $param2);
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
390
                delete $saved_param->{$_} for (@{$opt{cleanup} || []});
micro optimization and
Yuki Kimoto authored on 2011-10-25
391
                last;
392
            }
393
        }
394
    }
395
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
396
    # Append
397
    $sql .= $opt{append} if defined $opt{append} && !ref $sql;
398
    
399
    # Query
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
400
    my $query;
micro optimization and
Yuki Kimoto authored on 2011-10-25
401
    if (ref $sql) {
402
        $query = $sql;
403
        warn "execute method receiving query object as first parameter is DEPRECATED!" .
404
             "because this is very buggy.";
405
    }
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
406
    else {
407
        $query = $opt{reuse}->{$sql} if $opt{reuse};
408
        $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter})
409
          unless $query;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
410
        $query->statement($opt{statement} || '');
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
411
        $opt{reuse}->{$sql} = $query if $opt{reuse};
412
    }
413
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
414
    # Save query
micro optimization
Yuki Kimoto authored on 2011-10-23
415
    $self->{last_sql} = $query->{sql};
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
416

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
417
    # Return query
418
    return $query if $opt{query};
micro optimization
Yuki Kimoto authored on 2011-07-30
419
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
420
    # Merge query filter(DEPRECATED!)
DBIx::Custom::Query filter m...
Yuki Kimoto authored on 2011-07-30
421
    $filter ||= $query->{filter} || {};
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
422
    
cleanup
Yuki Kimoto authored on 2011-04-02
423
    # Tables
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
424
    unshift @$tables, @{$query->{tables} || []};
micro optimization
Yuki Kimoto authored on 2011-07-30
425
    my $main_table = @{$tables}[-1];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
426

            
427
    # Merge id to parameter
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
428
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
429
        croak "execute id option must be specified with primary_key option"
430
          unless $opt{primary_key};
431
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
432
        $opt{id} = [$opt{id}] unless ref $opt{id};
433
        my $statement = $query->statement;
434
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
435
           my $key = $opt{primary_key}->[$i];
436
           $key = "$main_table.$key" if $statement eq 'update' ||
437
             $statement eq 'delete' || $statement eq 'select';
438
           next if exists $param->{$key};
439
           $param->{$key} = $opt{id}->[$i];
micro optimization and
Yuki Kimoto authored on 2011-10-25
440
           push @cleanup, $key;1
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
441
        }
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
442
    }
micro optimization
Yuki Kimoto authored on 2011-07-30
443
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
444
    # Cleanup tables(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
445
    $tables = $self->_remove_duplicate_table($tables, $main_table)
446
      if @$tables > 1;
cleanup
Yuki Kimoto authored on 2011-04-02
447
    
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
448
    # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
449
    my $type_filters = {};
micro optimization
Yuki Kimoto authored on 2011-10-23
450
    if ($self->{_type_rule_is_called}) {
451
        unless ($opt{type_rule_off}) {
452
            my $type_rule_off_parts = {
453
                1 => $opt{type_rule1_off},
454
                2 => $opt{type_rule2_off}
455
            };
456
            for my $i (1, 2) {
457
                unless ($type_rule_off_parts->{$i}) {
458
                    $type_filters->{$i} = {};
459
                    my $table_alias = $opt{table_alias} || {};
460
                    for my $alias (keys %$table_alias) {
461
                        my $table = $table_alias->{$alias};
462
                        
463
                        for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
464
                            $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
465
                        }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
466
                    }
micro optimization
Yuki Kimoto authored on 2011-10-23
467
                    $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
468
                      if $main_table;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
469
                }
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
470
            }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
471
        }
472
    }
cleanup
Yuki Kimoto authored on 2011-04-02
473
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
474
    # Applied filter(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
475
    if ($self->{filter}{on}) {
476
        my $applied_filter = {};
cleanup
Yuki Kimoto authored on 2011-10-21
477
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-07-30
478
            $applied_filter = {
479
                %$applied_filter,
480
                %{$self->{filter}{out}->{$table} || {}}
481
            }
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
482
        }
micro optimization
Yuki Kimoto authored on 2011-07-30
483
        $filter = {%$applied_filter, %$filter};
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
484
    }
485
    
cleanup
Yuki Kimoto authored on 2011-04-02
486
    # Replace filter name to code
cleanup
Yuki Kimoto authored on 2011-10-21
487
    for my $column (keys %$filter) {
cleanup
Yuki Kimoto authored on 2011-04-02
488
        my $name = $filter->{$column};
489
        if (!defined $name) {
490
            $filter->{$column} = undef;
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
491
        }
cleanup
Yuki Kimoto authored on 2011-04-02
492
        elsif (ref $name ne 'CODE') {
cleanup
Yuki Kimoto authored on 2011-04-25
493
          croak qq{Filter "$name" is not registered" } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
494
            unless exists $self->filters->{$name};
495
          $filter->{$column} = $self->filters->{$name};
cleanup
Yuki Kimoto authored on 2010-12-21
496
        }
497
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
498
    
cleanup
Yuki Kimoto authored on 2011-04-02
499
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
500
    my ($bind, $bind_types) = $self->_create_bind_values($param, $query->columns,
501
      $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
502

            
cleanup
yuki-kimoto authored on 2010-10-17
503
    # Execute
micro optimization
Yuki Kimoto authored on 2011-10-23
504
    my $sth = $query->{sth};
cleanup
yuki-kimoto authored on 2010-10-17
505
    my $affected;
cleanup
Yuki Kimoto authored on 2011-03-21
506
    eval {
micro optimization
Yuki Kimoto authored on 2011-10-23
507
        if ($opt{bind_type} || $opt{type}) {
508
            $sth->bind_param($_ + 1, $bind->[$_],
509
                $bind_types->[$_] ? $bind_types->[$_] : ())
510
              for (0 .. @$bind - 1);
511
            $affected = $sth->execute;
512
        }
513
        else {
514
            $affected = $sth->execute(@$bind);
515
        }
cleanup
Yuki Kimoto authored on 2011-03-21
516
    };
improved error messages
Yuki Kimoto authored on 2011-04-18
517
    
micro optimization
Yuki Kimoto authored on 2011-07-30
518
    $self->_croak($@, qq{. Following SQL is executed.\n}
519
      . qq{$query->{sql}\n} . _subname) if $@;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
520

            
521
    # Remove id from parameter
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
522
    delete $param->{$_} for (@cleanup, @{$opt{cleanup} || []});
cleanup
yuki-kimoto authored on 2010-10-17
523
    
improved debug message
Yuki Kimoto authored on 2011-05-23
524
    # DEBUG message
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
525
    if ($ENV{DBIX_CUSTOM_DEBUG}) {
526
        warn "SQL:\n" . $query->sql . "\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
527
        my @output;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
528
        for my $value (@$bind) {
improved debug message
Yuki Kimoto authored on 2011-05-23
529
            $value = 'undef' unless defined $value;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
530
            $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
improved debug message
Yuki Kimoto authored on 2011-05-23
531
              if utf8::is_utf8($value);
532
            push @output, $value;
533
        }
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
534
        warn "Bind values: " . join(', ', @output) . "\n\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
535
    }
added environment variable D...
Yuki Kimoto authored on 2011-04-02
536
    
micro optimization
Yuki Kimoto authored on 2011-10-23
537
    # Not select statement
538
    return $affected unless $sth->{NUM_OF_FIELDS};
539

            
540
    # Filter(DEPRECATED!)
541
    my $infilter = {};
542
    if ($self->{filter}{on}) {
543
        $infilter->{in}  = {};
544
        $infilter->{end} = {};
545
        push @$tables, $main_table if $main_table;
546
        for my $table (@$tables) {
547
            for my $way (qw/in end/) {
548
                $infilter->{$way} = {%{$infilter->{$way}},
549
                  %{$self->{filter}{$way}{$table} || {}}};
cleanup
Yuki Kimoto authored on 2011-04-02
550
            }
cleanup
Yuki Kimoto authored on 2011-01-12
551
        }
cleanup
yuki-kimoto authored on 2010-10-17
552
    }
micro optimization
Yuki Kimoto authored on 2011-10-23
553
    
554
    # Result
555
    my $result = $self->result_class->new(
556
        sth => $sth,
557
        dbi => $self,
558
        default_filter => $self->{default_in_filter},
559
        filter => $infilter->{in} || {},
560
        end_filter => $infilter->{end} || {},
561
        type_rule => {
562
            from1 => $self->type_rule->{from1},
563
            from2 => $self->type_rule->{from2}
564
        },
565
    );
566
    $result;
cleanup
yuki-kimoto authored on 2010-10-17
567
}
568

            
added test
Yuki Kimoto authored on 2011-08-16
569
sub get_table_info {
cleanup
Yuki Kimoto authored on 2011-10-21
570
    my ($self, %opt) = @_;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
571
    
cleanup
Yuki Kimoto authored on 2011-10-21
572
    my $exclude = delete $opt{exclude};
573
    croak qq/"$_" is wrong option/ for keys %opt;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
574
    
added test
Yuki Kimoto authored on 2011-08-16
575
    my $table_info = [];
576
    $self->each_table(
577
        sub { push @$table_info, {table => $_[1], info => $_[2] } },
578
        exclude => $exclude
579
    );
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
580
    
cleanup test
Yuki Kimoto authored on 2011-08-16
581
    return [sort {$a->{table} cmp $b->{table} } @$table_info];
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
582
}
583

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
584
sub get_column_info {
cleanup
Yuki Kimoto authored on 2011-10-21
585
    my ($self, %opt) = @_;
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
586
    
cleanup
Yuki Kimoto authored on 2011-10-21
587
    my $exclude_table = delete $opt{exclude_table};
588
    croak qq/"$_" is wrong option/ for keys %opt;
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
589
    
590
    my $column_info = [];
591
    $self->each_column(
592
        sub { push @$column_info, {table => $_[1], column => $_[2], info => $_[3] } },
593
        exclude_table => $exclude_table
594
    );
595
    
596
    return [
597
      sort {$a->{table} cmp $b->{table} || $a->{column} cmp $b->{column} }
cleanup
Yuki Kimoto authored on 2011-08-16
598
        @$column_info];
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
599
}
600

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
601
sub helper {
602
    my $self = shift;
603
    
604
    # Register method
605
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
606
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
607
    
608
    return $self;
609
}
610

            
cleanup
yuki-kimoto authored on 2010-10-17
611
sub insert {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
612
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
613
    
cleanup
Yuki Kimoto authored on 2011-10-21
614
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
615
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
616
    my %opt = @_;
micro optimization
Yuki Kimoto authored on 2011-10-23
617
    warn "insert method param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
618
    $param ||= delete $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
619
    
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
620
    # Timestamp(DEPRECATED!)
cleanup
Yuki Kimoto authored on 2011-10-21
621
    if ($opt{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
622
        warn "insert timestamp option is DEPRECATED! use created_at with now attribute";
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
623
        my $columns = $insert_timestamp->[0];
624
        $columns = [$columns] unless ref $columns eq 'ARRAY';
625
        my $value = $insert_timestamp->[1];
626
        $value = $value->() if ref $value eq 'CODE';
627
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
628
    }
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
629

            
630
    # Created time and updated time
631
    my @timestamp_cleanup;
632
    if (defined $opt{created_at} || defined $opt{updated_at}) {
633
        my $now = $self->now->();
634
        if (defined $opt{created_at}) {
635
            $param->{$opt{created_at}} = $now;
636
            push @timestamp_cleanup, $opt{created_at};
637
        }
638
        if (defined $opt{updated_at}) {
639
            $param->{$opt{updated_at}} = $now;
640
            push @timestamp_cleanup, $opt{updated_at};
641
        }
642
    }
cleanup
Yuki Kimoto authored on 2011-10-21
643
    
644
    # Merge id to parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
645
    my @cleanup;
micro optimization and
Yuki Kimoto authored on 2011-10-25
646
    my $id_param = {};
micro optimization
Yuki Kimoto authored on 2011-10-23
647
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
648
        croak "insert id option must be specified with primary_key option"
micro optimization
Yuki Kimoto authored on 2011-10-23
649
          unless $opt{primary_key};
650
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
651
        $opt{id} = [$opt{id}] unless ref $opt{id};
652
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
653
           my $key = $opt{primary_key}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
654
           next if exists $param->{$key};
micro optimization
Yuki Kimoto authored on 2011-10-23
655
           $param->{$key} = $opt{id}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
656
           push @cleanup, $key;
micro optimization
Yuki Kimoto authored on 2011-10-23
657
        }
658
    }
cleanup
Yuki Kimoto authored on 2011-10-21
659
    
cleanup
Yuki Kimoto authored on 2011-04-02
660
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-10-21
661
    my $sql = "insert ";
cleanup
Yuki Kimoto authored on 2011-10-21
662
    $sql .= "$opt{prefix} " if defined $opt{prefix};
663
    $sql .= "into " . $self->_q($opt{table}) . " "
664
      . $self->values_clause($param, {wrap => $opt{wrap}}) . " ";
micro optimization
Yuki Kimoto authored on 2011-10-23
665

            
666
    # Remove id from parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
667
    delete $param->{$_} for @cleanup;
packaging one directory
yuki-kimoto authored on 2009-11-16
668
    
669
    # Execute query
micro optimization
Yuki Kimoto authored on 2011-10-23
670
    $opt{statement} = 'insert';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
671
    $opt{cleanup} = \@timestamp_cleanup;
micro optimization
Yuki Kimoto authored on 2011-10-23
672
    $self->execute($sql, $param, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
673
}
674

            
micro optimization
Yuki Kimoto authored on 2011-10-23
675
sub _merge_id_to_param {
676
    my ($self, $id, $primary_keys, $param) = @_;
677
    
678
    # Create parameter
679
    $id = [$id] unless ref $id;
680
    
681
    return $param;
682
}
683

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
684
sub insert_timestamp {
685
    my $self = shift;
686
    
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
687
    warn "insert_timestamp method is DEPRECATED! use now attribute";
688
    
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
689
    if (@_) {
690
        $self->{insert_timestamp} = [@_];
691
        
692
        return $self;
693
    }
694
    return $self->{insert_timestamp};
695
}
696

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
697
sub include_model {
698
    my ($self, $name_space, $model_infos) = @_;
699
    
cleanup
Yuki Kimoto authored on 2011-04-02
700
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
701
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
702
    
703
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
704
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
705

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
706
        # Load name space module
cleanup
Yuki Kimoto authored on 2011-04-25
707
        croak qq{"$name_space" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
708
          if $name_space =~ /[^\w:]/;
709
        eval "use $name_space";
cleanup
Yuki Kimoto authored on 2011-04-25
710
        croak qq{Name space module "$name_space.pm" is needed. $@ }
711
            . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
712
          if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
713
        
714
        # Search model modules
715
        my $path = $INC{"$name_space.pm"};
716
        $path =~ s/\.pm$//;
717
        opendir my $dh, $path
cleanup
Yuki Kimoto authored on 2011-04-25
718
          or croak qq{Can't open directory "$path": $! } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
719
        $model_infos = [];
720
        while (my $module = readdir $dh) {
721
            push @$model_infos, $module
722
              if $module =~ s/\.pm$//;
723
        }
724
        close $dh;
725
    }
726
    
cleanup
Yuki Kimoto authored on 2011-04-02
727
    # Include models
cleanup
Yuki Kimoto authored on 2011-10-21
728
    for my $model_info (@$model_infos) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
729
        
cleanup
Yuki Kimoto authored on 2011-04-02
730
        # Load model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
731
        my $model_class;
732
        my $model_name;
733
        my $model_table;
734
        if (ref $model_info eq 'HASH') {
735
            $model_class = $model_info->{class};
736
            $model_name  = $model_info->{name};
737
            $model_table = $model_info->{table};
738
            
739
            $model_name  ||= $model_class;
740
            $model_table ||= $model_name;
741
        }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
742
        else { $model_class = $model_name = $model_table = $model_info }
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
743
        my $mclass = "${name_space}::$model_class";
cleanup
Yuki Kimoto authored on 2011-04-25
744
        croak qq{"$mclass" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
745
          if $mclass =~ /[^\w:]/;
746
        unless ($mclass->can('isa')) {
747
            eval "use $mclass";
cleanup
Yuki Kimoto authored on 2011-04-25
748
            croak "$@ " . _subname if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
749
        }
750
        
cleanup
Yuki Kimoto authored on 2011-04-02
751
        # Create model
cleanup
Yuki Kimoto authored on 2011-10-21
752
        my $opt = {};
753
        $opt->{model_class} = $mclass if $mclass;
754
        $opt->{name}        = $model_name if $model_name;
755
        $opt->{table}       = $model_table if $model_table;
756
        $self->create_model($opt);
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
757
    }
758
    
759
    return $self;
760
}
761

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

            
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
764
sub mapper {
765
    my $self = shift;
766
    return DBIx::Custom::Mapper->new(@_);
767
}
768

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
769
sub merge_param {
770
    my ($self, @params) = @_;
771
    
cleanup
Yuki Kimoto authored on 2011-04-02
772
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
773
    my $merge = {};
cleanup
Yuki Kimoto authored on 2011-10-21
774
    for my $param (@params) {
775
        for my $column (keys %$param) {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
776
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
777
            
778
            if (exists $merge->{$column}) {
779
                $merge->{$column} = [$merge->{$column}]
780
                  unless ref $merge->{$column} eq 'ARRAY';
781
                push @{$merge->{$column}},
782
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
783
            }
784
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
785
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
786
            }
787
        }
788
    }
789
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
790
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
791
}
792

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
793
sub model {
794
    my ($self, $name, $model) = @_;
795
    
cleanup
Yuki Kimoto authored on 2011-04-02
796
    # Set model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
797
    if ($model) {
798
        $self->models->{$name} = $model;
799
        return $self;
800
    }
801
    
802
    # Check model existance
cleanup
Yuki Kimoto authored on 2011-04-25
803
    croak qq{Model "$name" is not included } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
804
      unless $self->models->{$name};
805
    
cleanup
Yuki Kimoto authored on 2011-04-02
806
    # Get model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
807
    return $self->models->{$name};
808
}
809

            
cleanup
Yuki Kimoto authored on 2011-03-21
810
sub mycolumn {
811
    my ($self, $table, $columns) = @_;
812
    
cleanup
Yuki Kimoto authored on 2011-04-02
813
    # Create column clause
814
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
815
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
816
    push @column, $self->_q($table) . "." . $self->_q($_) .
817
      " as " . $self->_q($_)
818
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
819
    
820
    return join (', ', @column);
821
}
822

            
added dbi_options attribute
kimoto authored on 2010-12-20
823
sub new {
824
    my $self = shift->SUPER::new(@_);
825
    
cleanup
Yuki Kimoto authored on 2011-04-02
826
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
827
    my @attrs = keys %$self;
cleanup
Yuki Kimoto authored on 2011-10-21
828
    for my $attr (@attrs) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
829
        croak qq{Invalid attribute: "$attr" } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
830
          unless $self->can($attr);
831
    }
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
832

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
833
    # DEPRECATED
cleanup
Yuki Kimoto authored on 2011-08-13
834
    $self->{_tags} = {
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
835
        '?'     => \&DBIx::Custom::Tag::placeholder,
836
        '='     => \&DBIx::Custom::Tag::equal,
837
        '<>'    => \&DBIx::Custom::Tag::not_equal,
838
        '>'     => \&DBIx::Custom::Tag::greater_than,
839
        '<'     => \&DBIx::Custom::Tag::lower_than,
840
        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
841
        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
842
        'like'  => \&DBIx::Custom::Tag::like,
843
        'in'    => \&DBIx::Custom::Tag::in,
844
        'insert_param' => \&DBIx::Custom::Tag::insert_param,
845
        'update_param' => \&DBIx::Custom::Tag::update_param
cleanup
Yuki Kimoto authored on 2011-08-13
846
    };
847
    
848
    return $self;
849
}
850

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

            
853
sub order {
854
    my $self = shift;
855
    return DBIx::Custom::Order->new(dbi => $self, @_);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
856
}
857

            
cleanup
yuki-kimoto authored on 2010-10-17
858
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
859
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
860
    
861
    # Register filter
862
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
863
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
864
    
cleanup
Yuki Kimoto authored on 2011-04-02
865
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
866
}
packaging one directory
yuki-kimoto authored on 2009-11-16
867

            
868
sub select {
cleanup
Yuki Kimoto authored on 2011-10-21
869
    my ($self, %opt) = @_;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
870

            
cleanup
Yuki Kimoto authored on 2011-10-21
871
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
872
    my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
873
               : defined $opt{table} ? [$opt{table}]
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
874
               : [];
cleanup
Yuki Kimoto authored on 2011-10-21
875
    $opt{table} = $tables;
cleanup
Yuki Kimoto authored on 2011-10-21
876
    my $where_param = $opt{where_param} || delete $opt{param} || {};
select method where_param op...
Yuki Kimoto authored on 2011-10-25
877
    warn "select method where_param option is DEPRECATED!"
878
      if $opt{where_param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
879
    
cleanup
Yuki Kimoto authored on 2011-03-09
880
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
881
    if ($opt{relation}) {
882
        warn "select() relation option is DEPRECATED!";
883
        $self->_add_relation_table($tables, $opt{relation});
884
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
885
    
cleanup
Yuki Kimoto authored on 2011-04-02
886
    # Select statement
micro optimization
Yuki Kimoto authored on 2011-09-30
887
    my $sql = 'select ';
packaging one directory
yuki-kimoto authored on 2009-11-16
888
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
889
    # Prefix
cleanup
Yuki Kimoto authored on 2011-10-21
890
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
891
    
cleanup
Yuki Kimoto authored on 2011-10-21
892
    # Column
cleanup
Yuki Kimoto authored on 2011-10-21
893
    if (defined $opt{column}) {
894
        my $columns
895
          = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
cleanup
Yuki Kimoto authored on 2011-10-21
896
        for my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
897
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
898
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
899
            }
900
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
901
                if (@$column == 3 && $column->[1] eq 'as') {
902
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
903
                    splice @$column, 1, 1;
904
                }
905
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
906
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
907
            }
cleanup
Yuki Kimoto authored on 2011-04-02
908
            unshift @$tables, @{$self->_search_tables($column)};
micro optimization
Yuki Kimoto authored on 2011-09-30
909
            $sql .= "$column, ";
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
910
        }
micro optimization
Yuki Kimoto authored on 2011-09-30
911
        $sql =~ s/, $/ /;
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
912
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
913
    else { $sql .= '* ' }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
914
    
915
    # Table
micro optimization
Yuki Kimoto authored on 2011-09-30
916
    $sql .= 'from ';
cleanup
Yuki Kimoto authored on 2011-10-21
917
    if ($opt{relation}) {
cleanup
Yuki Kimoto authored on 2011-03-30
918
        my $found = {};
cleanup
Yuki Kimoto authored on 2011-10-21
919
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-09-30
920
            $sql .= $self->_q($table) . ', ' unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
921
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
922
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
923
    }
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
924
    else { $sql .= $self->_q($tables->[-1] || '') . ' ' }
micro optimization
Yuki Kimoto authored on 2011-09-30
925
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2011-10-21
926
    croak "select method table option must be specified " . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
927
      unless $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
928

            
cleanup
Yuki Kimoto authored on 2011-04-02
929
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
930
    unshift @$tables,
931
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
932
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
933
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
934
    my $w = $self->_where_clause_and_param($opt{where}, $where_param,
935
      delete $opt{id}, $opt{primary_key}, $tables->[-1]);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
936
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
937
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-10-21
938
    unshift @$tables, @{$self->_search_tables($w->{clause})};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
939
    
cleanup
Yuki Kimoto authored on 2011-10-21
940
    # Join statement
cleanup
Yuki Kimoto authored on 2011-10-21
941
    $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
942
    
cleanup
Yuki Kimoto authored on 2011-03-09
943
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-10-21
944
    $sql .= "$w->{clause} ";
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
945
    
cleanup
Yuki Kimoto authored on 2011-03-08
946
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
947
    $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
cleanup
Yuki Kimoto authored on 2011-10-21
948
      if $opt{relation};
cleanup
Yuki Kimoto authored on 2011-03-08
949
    
packaging one directory
yuki-kimoto authored on 2009-11-16
950
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
951
    $opt{statement} = 'select';
cleanup
Yuki Kimoto authored on 2011-10-21
952
    my $result = $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
953
    
micro optimization
Yuki Kimoto authored on 2011-10-23
954
    $result;
packaging one directory
yuki-kimoto authored on 2009-11-16
955
}
956

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
957
sub setup_model {
958
    my $self = shift;
959
    
cleanup
Yuki Kimoto authored on 2011-04-02
960
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
961
    $self->each_column(
962
        sub {
963
            my ($self, $table, $column, $column_info) = @_;
964
            if (my $model = $self->models->{$table}) {
965
                push @{$model->columns}, $column;
966
            }
967
        }
968
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
969
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
970
}
971

            
update pod
Yuki Kimoto authored on 2011-08-10
972
sub show_datatype {
973
    my ($self, $table) = @_;
974
    croak "Table name must be specified" unless defined $table;
975
    print "$table\n";
976
    
977
    my $result = $self->select(table => $table, where => "'0' <> '0'");
978
    my $sth = $result->sth;
979

            
980
    my $columns = $sth->{NAME};
981
    my $data_types = $sth->{TYPE};
982
    
983
    for (my $i = 0; $i < @$columns; $i++) {
984
        my $column = $columns->[$i];
985
        my $data_type = $data_types->[$i];
986
        print "$column: $data_type\n";
987
    }
988
}
989

            
990
sub show_typename {
991
    my ($self, $t) = @_;
992
    croak "Table name must be specified" unless defined $t;
993
    print "$t\n";
994
    
995
    $self->each_column(sub {
996
        my ($self, $table, $column, $infos) = @_;
997
        return unless $table eq $t;
998
        my $typename = $infos->{TYPE_NAME};
999
        print "$column: $typename\n";
1000
    });
1001
    
1002
    return $self;
1003
}
1004

            
test cleanup
Yuki Kimoto authored on 2011-08-15
1005
sub show_tables {
1006
    my $self = shift;
1007
    
1008
    my %tables;
1009
    $self->each_table(sub { $tables{$_[1]}++ });
1010
    print join("\n", sort keys %tables) . "\n";
1011
    return $self;
1012
}
1013

            
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1014
sub type_rule {
1015
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-23
1016

            
1017
    $self->{_type_rule_is_called} = 1;
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1018
    
1019
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
1020
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1021
        
1022
        # Into
cleanup
Yuki Kimoto authored on 2011-10-21
1023
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1024
            my $into = "into$i";
cleanup
Yuki Kimoto authored on 2011-08-16
1025
            my $exists_into = exists $type_rule->{$into};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1026
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1027
            $self->{type_rule} = $type_rule;
1028
            $self->{"_$into"} = {};
cleanup
Yuki Kimoto authored on 2011-10-21
1029
            for my $type_name (keys %{$type_rule->{$into} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1030
                croak qq{type name of $into section must be lower case}
1031
                  if $type_name =~ /[A-Z]/;
1032
            }
cleanup
Yuki Kimoto authored on 2011-08-16
1033
            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1034
            $self->each_column(sub {
1035
                my ($dbi, $table, $column, $column_info) = @_;
1036
                
1037
                my $type_name = lc $column_info->{TYPE_NAME};
1038
                if ($type_rule->{$into} &&
1039
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1040
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1041
                    return unless exists $type_rule->{$into}->{$type_name};
1042
                    if  (defined $filter && ref $filter ne 'CODE') 
1043
                    {
1044
                        my $fname = $filter;
1045
                        croak qq{Filter "$fname" is not registered" } . _subname
1046
                          unless exists $self->filters->{$fname};
1047
                        
1048
                        $filter = $self->filters->{$fname};
1049
                    }
1050

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1051
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1052
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1053
                }
1054
            });
1055
        }
1056

            
1057
        # From
cleanup
Yuki Kimoto authored on 2011-10-21
1058
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1059
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
cleanup
Yuki Kimoto authored on 2011-10-21
1060
            for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1061
                croak qq{data type of from$i section must be lower case or number}
1062
                  if $data_type =~ /[A-Z]/;
1063
                my $fname = $type_rule->{"from$i"}{$data_type};
1064
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1065
                    croak qq{Filter "$fname" is not registered" } . _subname
1066
                      unless exists $self->filters->{$fname};
1067
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1068
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1069
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1070
            }
1071
        }
1072
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1073
        return $self;
1074
    }
1075
    
1076
    return $self->{type_rule} || {};
1077
}
1078

            
cleanup
yuki-kimoto authored on 2010-10-17
1079
sub update {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1080
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1081

            
cleanup
Yuki Kimoto authored on 2011-10-21
1082
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1083
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
1084
    my %opt = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1085
    warn "update param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
1086
    warn "update method where_param option is DEPRECATED!"
1087
      if $opt{where_param};
cleanup
Yuki Kimoto authored on 2011-10-21
1088
    $param ||= $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1089
    
cleanup
Yuki Kimoto authored on 2011-10-21
1090
    # Don't allow update all rows
1091
    croak qq{update method where option must be specified } . _subname
1092
      if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1093
    
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1094
    # Timestamp(DEPRECATED!)
cleanup
Yuki Kimoto authored on 2011-10-21
1095
    if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
1096
        warn "update timestamp option is DEPRECATED! use updated_at and now method";
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1097
        my $columns = $update_timestamp->[0];
1098
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1099
        my $value = $update_timestamp->[1];
1100
        $value = $value->() if ref $value eq 'CODE';
1101
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1102
    }
1103

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1104
    # Created time and updated time
1105
    my @timestamp_cleanup;
1106
    if (defined $opt{updated_at}) {
1107
        $param->{$opt{updated_at}} = $self->now->();
1108
        push @timestamp_cleanup, $opt{updated_at};
1109
    }
1110

            
cleanup
Yuki Kimoto authored on 2011-10-21
1111
    # Assign clause
cleanup
Yuki Kimoto authored on 2011-10-21
1112
    my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
cleanup
Yuki Kimoto authored on 2011-10-21
1113
    
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1114
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
1115
    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
1116
      delete $opt{id}, $opt{primary_key}, $opt{table});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1117
    
cleanup
Yuki Kimoto authored on 2011-04-02
1118
    # Update statement
cleanup
Yuki Kimoto authored on 2011-10-21
1119
    my $sql = "update ";
1120
    $sql .= "$opt{prefix} " if defined $opt{prefix};
cleanup
Yuki Kimoto authored on 2011-10-21
1121
    $sql .= $self->_q($opt{table}) . " set $assign_clause $w->{clause} ";
cleanup
Yuki Kimoto authored on 2011-01-27
1122
    
cleanup
yuki-kimoto authored on 2010-10-17
1123
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
1124
    $opt{statement} = 'update';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1125
    $opt{cleanup} = \@timestamp_cleanup;
micro optimization and
Yuki Kimoto authored on 2011-10-25
1126
    $self->execute($sql, [$param, $w->{param}], %opt);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1127
}
1128

            
cleanup
yuki-kimoto authored on 2010-10-17
1129
sub update_all { shift->update(allow_update_all => 1, @_) };
1130

            
cleanup
Yuki Kimoto authored on 2011-10-21
1131
sub update_or_insert {
1132
    my $self = shift;
1133

            
cleanup
Yuki Kimoto authored on 2011-10-21
1134
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1135
    my $param  = shift;
1136
    my %opt = @_;
1137
    my $id = $opt{id};
1138
    my $primary_key = $opt{primary_key};
1139
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
1140
    croak "update_or_insert method need primary_key option " .
1141
          "when id is specified" . _subname
1142
      if defined $id && !defined $primary_key;
1143
    my $table  = $opt{table};
1144
    croak qq{"table" option must be specified } . _subname
1145
      unless defined $table;
1146
    my $select_option = $opt{select_option};
1147
    
1148
    my $rows = $self->select(table => $table, id => $id,
1149
        primary_key => $primary_key, %$select_option)->all;
1150
    
1151
    croak "selected row count must be one or zero" . _subname
1152
      if @$rows > 1;
1153
    
1154
    my $row = $rows->[0];
1155
    my @opt = (table => $table);
1156
    push @opt, id => $id, primary_key => $primary_key if defined $id;
1157
    push @opt, %opt;
1158
    
1159
    if ($row) {
1160
        return $self->update($param, @opt);
1161
    }
1162
    else {
1163
        return $self->insert($param, @opt);
1164
    }
1165
}
1166

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1167
sub update_timestamp {
1168
    my $self = shift;
1169
    
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
1170
    warn "update_timestamp method is DEPRECATED! use now method";
1171
    
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1172
    if (@_) {
1173
        $self->{update_timestamp} = [@_];
1174
        
1175
        return $self;
1176
    }
1177
    return $self->{update_timestamp};
1178
}
1179

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1180
sub values_clause {
1181
    my ($self, $param, $opts) = @_;
1182
    
1183
    my $wrap = $opts->{wrap} || {};
1184
    
1185
    # Create insert parameter tag
micro optimization
Yuki Kimoto authored on 2011-10-23
1186
    my $safety = $self->{safety_character} || $self->safety_character;
improved performance
Yuki Kimoto authored on 2011-10-22
1187
    my $qp = $self->_q('');
fixed some quoted bug
Yuki Kimoto authored on 2011-10-22
1188
    my $q = substr($qp, 0, 1) || '';
1189
    my $p = substr($qp, 1, 1) || '';
improved performance
Yuki Kimoto authored on 2011-10-22
1190
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1191
    # Check unsafety keys
1192
    unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
1193
        for my $column (keys %$param) {
1194
            croak qq{"$column" is not safety column name } . _subname
1195
              unless $column =~ /^[$safety\.]+$/;
1196
        }
1197
    }
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1198
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1199
    # values clause(performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
1200
    '(' .
1201
    join(
1202
      ', ',
1203
      map { "$q$_$p" } sort keys %$param
1204
    ) .
1205
    ') values (' .
1206
    join(
1207
      ', ',
1208
      map {
1209
          ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1210
          $wrap->{$_} ? $wrap->{$_}->(":$_") :
1211
          ":$_";
1212
      } sort keys %$param
1213
    ) .
1214
    ')'
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1215
}
1216

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1219
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1220
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1221
    my ($self, $source, $after_build_sql) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1222
    
updated pod
Yuki Kimoto authored on 2011-06-21
1223
    # Cache
1224
    my $cache = $self->cache;
1225
    
1226
    # Query
1227
    my $query;
1228
    
1229
    # Get cached query
1230
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1231
        
updated pod
Yuki Kimoto authored on 2011-06-21
1232
        # Get query
1233
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1234
        
updated pod
Yuki Kimoto authored on 2011-06-21
1235
        # Create query
1236
        if ($q) {
1237
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1238
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1239
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1240
    }
1241
    
1242
    # Create query
1243
    unless ($query) {
1244

            
1245
        # Create query
1246
        my $builder = $self->query_builder;
1247
        $query = $builder->build_query($source);
1248

            
1249
        # Remove reserved word quote
1250
        if (my $q = $self->_quote) {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1251
            $q = quotemeta($q);
1252
            $_ =~ s/[$q]//g for @{$query->columns}
cleanup
Yuki Kimoto authored on 2011-06-13
1253
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1254

            
1255
        # Save query to cache
1256
        $self->cache_method->(
1257
            $self, $source,
1258
            {
1259
                sql     => $query->sql, 
1260
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1261
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1262
            }
1263
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1264
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1265

            
1266
    # Filter SQL
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1267
    if ($after_build_sql) {
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1268
        my $sql = $query->sql;
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1269
        $sql = $after_build_sql->($sql);
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1270
        $query->sql($sql);
1271
    }
1272
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1273
    # Save sql
1274
    $self->last_sql($query->sql);
1275
    
updated pod
Yuki Kimoto authored on 2011-06-21
1276
    # Prepare statement handle
1277
    my $sth;
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1278
    eval { $sth = $self->dbh->prepare($query->{sql}) };
updated pod
Yuki Kimoto authored on 2011-06-21
1279
    
1280
    if ($@) {
1281
        $self->_croak($@, qq{. Following SQL is executed.\n}
1282
                        . qq{$query->{sql}\n} . _subname);
1283
    }
1284
    
1285
    # Set statement handle
1286
    $query->sth($sth);
1287
    
1288
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1289
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1290
    
1291
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1292
}
1293

            
cleanup
Yuki Kimoto authored on 2011-04-02
1294
sub _create_bind_values {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1295
    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1296
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1297
    $bind_type = _array_to_hash($bind_type) if ref $bind_type eq 'ARRAY';
1298
    
cleanup
Yuki Kimoto authored on 2011-04-02
1299
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
1300
    my @bind;
1301
    my @types;
1302
    my %count;
1303
    my %not_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1304
    for my $column (@$columns) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
1305
        
micro optimization
Yuki Kimoto authored on 2011-10-23
1306
        # Bind value
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1307
        if(ref $params->{$column} eq 'ARRAY') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1308
            my $i = $count{$column} || 0;
1309
            $i += $not_exists{$column} || 0;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1310
            my $found;
1311
            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1312
                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1313
                    $not_exists{$column}++;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1314
                }
1315
                else  {
micro optimization
Yuki Kimoto authored on 2011-10-23
1316
                    push @bind, $params->{$column}->[$k];
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1317
                    $found = 1;
1318
                    last
1319
                }
1320
            }
1321
            next unless $found;
1322
        }
micro optimization
Yuki Kimoto authored on 2011-10-23
1323
        else { push @bind, $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1324
        
cleanup
Yuki Kimoto authored on 2011-01-12
1325
        # Filter
micro optimization
Yuki Kimoto authored on 2011-10-23
1326
        if (my $f = $filter->{$column} || $self->{default_out_filter} || '') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1327
            $bind[-1] = $f->($bind[-1]);
micro optimization
Yuki Kimoto authored on 2011-10-23
1328
        }
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1329
        
1330
        # Type rule
micro optimization
Yuki Kimoto authored on 2011-10-23
1331
        if ($self->{_type_rule_is_called}) {
1332
            my $tf1 = $self->{"_into1"}->{dot}->{$column}
1333
              || $type_filters->{1}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1334
            $bind[-1] = $tf1->($bind[-1]) if $tf1;
micro optimization
Yuki Kimoto authored on 2011-10-23
1335
            my $tf2 = $self->{"_into2"}->{dot}->{$column}
1336
              || $type_filters->{2}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1337
            $bind[-1] = $tf2->($bind[-1]) if $tf2;
micro optimization
Yuki Kimoto authored on 2011-10-23
1338
        }
micro optimization
Yuki Kimoto authored on 2011-10-22
1339
       
micro optimization
Yuki Kimoto authored on 2011-10-23
1340
        # Bind types
micro optimization
Yuki Kimoto authored on 2011-10-23
1341
        push @types, $bind_type->{$column};
removed reconnect method
yuki-kimoto authored on 2010-05-28
1342
        
1343
        # Count up 
micro optimization
Yuki Kimoto authored on 2011-10-23
1344
        $count{$column}++;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1345
    }
1346
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1347
    return (\@bind, \@types);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1348
}
1349

            
cleanup
Yuki Kimoto authored on 2011-10-21
1350
sub _id_to_param {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1351
    my ($self, $id, $primary_keys, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1352
    
1353
    # Check primary key
cleanup
Yuki Kimoto authored on 2011-10-21
1354
    croak "primary_key option " .
1355
          "must be specified with id option " . _subname
1356
      unless defined $primary_keys;
1357
    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
improved error messages
Yuki Kimoto authored on 2011-04-18
1358
    
cleanup
Yuki Kimoto authored on 2011-06-08
1359
    # Create parameter
1360
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1361
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1362
        $id = [$id] unless ref $id;
1363
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1364
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1365
          unless !ref $id || ref $id eq 'ARRAY';
1366
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1367
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1368
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1369
        for(my $i = 0; $i < @$primary_keys; $i ++) {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1370
           my $key = $primary_keys->[$i];
1371
           $key = "$table." . $key if $table;
1372
           $param->{$key} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1373
        }
1374
    }
1375
    
cleanup
Yuki Kimoto authored on 2011-06-08
1376
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1377
}
1378

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1379
sub _connect {
1380
    my $self = shift;
1381
    
1382
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1383
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1384
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1385
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1386
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1387
    croak qq{"dsn" must be specified } . _subname
1388
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1389
    my $user        = $self->user;
1390
    my $password    = $self->password;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1391
    my $option = $self->_option;
1392
    $option = {%{$self->default_option}, %$option};
cleanup
Yuki Kimoto authored on 2011-08-16
1393
    
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1394
    # Connect
cleanup
Yuki Kimoto authored on 2011-08-16
1395
    my $dbh;
1396
    eval {
1397
        $dbh = DBI->connect(
1398
            $dsn,
1399
            $user,
1400
            $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1401
            $option
cleanup
Yuki Kimoto authored on 2011-08-16
1402
        );
1403
    };
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1404
    
1405
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1406
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1407
    
1408
    return $dbh;
1409
}
1410

            
cleanup
yuki-kimoto authored on 2010-10-17
1411
sub _croak {
1412
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1413
    
1414
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1415
    $append ||= "";
1416
    
1417
    # Verbose
1418
    if ($Carp::Verbose) { croak $error }
1419
    
1420
    # Not verbose
1421
    else {
1422
        
1423
        # Remove line and module infromation
1424
        my $at_pos = rindex($error, ' at ');
1425
        $error = substr($error, 0, $at_pos);
1426
        $error =~ s/\s+$//;
1427
        croak "$error$append";
1428
    }
1429
}
1430

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1433
sub _need_tables {
1434
    my ($self, $tree, $need_tables, $tables) = @_;
1435
    
cleanup
Yuki Kimoto authored on 2011-04-02
1436
    # Get needed tables
cleanup
Yuki Kimoto authored on 2011-10-21
1437
    for my $table (@$tables) {
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1438
        if ($tree->{$table}) {
1439
            $need_tables->{$table} = 1;
1440
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1441
        }
1442
    }
1443
}
1444

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1445
sub _option {
1446
    my $self = shift;
1447
    my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1448
    warn "dbi_options is DEPRECATED! use option instead\n"
1449
      if keys %{$self->dbi_options};
1450
    warn "dbi_option is DEPRECATED! use option instead\n"
1451
      if keys %{$self->dbi_option};
1452
    return $option;
1453
}
1454

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1455
sub _push_join {
1456
    my ($self, $sql, $join, $join_tables) = @_;
1457
    
cleanup
Yuki Kimoto authored on 2011-10-21
1458
    $join = [$join] unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-10-21
1459
    
cleanup
Yuki Kimoto authored on 2011-04-02
1460
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1461
    return unless @$join;
1462
    
cleanup
Yuki Kimoto authored on 2011-04-02
1463
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1464
    my $tree = {};
1465
    for (my $i = 0; $i < @$join; $i++) {
1466
        
cleanup
Yuki Kimoto authored on 2011-07-28
1467
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1468
        my $join_clause;;
1469
        my $option;
1470
        if (ref $join->[$i] eq 'HASH') {
1471
            $join_clause = $join->[$i]->{clause};
1472
            $option = {table => $join->[$i]->{table}};
1473
        }
1474
        else {
1475
            $join_clause = $join->[$i];
1476
            $option = {};
1477
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1478

            
1479
        # Find tables in join clause
added join new syntax
Yuki Kimoto authored on 2011-07-28
1480
        my $table1;
1481
        my $table2;
1482
        if (my $table = $option->{table}) {
1483
            $table1 = $table->[0];
1484
            $table2 = $table->[1];
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1485
        }
cleanup
Yuki Kimoto authored on 2011-07-28
1486
        else {
1487
            my $q = $self->_quote;
1488
            my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1489
            $j_clause =~ s/'.+?'//g;
1490
            my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1491
            $j_clause =~ s/[$q_re]//g;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1492
            
1493
            my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
cleanup
Yuki Kimoto authored on 2011-07-28
1494
            my $c = $self->safety_character;
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1495
            my $join_re = qr/($c+)\.$c+[^$c].*?($c+)\.$c+/sm;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1496
            for my $clause (@j_clauses) {
1497
                if ($clause =~ $join_re) {
1498
                    $table1 = $1;
1499
                    $table2 = $2;
1500
                    last;
1501
                }                
cleanup
Yuki Kimoto authored on 2011-07-28
1502
            }
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1503
        }
added join new syntax
Yuki Kimoto authored on 2011-07-28
1504
        croak qq{join clause must have two table name after "on" keyword. } .
1505
              qq{"$join_clause" is passed }  . _subname
1506
          unless defined $table1 && defined $table2;
1507
        croak qq{right side table of "$join_clause" must be unique }
1508
            . _subname
1509
          if exists $tree->{$table2};
1510
        croak qq{Same table "$table1" is specified} . _subname
1511
          if $table1 eq $table2;
1512
        $tree->{$table2}
1513
          = {position => $i, parent => $table1, join => $join_clause};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1514
    }
1515
    
cleanup
Yuki Kimoto authored on 2011-04-02
1516
    # Search need tables
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1517
    my $need_tables = {};
1518
    $self->_need_tables($tree, $need_tables, $join_tables);
cleanup
Yuki Kimoto authored on 2011-10-21
1519
    my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} }
1520
      keys %$need_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1521
    
1522
    # Add join clause
cleanup
Yuki Kimoto authored on 2011-10-21
1523
    $$sql .= $tree->{$_}{join} . ' ' for @need_tables;
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1524
}
cleanup
Yuki Kimoto authored on 2011-03-08
1525

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1526
sub _quote {
1527
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-22
1528
    return $self->{reserved_word_quote} || $self->quote || '';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1529
}
1530

            
cleanup
Yuki Kimoto authored on 2011-07-29
1531
sub _q {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1532
    my ($self, $value, $quotemeta) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1533
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1534
    my $quote = $self->{reserved_word_quote}
1535
      || $self->{quote} || $self->quote || '';
1536
    return "$quote$value$quote"
1537
      if !$quotemeta && ($quote eq '`' || $quote eq '"');
1538
    
cleanup
Yuki Kimoto authored on 2011-07-29
1539
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1540
    my $p;
1541
    if (defined $quote && length $quote > 1) {
1542
        $p = substr($quote, 1, 1);
1543
    }
1544
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1545
    
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1546
    if ($quotemeta) {
1547
        $q = quotemeta($q);
1548
        $p = quotemeta($p);
1549
    }
1550
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1551
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1552
}
1553

            
cleanup
Yuki Kimoto authored on 2011-04-02
1554
sub _remove_duplicate_table {
1555
    my ($self, $tables, $main_table) = @_;
1556
    
1557
    # Remove duplicate table
1558
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1559
    delete $tables{$main_table} if $main_table;
1560
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1561
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1562
    if (my $q = $self->_quote) {
1563
        $q = quotemeta($q);
1564
        $_ =~ s/[$q]//g for @$new_tables;
1565
    }
1566

            
1567
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1568
}
1569

            
cleanup
Yuki Kimoto authored on 2011-04-02
1570
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1571
    my ($self, $source) = @_;
1572
    
cleanup
Yuki Kimoto authored on 2011-04-02
1573
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1574
    my $tables = [];
1575
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1576
    my $q = $self->_quote;
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1577
    my $quoted_safety_character_re = $self->_q("?([$safety_character]+)", 1);
1578
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1579
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1580
    while ($source =~ /$table_re/g) {
1581
        push @$tables, $1;
1582
    }
1583
    
1584
    return $tables;
1585
}
1586

            
cleanup
Yuki Kimoto authored on 2011-10-21
1587
sub _where_clause_and_param {
cleanup
Yuki Kimoto authored on 2011-10-25
1588
    my ($self, $where, $where_param, $id, $primary_key, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-25
1589

            
cleanup
Yuki Kimoto authored on 2011-10-21
1590
    $where ||= {};
cleanup
Yuki Kimoto authored on 2011-10-25
1591
    $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
cleanup
Yuki Kimoto authored on 2011-10-25
1592
    $where_param ||= {};
cleanup
Yuki Kimoto authored on 2011-10-21
1593
    my $w = {};
1594
    my $where_clause = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1595

            
cleanup
Yuki Kimoto authored on 2011-10-25
1596
    my $obj;
1597
    
cleanup
Yuki Kimoto authored on 2011-10-21
1598
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1599
        $w->{clause} = "where " . $where->[0];
1600
        $w->{param} = $where->[1];
1601
    }
1602
    elsif (ref $where) {
cleanup
Yuki Kimoto authored on 2011-10-25
1603

            
1604
        # Hash
1605
        if (ref $where eq 'HASH') {
1606
            my $clause = ['and'];
1607
            my $q = $self->_quote;
1608
            for my $column (keys %$where) {
1609
                my $table;
1610
                my $c;
1611
                if ($column =~ /(?:(.*?)\.)?(.*)/) {
1612
                    $table = $1;
1613
                    $c = $2;
1614
                }
1615
                
1616
                my $table_quote;
1617
                $table_quote = $self->_q($table) if defined $table;
1618
                my $column_quote = $self->_q($c);
1619
                $column_quote = $table_quote . '.' . $column_quote
1620
                  if defined $table_quote;
1621
                push @$clause, "$column_quote = :$column" for keys %$where;
1622
            }
1623
            $obj = $self->where(clause => $clause, param => $where);
1624
        }
1625
        
1626
        # DBIx::Custom::Where object
1627
        elsif (ref $where eq 'DBIx::Custom::Where') {
1628
            $obj = $where;
1629
        }
1630
        
1631
        # Array
1632
        elsif (ref $where eq 'ARRAY') {
1633
            $obj = $self->where(
1634
                clause => $where->[0],
1635
                param  => $where->[1]
1636
            );
1637
        }
1638
        
1639
        # Check where argument
1640
        croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1641
            . qq{or array reference, which contains where clause and parameter}
1642
            . _subname
1643
          unless ref $obj eq 'DBIx::Custom::Where';
1644

            
1645

            
1646
        $w->{param} = keys %$where_param
1647
                    ? $self->merge_param($where_param, $obj->param)
1648
                    : $obj->param;
1649
        $w->{clause} = $obj->to_string;
cleanup
Yuki Kimoto authored on 2011-10-21
1650
    }
1651
    elsif ($where) {
1652
        $w->{clause} = "where $where";
cleanup
Yuki Kimoto authored on 2011-10-25
1653
        $w->{param} = $where_param;
cleanup
Yuki Kimoto authored on 2011-10-21
1654
    }
1655
    
1656
    return $w;
1657
}
1658

            
updated pod
Yuki Kimoto authored on 2011-06-21
1659
sub _apply_filter {
1660
    my ($self, $table, @cinfos) = @_;
1661

            
1662
    # Initialize filters
1663
    $self->{filter} ||= {};
micro optimization
Yuki Kimoto authored on 2011-07-30
1664
    $self->{filter}{on} = 1;
updated pod
Yuki Kimoto authored on 2011-06-21
1665
    $self->{filter}{out} ||= {};
1666
    $self->{filter}{in} ||= {};
1667
    $self->{filter}{end} ||= {};
1668
    
1669
    # Usage
1670
    my $usage = "Usage: \$dbi->apply_filter(" .
1671
                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1672
                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1673
    
1674
    # Apply filter
1675
    for (my $i = 0; $i < @cinfos; $i += 2) {
1676
        
1677
        # Column
1678
        my $column = $cinfos[$i];
1679
        if (ref $column eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-10-21
1680
            for my $c (@$column) {
updated pod
Yuki Kimoto authored on 2011-06-21
1681
                push @cinfos, $c, $cinfos[$i + 1];
1682
            }
1683
            next;
1684
        }
1685
        
1686
        # Filter infomation
1687
        my $finfo = $cinfos[$i + 1] || {};
1688
        croak "$usage (table: $table) " . _subname
1689
          unless  ref $finfo eq 'HASH';
cleanup
Yuki Kimoto authored on 2011-10-21
1690
        for my $ftype (keys %$finfo) {
updated pod
Yuki Kimoto authored on 2011-06-21
1691
            croak "$usage (table: $table) " . _subname
1692
              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1693
        }
1694
        
1695
        # Set filters
cleanup
Yuki Kimoto authored on 2011-10-21
1696
        for my $way (qw/in out end/) {
updated pod
Yuki Kimoto authored on 2011-06-21
1697
        
1698
            # Filter
1699
            my $filter = $finfo->{$way};
1700
            
1701
            # Filter state
1702
            my $state = !exists $finfo->{$way} ? 'not_exists'
1703
                      : !defined $filter        ? 'not_defined'
1704
                      : ref $filter eq 'CODE'   ? 'code'
1705
                      : 'name';
1706
            
1707
            # Filter is not exists
1708
            next if $state eq 'not_exists';
1709
            
1710
            # Check filter name
1711
            croak qq{Filter "$filter" is not registered } . _subname
1712
              if  $state eq 'name'
1713
               && ! exists $self->filters->{$filter};
1714
            
1715
            # Set filter
1716
            my $f = $state eq 'not_defined' ? undef
1717
                  : $state eq 'code'        ? $filter
1718
                  : $self->filters->{$filter};
1719
            $self->{filter}{$way}{$table}{$column} = $f;
1720
            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1721
            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1722
            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1723
        }
1724
    }
1725
    
1726
    return $self;
1727
}
1728

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1729
# DEPRECATED!
1730
has 'data_source';
1731
has dbi_options => sub { {} };
1732
has filter_check  => 1;
1733
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1734
has dbi_option => sub { {} };
1735
has default_dbi_option => sub {
1736
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1737
    return shift->default_option;
1738
};
1739

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1740
# DEPRECATED!
1741
sub method {
1742
    warn "method is DEPRECATED! use helper instead";
1743
    return shift->helper(@_);
1744
}
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1745

            
1746
# DEPRECATED!
1747
sub assign_param {
1748
    my $self = shift;
1749
    warn "assing_param is DEPRECATED! use assign_clause instead";
1750
    return $self->assign_clause(@_);
1751
}
1752

            
1753
# DEPRECATED
1754
sub update_param {
1755
    my ($self, $param, $opts) = @_;
1756
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1757
    warn "update_param is DEPRECATED! use assign_clause instead.";
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1758
    
1759
    # Create update parameter tag
1760
    my $tag = $self->assign_clause($param, $opts);
1761
    $tag = "set $tag" unless $opts->{no_set};
1762

            
1763
    return $tag;
1764
}
1765

            
updated pod
Yuki Kimoto authored on 2011-06-21
1766
# DEPRECATED!
1767
sub create_query {
1768
    warn "create_query is DEPRECATED! use query option of each method";
1769
    shift->_create_query(@_);
1770
}
1771

            
cleanup
Yuki Kimoto authored on 2011-06-13
1772
# DEPRECATED!
1773
sub apply_filter {
1774
    my $self = shift;
1775
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1776
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1777
    return $self->_apply_filter(@_);
1778
}
1779

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1780
# DEPRECATED!
1781
sub select_at {
cleanup
Yuki Kimoto authored on 2011-10-21
1782
    my ($self, %opt) = @_;
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1783

            
cleanup
Yuki Kimoto authored on 2011-10-21
1784
    warn "select_at is DEPRECATED! use select method id option instead";
updated pod
Yuki Kimoto authored on 2011-06-08
1785

            
cleanup
Yuki Kimoto authored on 2011-10-21
1786
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1787
    my $primary_keys = delete $opt{primary_key};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1788
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1789
    my $where = delete $opt{where};
1790
    my $param = delete $opt{param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1791
    
1792
    # Table
1793
    croak qq{"table" option must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1794
      unless $opt{table};
1795
    my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1796
    
1797
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1798
    my $where_param = $self->_id_to_param($where, $primary_keys);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1799
    
cleanup
Yuki Kimoto authored on 2011-10-21
1800
    return $self->select(where => $where_param, %opt);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1801
}
1802

            
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1803
# DEPRECATED!
1804
sub delete_at {
cleanup
Yuki Kimoto authored on 2011-10-21
1805
    my ($self, %opt) = @_;
updated pod
Yuki Kimoto authored on 2011-06-08
1806

            
cleanup
Yuki Kimoto authored on 2011-10-21
1807
    warn "delete_at is DEPRECATED! use delete method id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1808
    
cleanup
Yuki Kimoto authored on 2011-10-21
1809
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1810
    my $primary_keys = delete $opt{primary_key};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1811
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1812
    my $where = delete $opt{where};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1813
    
1814
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1815
    my $where_param = $self->_id_to_param($where, $primary_keys);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1816
    
cleanup
Yuki Kimoto authored on 2011-10-21
1817
    return $self->delete(where => $where_param, %opt);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1818
}
1819

            
cleanup
Yuki Kimoto authored on 2011-06-08
1820
# DEPRECATED!
1821
sub update_at {
1822
    my $self = shift;
1823

            
cleanup
Yuki Kimoto authored on 2011-10-21
1824
    warn "update_at is DEPRECATED! use update method id option instead";
cleanup
Yuki Kimoto authored on 2011-06-08
1825
    
cleanup
Yuki Kimoto authored on 2011-10-21
1826
    # Options
cleanup
Yuki Kimoto authored on 2011-06-08
1827
    my $param;
1828
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1829
    my %opt = @_;
1830
    my $primary_keys = delete $opt{primary_key};
cleanup
Yuki Kimoto authored on 2011-06-08
1831
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1832
    my $where = delete $opt{where};
1833
    my $p = delete $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-06-08
1834
    $param  ||= $p;
1835
    
1836
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1837
    my $where_param = $self->_id_to_param($where, $primary_keys);
cleanup
Yuki Kimoto authored on 2011-06-08
1838
    
cleanup
Yuki Kimoto authored on 2011-10-21
1839
    return $self->update(where => $where_param, param => $param, %opt);
cleanup
Yuki Kimoto authored on 2011-06-08
1840
}
1841

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1842
# DEPRECATED!
1843
sub insert_at {
1844
    my $self = shift;
1845
    
cleanup
Yuki Kimoto authored on 2011-10-21
1846
    warn "insert_at is DEPRECATED! use insert method id option instead";
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1847
    
cleanup
Yuki Kimoto authored on 2011-10-21
1848
    # Options
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1849
    my $param;
1850
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1851
    my %opt = @_;
1852
    my $primary_key = delete $opt{primary_key};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1853
    $primary_key = [$primary_key] unless ref $primary_key;
cleanup
Yuki Kimoto authored on 2011-10-21
1854
    my $where = delete $opt{where};
1855
    my $p = delete $opt{param} || {};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1856
    $param  ||= $p;
1857
    
1858
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1859
    my $where_param = $self->_id_to_param($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1860
    $param = $self->merge_param($where_param, $param);
1861
    
cleanup
Yuki Kimoto authored on 2011-10-21
1862
    return $self->insert(param => $param, %opt);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1863
}
1864

            
added warnings
Yuki Kimoto authored on 2011-06-07
1865
# DEPRECATED!
1866
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1867
    my $self = shift;
1868
    
added warnings
Yuki Kimoto authored on 2011-06-07
1869
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1870
    
1871
    # Merge tag
1872
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1873
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1874
    
1875
    return $self;
1876
}
1877

            
1878
# DEPRECATED!
1879
sub register_tag_processor {
1880
    my $self = shift;
1881
    warn "register_tag_processor is DEPRECATED!";
1882
    # Merge tag
1883
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1884
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1885
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1886
}
1887

            
cleanup
Yuki Kimoto authored on 2011-01-25
1888
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1889
sub default_bind_filter {
1890
    my $self = shift;
1891
    
cleanup
Yuki Kimoto authored on 2011-06-13
1892
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1893
    
cleanup
Yuki Kimoto authored on 2011-01-12
1894
    if (@_) {
1895
        my $fname = $_[0];
1896
        
1897
        if (@_ && !$fname) {
1898
            $self->{default_out_filter} = undef;
1899
        }
1900
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1901
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1902
              unless exists $self->filters->{$fname};
1903
        
1904
            $self->{default_out_filter} = $self->filters->{$fname};
1905
        }
1906
        return $self;
1907
    }
1908
    
1909
    return $self->{default_out_filter};
1910
}
1911

            
cleanup
Yuki Kimoto authored on 2011-01-25
1912
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1913
sub default_fetch_filter {
1914
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1915

            
cleanup
Yuki Kimoto authored on 2011-06-13
1916
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1917
    
1918
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1919
        my $fname = $_[0];
1920

            
cleanup
Yuki Kimoto authored on 2011-01-12
1921
        if (@_ && !$fname) {
1922
            $self->{default_in_filter} = undef;
1923
        }
1924
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1925
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1926
              unless exists $self->filters->{$fname};
1927
        
1928
            $self->{default_in_filter} = $self->filters->{$fname};
1929
        }
1930
        
1931
        return $self;
1932
    }
1933
    
many changed
Yuki Kimoto authored on 2011-01-23
1934
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1935
}
1936

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1937
# DEPRECATED!
1938
sub insert_param {
1939
    my $self = shift;
1940
    warn "insert_param is DEPRECATED! use values_clause instead";
1941
    return $self->values_clause(@_);
1942
}
1943

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1944
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1945
sub insert_param_tag {
1946
    warn "insert_param_tag is DEPRECATED! " .
1947
         "use insert_param instead!";
1948
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1949
}
1950

            
1951
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1952
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1953
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1954
         "use update_param instead";
1955
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1956
}
cleanup
Yuki Kimoto authored on 2011-03-08
1957
# DEPRECATED!
1958
sub _push_relation {
1959
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1960
    
1961
    if (keys %{$relation || {}}) {
micro optimization
Yuki Kimoto authored on 2011-09-30
1962
        $$sql .= $need_where ? 'where ' : 'and ';
cleanup
Yuki Kimoto authored on 2011-10-21
1963
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1964
            my $table1 = (split (/\./, $rcolumn))[0];
1965
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1966
            push @$tables, ($table1, $table2);
micro optimization
Yuki Kimoto authored on 2011-09-30
1967
            $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
cleanup
Yuki Kimoto authored on 2011-03-08
1968
        }
1969
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
1970
    $$sql =~ s/and $/ /;
cleanup
Yuki Kimoto authored on 2011-03-08
1971
}
1972

            
1973
# DEPRECATED!
1974
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1975
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1976
    
1977
    if (keys %{$relation || {}}) {
cleanup
Yuki Kimoto authored on 2011-10-21
1978
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1979
            my $table1 = (split (/\./, $rcolumn))[0];
1980
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1981
            my $table1_exists;
1982
            my $table2_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1983
            for my $table (@$tables) {
cleanup
Yuki Kimoto authored on 2011-03-08
1984
                $table1_exists = 1 if $table eq $table1;
1985
                $table2_exists = 1 if $table eq $table2;
1986
            }
1987
            unshift @$tables, $table1 unless $table1_exists;
1988
            unshift @$tables, $table2 unless $table2_exists;
1989
        }
1990
    }
1991
}
1992

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1995
=head1 NAME
1996

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

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

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
2001
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2002
    
2003
    # Connect
2004
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2005
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2006
        user => 'ken',
2007
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2008
        option => {mysql_enable_utf8 => 1}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2009
    );
cleanup
yuki-kimoto authored on 2010-08-05
2010

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
2011
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
2012
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
2013
    
2014
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
2015
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
2016
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
2017
    
2018
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
2019
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
2020

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
2021
    # Select
updated pod
Yuki Kimoto authored on 2011-06-21
2022
    my $result = $dbi->select(table  => 'book',
2023
      column => ['title', 'author'], where  => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
2024

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2025
    # Select, more complex
2026
    my $result = $dbi->select(
2027
        table  => 'book',
2028
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
2029
            {book => [qw/title author/]},
2030
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2031
        ],
2032
        where  => {'book.author' => 'Ken'},
2033
        join => ['left outer join company on book.company_id = company.id'],
2034
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
2035
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2036
    
removed register_format()
yuki-kimoto authored on 2010-05-26
2037
    # Fetch
2038
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2039
        
removed register_format()
yuki-kimoto authored on 2010-05-26
2040
    }
2041
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2042
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
2043
    while (my $row = $result->fetch_hash) {
2044
        
2045
    }
2046
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2047
    # Execute SQL with parameter.
2048
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2049
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
2050
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2051
    );
2052
    
fix heading typos
Terrence Brannon authored on 2011-08-17
2053
=head1 DESCRIPTION
removed reconnect method
yuki-kimoto authored on 2010-05-28
2054

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2070
Named place holder support
2071

            
2072
=item *
2073

            
cleanup
Yuki Kimoto authored on 2011-07-29
2074
Model support
2075

            
2076
=item *
2077

            
2078
Connection manager support
2079

            
2080
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2081

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

            
2086
=item *
2087

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

            
2090
=item *
2091

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

            
2094
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2095

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2103
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2104
L<DBIx::Custom::Result>,
2105
L<DBIx::Custom::Query>,
2106
L<DBIx::Custom::Where>,
2107
L<DBIx::Custom::Model>,
2108
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2109

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

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

            
2114
    my $connector = $dbi->connector;
micro optimization
Yuki Kimoto authored on 2011-07-30
2115
    $dbi = $dbi->connector($connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2116

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

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

            
2123
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2124
        "dbi:mysql:database=$database",
2125
        $user,
2126
        $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2127
        DBIx::Custom->new->default_option
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2128
    );
2129
    
updated pod
Yuki Kimoto authored on 2011-06-21
2130
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2131

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

            
2135
    my $dbi = DBIx::Custom->connect(
2136
      dsn => $dsn, user => $user, password => $password, connector => 1);
2137
    
2138
    my $connector = $dbi->connector; # DBIx::Connector
2139

            
2140
Note that L<DBIx::Connector> must be installed.
2141

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

            
2144
    my $dsn = $dbi->dsn;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2145
    $dbi = $dbi->dsn("DBI:mysql:database=dbname");
packaging one directory
yuki-kimoto authored on 2009-11-16
2146

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

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

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2151
    my $default_option = $dbi->default_option;
2152
    $dbi = $dbi->default_option($default_option);
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
2153

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2157
    {
2158
        RaiseError => 1,
2159
        PrintError => 0,
2160
        AutoCommit => 1,
2161
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2162

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

            
2165
    my $exclude_table = $dbi->exclude_table;
2166
    $dbi = $dbi->exclude_table(qr/pg_/);
2167

            
2168
Excluded table regex.
2169
C<each_column>, C<each_table>, C<type_rule>,
2170
and C<setup_model> methods ignore matching tables.
2171

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2174
    my $filters = $dbi->filters;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2175
    $dbi = $dbi->filters(\%filters);
packaging one directory
yuki-kimoto authored on 2009-11-16
2176

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

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

            
2181
    my $last_sql = $dbi->last_sql;
2182
    $dbi = $dbi->last_sql($last_sql);
2183

            
2184
Get last successed SQL executed by C<execute> method.
2185

            
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2186
=head2 C<now EXPERIMENTAL>
2187

            
2188
    my $now = $dbi->now;
2189
    $dbi = $dbi->now($now);
2190

            
2191
Code reference which return time now, default to the following code reference.
2192

            
2193
    sub {
2194
        my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2195
        $mon++;
2196
        $year += 1900;
2197
        return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2198
    }
2199

            
2200
This return the time like "2011-10-14 05:05:27".
2201

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

            
2204
    my $models = $dbi->models;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2205
    $dbi = $dbi->models(\%models);
add models() attribute
Yuki Kimoto authored on 2011-02-21
2206

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

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

            
2211
    my $option = $dbi->option;
2212
    $dbi = $dbi->option($option);
2213

            
2214
L<DBI> option, used when C<connect> method is executed.
2215
Each value in option override the value of C<default_option>.
2216

            
cleanup
yuki-kimoto authored on 2010-10-17
2217
=head2 C<password>
2218

            
2219
    my $password = $dbi->password;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2220
    $dbi = $dbi->password('lkj&le`@s');
cleanup
yuki-kimoto authored on 2010-10-17
2221

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

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

            
test cleanup
Yuki Kimoto authored on 2011-08-10
2226
    my $builder = $dbi->query_builder;
added commit method
yuki-kimoto authored on 2010-05-27
2227

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

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2232
     my quote = $dbi->quote;
2233
     $dbi = $dbi->quote('"');
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
2234

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2239
You can set quote pair.
2240

            
2241
    $dbi->quote('[]');
2242

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2245
    my $result_class = $dbi->result_class;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2246
    $dbi = $dbi->result_class('DBIx::Custom::Result');
cleanup
yuki-kimoto authored on 2010-08-05
2247

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2252
    my $safety_character = $dbi->safety_character;
2253
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2254

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2260
    my $separator = $dbi->separator;
2261
    $dbi = $dbi->separator('-');
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
2262

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

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

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

            
2271
    my $tag_parse = $dbi->tag_parse(0);
2272
    $dbi = $dbi->tag_parse;
2273

            
2274
Enable DEPRECATED tag parsing functionality, default to 1.
2275
If you want to disable tag parsing functionality, set to 0.
2276

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2279
    my $user = $dbi->user;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2280
    $dbi = $dbi->user('Ken');
cleanup
yuki-kimoto authored on 2010-08-05
2281

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

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

            
2286
    my $user_column_info = $dbi->user_column_info;
2287
    $dbi = $dbi->user_column_info($user_column_info);
2288

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

            
2291
    [
2292
        {table => 'book', column => 'title', info => {...}},
2293
        {table => 'author', column => 'name', info => {...}}
2294
    ]
2295

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

            
2298
    my $user_column_info
2299
      = $dbi->get_column_info(exclude_table => qr/^system/);
2300
    $dbi->user_column_info($user_column_info);
2301

            
2302
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
2303
to find column info. this is very fast.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2304

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

            
2307
    my $user_table_info = $dbi->user_table_info;
2308
    $dbi = $dbi->user_table_info($user_table_info);
2309

            
2310
You can set the following data.
2311

            
2312
    [
2313
        {table => 'book', info => {...}},
2314
        {table => 'author', info => {...}}
2315
    ]
2316

            
2317
Usually, you can set return value of C<get_table_info>.
2318

            
2319
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2320
    $dbi->user_table_info($user_table_info);
2321

            
2322
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2323
to find table info.
2324

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

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

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2333
    print $dbi->available_datatype;
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2334

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

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2340
    print $dbi->available_typename;
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2341

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2347
    my $assign_clause = $dbi->assign_clause({title => 'a', age => 2});
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2348

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2351
    title = :title, author = :author
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2352

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2359
    my $column = $dbi->column(book => ['author', 'title']);
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2360

            
2361
Create column clause. The follwoing column clause is created.
2362

            
2363
    book.author as "book.author",
2364
    book.title as "book.title"
2365

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2368
    # Separator is hyphen
2369
    $dbi->separator('-');
2370
    
2371
    book.author as "book-author",
2372
    book.title as "book-title"
2373
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2374
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2375

            
update pod
Yuki Kimoto authored on 2011-03-13
2376
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2377
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2378
        user => 'ken',
2379
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2380
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2381
    );
2382

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

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

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

            
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
2391
    my $count = $dbi->count(table => 'book');
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
2392

            
2393
Get rows count.
2394

            
2395
Options is same as C<select> method's ones.
2396

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2399
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2400
        table => 'book',
2401
        primary_key => 'id',
2402
        join => [
2403
            'inner join company on book.comparny_id = company.id'
2404
        ],
2405
    );
2406

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

            
2410
   $dbi->model('book')->select(...);
2411

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

            
2414
    my $dbh = $dbi->dbh;
2415

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

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

            
2421
    $dbi->delete(table => 'book', where => {title => 'Perl'});
2422

            
2423
Execute delete statement.
2424

            
2425
The following opitons are available.
2426

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

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

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

            
2434
=item C<id>
2435

            
2436
    id => 4
2437
    id => [4, 5]
2438

            
2439
ID corresponding to C<primary_key>.
2440
You can delete rows by C<id> and C<primary_key>.
2441

            
2442
    $dbi->delete(
fixed pod
Yuki Kimoto authored on 2011-10-20
2443
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2444
        id => [4, 5],
2445
        table => 'book',
2446
    );
2447

            
2448
The above is same as the followin one.
2449

            
2450
    $dbi->delete(where => {id1 => 4, id2 => 5}, table => 'book');
2451

            
2452
=item C<prefix>
2453

            
2454
    prefix => 'some'
2455

            
2456
prefix before table name section.
2457

            
2458
    delete some from book
2459

            
2460
=item C<table>
2461

            
2462
    table => 'book'
2463

            
2464
Table name.
2465

            
2466
=item C<where>
2467

            
2468
Same as C<select> method's C<where> option.
2469

            
2470
=back
2471

            
2472
=head2 C<delete_all>
2473

            
2474
    $dbi->delete_all(table => $table);
2475

            
2476
Execute delete statement for all rows.
2477
Options is same as C<delete>.
2478

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

            
2481
    $dbi->each_column(
2482
        sub {
2483
            my ($dbi, $table, $column, $column_info) = @_;
2484
            
2485
            my $type = $column_info->{TYPE_NAME};
2486
            
2487
            if ($type eq 'DATE') {
2488
                # ...
2489
            }
2490
        }
2491
    );
2492

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

            
2498
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2499
infromation, you can improve the performance of C<each_column> in
2500
the following way.
2501

            
2502
    my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
2503
    $dbi->user_column_info($column_info);
2504
    $dbi->each_column(sub { ... });
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2505

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

            
2508
    $dbi->each_table(
2509
        sub {
2510
            my ($dbi, $table, $table_info) = @_;
2511
            
2512
            my $table_name = $table_info->{TABLE_NAME};
2513
        }
2514
    );
2515

            
improved pod
Yuki Kimoto authored on 2011-10-14
2516
Iterate all table informationsfrom in database.
2517
Argument is callback which is executed when one table is found.
2518
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2519
C<table information>.
2520

            
2521
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2522
infromation, you can improve the performance of C<each_table> in
2523
the following way.
2524

            
2525
    my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
2526
    $dbi->user_table_info($table_info);
2527
    $dbi->each_table(sub { ... });
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
2528

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2531
    my $result = $dbi->execute(
updated pod
Yuki Kimoto authored on 2011-06-21
2532
      "select * from book where title = :title and author like :author",
2533
      {title => 'Perl', author => '%Ken%'}
2534
    );
2535

            
2536
    my $result = $dbi->execute(
2537
      "select * from book where title = :book.title and author like :book.author",
2538
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2539
    );
2540

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2547
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2548
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2549
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2550
    select * from book where title = :title and author like :author
2551
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2552
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2553
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2554

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2558
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2559
    select * from book where :title{=} and :author{like}
2560
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2561
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2562
    select * from where title = ? and author like ?;
2563

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

            
2568
    select * from where title = "aa\\:bb";
2569

            
cleanup
Yuki Kimoto authored on 2011-10-20
2570
B<OPTIONS>
2571

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

            
2574
=over 4
2575

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

            
2578
You can filter sql after the sql is build.
2579

            
2580
    after_build_sql => $code_ref
2581

            
2582
The following one is one example.
2583

            
2584
    $dbi->select(
2585
        table => 'book',
2586
        column => 'distinct(name)',
2587
        after_build_sql => sub {
2588
            "select count(*) from ($_[0]) as t1"
2589
        }
2590
    );
2591

            
2592
The following SQL is executed.
2593

            
2594
    select count(*) from (select distinct(name) from book) as t1;
2595

            
cleanup
Yuki Kimoto authored on 2011-10-20
2596
=item C<append>
2597

            
2598
    append => 'order by name'
2599

            
2600
Append some statement after SQL.
2601

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

            
2604
Specify database bind data type.
2605

            
2606
    bind_type => [image => DBI::SQL_BLOB]
2607
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2608

            
2609
This is used to bind parameter by C<bind_param> of statment handle.
2610

            
2611
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2612

            
update pod
Yuki Kimoto authored on 2011-03-13
2613
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2614
    
2615
    filter => {
2616
        title  => sub { uc $_[0] }
2617
        author => sub { uc $_[0] }
2618
    }
update pod
Yuki Kimoto authored on 2011-03-13
2619

            
updated pod
Yuki Kimoto authored on 2011-06-09
2620
    # Filter name
2621
    filter => {
2622
        title  => 'upper_case',
2623
        author => 'upper_case'
2624
    }
2625
        
2626
    # At once
2627
    filter => [
2628
        [qw/title author/]  => sub { uc $_[0] }
2629
    ]
2630

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

            
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2636
=item C<id>
2637

            
2638
    id => 4
2639
    id => [4, 5]
2640

            
2641
ID corresponding to C<primary_key>.
2642
You can delete rows by C<id> and C<primary_key>.
2643

            
2644
    $dbi->execute(
2645
        "select * from book where id1 = :id1 and id2 = :id2",
2646
        {},
fixed pod
Yuki Kimoto authored on 2011-10-20
2647
        primary_key => ['id1', 'id2'],
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2648
        id => [4, 5],
2649
    );
2650

            
2651
The above is same as the followin one.
2652

            
2653
    $dbi->execute(
2654
        "select * from book where id1 = :id1 and id2 = :id2",
2655
        {id1 => 4, id2 => 5}
2656
    );
2657

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

            
2660
    query => 1
2661

            
2662
C<execute> method return L<DBIx::Custom::Query> object, not executing SQL.
micro optimization and
Yuki Kimoto authored on 2011-10-25
2663
You can check SQL, column, or get statment handle.
updated pod
Yuki Kimoto authored on 2011-06-21
2664

            
2665
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2666
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2667
    my $columns = $query->columns;
2668
    
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2669
=item C<primary_key>
2670

            
cleanup
Yuki Kimoto authored on 2011-10-20
2671
    primary_key => 'id'
2672
    primary_key => ['id1', 'id2']
2673

            
2674
Priamry key. This is used when C<id> option find primary key.
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2675

            
updated pod
Yuki Kimoto authored on 2011-06-09
2676
=item C<table>
2677
    
2678
    table => 'author'
2679

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2684
    $dbi->execute("select * from book where title = :title and author = :author",
2685
        {title => 'Perl', author => 'Ken', table => 'book');
updated pod
Yuki Kimoto authored on 2011-06-09
2686

            
updated pod
Yuki Kimoto authored on 2011-06-21
2687
    # Same
2688
    $dbi->execute(
2689
      "select * from book where title = :book.title and author = :book.author",
2690
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2691

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2694
    table_alias => {user => 'worker'}
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
2695

            
2696
Table alias. Key is real table name, value is alias table name.
2697
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2698
on alias table name.
2699

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2700
=item C<reuse EXPERIMENTAL>
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2701
    
micro optimization
Yuki Kimoto authored on 2011-10-23
2702
    reuse => $has_ref
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2703

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2704
Reuse query object if the hash reference variable is set.
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2705
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2706
    my $queries = {};
2707
    $dbi->execute($sql, $param, reuse => $queries);
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2708

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2709
This will improved performance when you want to execute same query repeatedly
2710
because generally creating query object is slow.
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2711

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

            
2714
    type_rule_off => 1
2715

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

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

            
2720
    type_rule1_off => 1
2721

            
2722
Turn C<into1> type rule off.
2723

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

            
2726
    type_rule2_off => 1
2727

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

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

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

            
improved pod
Yuki Kimoto authored on 2011-10-14
2734
    my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2735

            
2736
get column infomation except for one which match C<exclude_table> pattern.
2737

            
2738
    [
2739
        {table => 'book', column => 'title', info => {...}},
2740
        {table => 'author', column => 'name' info => {...}}
2741
    ]
2742

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

            
improved pod
Yuki Kimoto authored on 2011-10-14
2745
    my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
update pod
Yuki Kimoto authored on 2011-03-13
2746

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

            
2749
    [
2750
        {table => 'book', info => {...}},
2751
        {table => 'author', info => {...}}
2752
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2753

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

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

            
2758
    $dbi->helper(
2759
        update_or_insert => sub {
2760
            my $self = shift;
2761
            
2762
            # Process
2763
        },
2764
        find_or_create   => sub {
2765
            my $self = shift;
2766
            
2767
            # Process
2768
        }
2769
    );
2770

            
2771
Register helper. These helper is called directly from L<DBIx::Custom> object.
2772

            
2773
    $dbi->update_or_insert;
2774
    $dbi->find_or_create;
2775

            
cleanup
yuki-kimoto authored on 2010-10-17
2776
=head2 C<insert>
2777

            
cleanup
Yuki Kimoto authored on 2011-06-09
2778
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
update pod
Yuki Kimoto authored on 2011-03-13
2779

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

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

            
2786
    {date => \"NOW()"}
2787

            
cleanup
Yuki Kimoto authored on 2011-10-20
2788
B<options>
2789

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

            
cleanup
Yuki Kimoto authored on 2011-06-09
2793
=over 4
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2794

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2795
=item C<created_at EXPERIMETNAL>
2796

            
2797
    created_at => 'created_datetime'
2798

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2805
    id => 4
2806
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2807

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2811
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2812
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
2813
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2814
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2815
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2816
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2817

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

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2820
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2821
        {id1 => 4, id2 => 5, title => 'Perl', author => 'Ken'},
2822
        table => 'book'
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2823
    );
update pod
Yuki Kimoto authored on 2011-03-13
2824

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

            
2827
    prefix => 'or replace'
2828

            
2829
prefix before table name section
2830

            
2831
    insert or replace into book
2832

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

            
2835
    table => 'book'
2836

            
2837
Table name.
2838

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2839
=item C<updated_at EXPERIMENTAL>
2840

            
2841
This option is same as C<update> method C<updated_at> option.
2842

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

            
2845
    wrap => {price => sub { "max($_[0])" }}
2846

            
2847
placeholder wrapped string.
2848

            
2849
If the following statement
2850

            
2851
    $dbi->insert({price => 100}, table => 'book',
2852
      {price => sub { "$_[0] + 5" }});
2853

            
2854
is executed, the following SQL is executed.
2855

            
2856
    insert into book price values ( ? + 5 );
2857

            
update pod
Yuki Kimoto authored on 2011-03-13
2858
=back
2859

            
2860
=over 4
2861

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2864
    $dbi->include_model('MyModel');
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2865

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2869
    lib / MyModel.pm
2870
        / MyModel / book.pm
2871
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2872

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

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

            
2877
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2878
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2879
    
2880
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2881

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2886
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2887
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2888
    
2889
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2890

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2893
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2894
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2895
    
2896
    1;
2897
    
updated pod
Yuki Kimoto authored on 2011-06-21
2898
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2899

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2902
    my $book_model = $dbi->model('book');
update pod
Yuki Kimoto authored on 2011-03-13
2903
    my $company_model = $dbi->model('company');
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2904

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

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

            
2909
    my $like_value = $dbi->like_value
2910

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

            
2913
    sub { "%$_[0]%" }
2914

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

            
2917
    my $mapper = $dbi->mapper(param => $param);
2918

            
2919
Create a new L<DBIx::Custom::Mapper> object.
2920

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

            
2923
    my $param = $dbi->merge_param({key1 => 1}, {key1 => 1, key2 => 2});
2924

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

            
2927
    {key1 => [1, 1], key2 => 2}
2928

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

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

            
2933
    my $model = $dbi->model('book');
2934

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2940
    my $column = $dbi->mycolumn(book => ['author', 'title']);
cleanup
Yuki Kimoto authored on 2011-03-21
2941

            
2942
Create column clause for myself. The follwoing column clause is created.
2943

            
2944
    book.author as author,
2945
    book.title as title
2946

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2949
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2950
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2951
        user => 'ken',
2952
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2953
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2954
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2955

            
2956
Create a new L<DBIx::Custom> object.
2957

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

            
2960
    my $not_exists = $dbi->not_exists;
2961

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

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

            
2967
    my $order = $dbi->order;
2968

            
2969
Create a new L<DBIx::Custom::Order> object.
2970

            
cleanup
yuki-kimoto authored on 2010-10-17
2971
=head2 C<register_filter>
2972

            
update pod
Yuki Kimoto authored on 2011-03-13
2973
    $dbi->register_filter(
2974
        # Time::Piece object to database DATE format
2975
        tp_to_date => sub {
2976
            my $tp = shift;
2977
            return $tp->strftime('%Y-%m-%d');
2978
        },
2979
        # database DATE format to Time::Piece object
2980
        date_to_tp => sub {
2981
           my $date = shift;
2982
           return Time::Piece->strptime($date, '%Y-%m-%d');
2983
        }
2984
    );
cleanup
yuki-kimoto authored on 2010-10-17
2985
    
update pod
Yuki Kimoto authored on 2011-03-13
2986
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2987

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2990
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2991
        table  => 'book',
2992
        column => ['author', 'title'],
2993
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2994
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2995
    
updated document
Yuki Kimoto authored on 2011-06-09
2996
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2997

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3005
=item C<column>
3006
    
updated document
Yuki Kimoto authored on 2011-06-09
3007
    column => 'author'
3008
    column => ['author', 'title']
3009

            
3010
Column clause.
updated pod
Yuki Kimoto authored on 2011-06-07
3011
    
updated document
Yuki Kimoto authored on 2011-06-09
3012
if C<column> is not specified, '*' is set.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3013

            
updated document
Yuki Kimoto authored on 2011-06-09
3014
    column => '*'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3015

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3018
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
3019
        {book => [qw/author title/]},
3020
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
3021
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
3022

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

            
3025
    book.author as "book.author",
3026
    book.title as "book.title",
3027
    person.name as "person.name",
3028
    person.age as "person.age"
3029

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3033
    column => [
- select method column optio...
Yuki Kimoto authored on 2011-07-11
3034
        ['date(book.register_datetime)' => 'book.register_date']
updated document
Yuki Kimoto authored on 2011-06-09
3035
    ];
- select() column option can...
Yuki Kimoto authored on 2011-06-08
3036

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

            
3039
    date(book.register_datetime) as "book.register_date"
updated pod
Yuki Kimoto authored on 2011-06-07
3040

            
updated document
Yuki Kimoto authored on 2011-06-09
3041
=item C<filter>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3042

            
updated document
Yuki Kimoto authored on 2011-06-09
3043
Same as C<execute> method's C<filter> option.
3044

            
3045
=item C<id>
3046

            
3047
    id => 4
3048
    id => [4, 5]
3049

            
3050
ID corresponding to C<primary_key>.
3051
You can select rows by C<id> and C<primary_key>.
3052

            
3053
    $dbi->select(
fixed pod
Yuki Kimoto authored on 2011-10-20
3054
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3055
        id => [4, 5],
3056
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3057
    );
3058

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3061
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3062
        where => {id1 => 4, id2 => 5},
3063
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3064
    );
3065
    
cleanup
Yuki Kimoto authored on 2011-10-20
3066
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3067

            
updated document
Yuki Kimoto authored on 2011-06-09
3068
    param => {'table2.key3' => 5}
update pod
Yuki Kimoto authored on 2011-03-12
3069

            
updated document
Yuki Kimoto authored on 2011-06-09
3070
Parameter shown before where clause.
3071
    
3072
For example, if you want to contain tag in join clause, 
3073
you can pass parameter by C<param> option.
update pod
Yuki Kimoto authored on 2011-03-12
3074

            
updated document
Yuki Kimoto authored on 2011-06-09
3075
    join  => ['inner join (select * from table2 where table2.key3 = :table2.key3)' . 
3076
              ' as table2 on table1.key1 = table2.key1']
3077

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

            
3080
    prefix => 'SQL_CALC_FOUND_ROWS'
3081

            
3082
Prefix of column cluase
3083

            
3084
    select SQL_CALC_FOUND_ROWS title, author from book;
3085

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

            
3088
    join => [
3089
        'left outer join company on book.company_id = company_id',
3090
        'left outer join location on company.location_id = location.id'
3091
    ]
3092
        
3093
Join clause. If column cluase or where clause contain table name like "company.name",
3094
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3095

            
3096
    $dbi->select(
3097
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3098
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3099
        where => {'company.name' => 'Orange'},
3100
        join => [
3101
            'left outer join company on book.company_id = company.id',
3102
            'left outer join location on company.location_id = location.id'
3103
        ]
3104
    );
3105

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3109
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3110
    from book
3111
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3112
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3113

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3114
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
3115
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3116

            
3117
    $dbi->select(
3118
        table => 'book',
3119
        column => ['company.location_id as location_id'],
3120
        where => {'company.name' => 'Orange'},
3121
        join => [
3122
            {
3123
                clause => 'left outer join location on company.location_id = location.id',
3124
                table => ['company', 'location']
3125
            }
3126
        ]
3127
    );
3128

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3131
    table => 'book'
updated pod
Yuki Kimoto authored on 2011-06-08
3132

            
updated document
Yuki Kimoto authored on 2011-06-09
3133
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3134

            
updated document
Yuki Kimoto authored on 2011-06-09
3135
=item C<where>
3136
    
3137
    # Hash refrence
3138
    where => {author => 'Ken', 'title' => 'Perl'}
3139
    
3140
    # DBIx::Custom::Where object
3141
    where => $dbi->where(
3142
        clause => ['and', 'author = :author', 'title like :title'],
3143
        param  => {author => 'Ken', title => '%Perl%'}
3144
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3145
    
3146
    # Array reference 1 (array reference, hash referenc). same as above
3147
    where => [
3148
        ['and', 'author = :author', 'title like :title'],
3149
        {author => 'Ken', title => '%Perl%'}
3150
    ];    
3151
    
3152
    # Array reference 2 (String, hash reference)
3153
    where => [
3154
        'title like :title',
3155
        {title => '%Perl%'}
3156
    ]
3157
    
3158
    # String
3159
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3160

            
cleanup
Yuki Kimoto authored on 2011-10-20
3161
Where clause. See L<DBIx::Custom::Where>.
updated document
Yuki Kimoto authored on 2011-06-09
3162
    
update pod
Yuki Kimoto authored on 2011-03-12
3163
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3164

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

            
3167
    $dbi->setup_model;
3168

            
3169
Setup all model objects.
3170
C<columns> of model object is automatically set, parsing database information.
3171

            
3172
=head2 C<type_rule>
3173

            
3174
    $dbi->type_rule(
3175
        into1 => {
3176
            date => sub { ... },
3177
            datetime => sub { ... }
3178
        },
3179
        into2 => {
3180
            date => sub { ... },
3181
            datetime => sub { ... }
3182
        },
3183
        from1 => {
3184
            # DATE
3185
            9 => sub { ... },
3186
            # DATETIME or TIMESTAMP
3187
            11 => sub { ... },
3188
        }
3189
        from2 => {
3190
            # DATE
3191
            9 => sub { ... },
3192
            # DATETIME or TIMESTAMP
3193
            11 => sub { ... },
3194
        }
3195
    );
3196

            
3197
Filtering rule when data is send into and get from database.
3198
This has a little complex problem.
3199

            
3200
In C<into1> and C<into2> you can specify
3201
type name as same as type name defined
3202
by create table, such as C<DATETIME> or C<DATE>.
3203

            
3204
Note that type name and data type don't contain upper case.
3205
If these contain upper case charactor, you convert it to lower case.
3206

            
3207
C<into2> is executed after C<into1>.
3208

            
3209
Type rule of C<into1> and C<into2> is enabled on the following
3210
column name.
3211

            
3212
=over 4
3213

            
3214
=item 1. column name
3215

            
3216
    issue_date
3217
    issue_datetime
3218

            
3219
This need C<table> option in each method.
3220

            
3221
=item 2. table name and column name, separator is dot
3222

            
3223
    book.issue_date
3224
    book.issue_datetime
3225

            
3226
=back
3227

            
3228
You get all type name used in database by C<available_typename>.
3229

            
3230
    print $dbi->available_typename;
3231

            
3232
In C<from1> and C<from2> you specify data type, not type name.
3233
C<from2> is executed after C<from1>.
3234
You get all data type by C<available_datatype>.
3235

            
3236
    print $dbi->available_datatype;
3237

            
3238
You can also specify multiple types at once.
3239

            
3240
    $dbi->type_rule(
3241
        into1 => [
3242
            [qw/DATE DATETIME/] => sub { ... },
3243
        ],
3244
    );
3245

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3248
    $dbi->update({title => 'Perl'}, table  => 'book', where  => {id => 4});
removed reconnect method
yuki-kimoto authored on 2010-05-28
3249

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

            
3252
If you want to set constant value to row data, use scalar reference
3253
as parameter value.
3254

            
3255
    {date => \"NOW()"}
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
3256

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3266
    id => 4
3267
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3268

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3272
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3273
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
3274
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3275
        id => [4, 5],
3276
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3277
    );
update pod
Yuki Kimoto authored on 2011-03-13
3278

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3281
    $dbi->update(
3282
        {title => 'Perl', author => 'Ken'}
3283
        where => {id1 => 4, id2 => 5},
3284
        table => 'book'
3285
    );
update pod
Yuki Kimoto authored on 2011-03-13
3286

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

            
3289
    prefix => 'or replace'
3290

            
3291
prefix before table name section
3292

            
3293
    update or replace book
3294

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3297
    table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
3298

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

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

            
3303
Same as C<select> method's C<where> option.
3304

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

            
3307
    wrap => {price => sub { "max($_[0])" }}
3308

            
3309
placeholder wrapped string.
3310

            
3311
If the following statement
3312

            
3313
    $dbi->update({price => 100}, table => 'book',
3314
      {price => sub { "$_[0] + 5" }});
3315

            
3316
is executed, the following SQL is executed.
3317

            
3318
    update book set price =  ? + 5;
3319

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
3320
=item C<updated_at EXPERIMETNAL>
3321

            
3322
    updated_at => 'updated_datetime'
3323

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3328
=back
update pod
Yuki Kimoto authored on 2011-03-13
3329

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
3332
    $dbi->update_all({title => 'Perl'}, table => 'book', );
update pod
Yuki Kimoto authored on 2011-03-13
3333

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

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3337
=head2 C<update_or_insert EXPERIMENTAL>
3338
    
3339
    # Where
3340
    $dbi->update_or_insert(
3341
        {id => 1, title => 'Perl'},
3342
        table => 'book',
3343
        where => {id => 1},
3344
        select_option => {append => 'for update'}
3345
    );
3346
    
3347
    # ID
3348
    $dbi->update_or_insert(
3349
        {title => 'Perl'},
3350
        table => 'book',
3351
        id => 1,
3352
        primary_key => 'id',
3353
        select_option => {append => 'for update'}
3354
    );
3355
    
3356
Update or insert.
3357

            
3358
In both examples, the following SQL is executed.
3359

            
3360
    # In case insert
3361
    insert into book (id, title) values (?, ?)
3362
    
3363
    # In case update
3364
    update book set (id = ?, title = ?) where book.id = ?
3365

            
3366
The following opitons are available adding to C<update> option.
3367

            
3368
=over 4
3369

            
3370
=item C<select_option>
3371

            
3372
    select_option => {append => 'for update'}
3373

            
3374
select method option,
3375
select method is used to check the row is already exists.
3376

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

            
3379
    $dbi->show_datatype($table);
3380

            
3381
Show data type of the columns of specified table.
3382

            
3383
    book
3384
    title: 5
3385
    issue_date: 91
3386

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

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

            
3391
    $dbi->show_tables;
3392

            
3393
Show tables.
3394

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

            
3397
    $dbi->show_typename($table);
3398

            
3399
Show type name of the columns of specified table.
3400

            
3401
    book
3402
    title: varchar
3403
    issue_date: date
3404

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

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

            
3409
    my $values_clause = $dbi->values_clause({title => 'a', age => 2});
3410

            
3411
Create values clause.
3412

            
3413
    (title, author) values (title = :title, age = :age);
3414

            
3415
You can use this in insert statement.
3416

            
3417
    my $insert_sql = "insert into book $values_clause";
3418

            
3419
=head2 C<where>
3420

            
3421
    my $where = $dbi->where(
3422
        clause => ['and', 'title = :title', 'author = :author'],
3423
        param => {title => 'Perl', author => 'Ken'}
3424
    );
3425

            
3426
Create a new L<DBIx::Custom::Where> object.
3427

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

            
3430
=head2 C<DBIX_CUSTOM_DEBUG>
3431

            
3432
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3433
executed SQL and bind values are printed to STDERR.
3434

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

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

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

            
3441
L<DBIx::Custom>
3442

            
3443
    # Attribute methods
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
3444
    default_dbi_option # will be removed 2017/1/1
3445
    dbi_option # will be removed 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3446
    data_source # will be removed at 2017/1/1
3447
    dbi_options # will be removed at 2017/1/1
3448
    filter_check # will be removed at 2017/1/1
3449
    reserved_word_quote # will be removed at 2017/1/1
3450
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3451
    
3452
    # Methods
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
3453
    update_timestamp # will be removed at 2017/1/1
3454
    insert_timestamp # will be removed at 2017/1/1
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3455
    method # will be removed at 2017/1/1
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
3456
    assign_param # will be removed at 2017/1/1
3457
    update_param # will be removed at 2017/1/1
3458
    insert_param # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3459
    create_query # will be removed at 2017/1/1
3460
    apply_filter # will be removed at 2017/1/1
3461
    select_at # will be removed at 2017/1/1
3462
    delete_at # will be removed at 2017/1/1
3463
    update_at # will be removed at 2017/1/1
3464
    insert_at # will be removed at 2017/1/1
3465
    register_tag # will be removed at 2017/1/1
3466
    default_bind_filter # will be removed at 2017/1/1
3467
    default_fetch_filter # will be removed at 2017/1/1
3468
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3469
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3470
    register_tag_processor # will be removed at 2017/1/1
3471
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3472
    
3473
    # Options
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
3474
    update timestamp option # will be removed 2017/1/1
3475
    insert timestamp option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3476
    select method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3477
    delete method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3478
    update method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3479
    insert method param option # will be removed at 2017/1/1
insert method's id option is...
Yuki Kimoto authored on 2011-10-10
3480
    insert method id option # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3481
    select method relation option # will be removed at 2017/1/1
3482
    select method column option [COLUMN, as => ALIAS] format
3483
      # will be removed at 2017/1/1
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3484
    execute method's sqlfilter option # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3485
    
3486
    # Others
micro optimization and
Yuki Kimoto authored on 2011-10-25
3487
    execute($query, ...) # execute method receiving query object.
3488
                         # this is removed at 2017/1/1
cleanup
Yuki Kimoto authored on 2011-07-28
3489
    execute("select * from {= title}"); # execute method's
3490
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3491
                                        # will be removed at 2017/1/1
3492
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3493

            
3494
L<DBIx::Custom::Model>
3495

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3496
    # Attribute methods
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3497
    method # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3498
    filter # will be removed at 2017/1/1
3499
    name # will be removed at 2017/1/1
3500
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3501

            
3502
L<DBIx::Custom::Query>
3503
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3504
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3505
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3506
    table # will be removed at 2017/1/1
3507
    filters # will be removed at 2017/1/1
3508
    
3509
    # Methods
3510
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3511

            
3512
L<DBIx::Custom::QueryBuilder>
3513
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3514
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3515
    tags # will be removed at 2017/1/1
3516
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3517
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3518
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3519
    register_tag # will be removed at 2017/1/1
3520
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3521
    
3522
    # Others
3523
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3524
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3525

            
3526
L<DBIx::Custom::Result>
3527
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3528
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3529
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3530
    
3531
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3532
    end_filter # will be removed at 2017/1/1
3533
    remove_end_filter # will be removed at 2017/1/1
3534
    remove_filter # will be removed at 2017/1/1
3535
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3536

            
3537
L<DBIx::Custom::Tag>
3538

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3539
    This module is DEPRECATED! # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3540

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

            
3543
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3544
except for attribute method.
3545
You can check all DEPRECATED functionalities by document.
3546
DEPRECATED functionality is removed after five years,
3547
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
3548
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3549

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

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

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

            
3556
C<< <kimoto.yuki at gmail.com> >>
3557

            
3558
L<http://github.com/yuki-kimoto/DBIx-Custom>
3559

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3560
=head1 AUTHOR
3561

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

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

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

            
3568
This program is free software; you can redistribute it and/or modify it
3569
under the same terms as Perl itself.
3570

            
3571
=cut