DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3552 lines | 91.984kb
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 { {} },
cleanup
Yuki Kimoto authored on 2011-08-13
55
    query_builder => sub {
56
        my $self = shift;
57
        my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
58
        weaken $builder->{dbi};
59
        return $builder;
60
    },
update pod
Yuki Kimoto authored on 2011-03-13
61
    result_class  => 'DBIx::Custom::Result',
62
    safety_character => '\w',
cleanup test
Yuki Kimoto authored on 2011-08-10
63
    separator => '.',
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
64
    stash => sub { {} },
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
65
    tag_parse => 1;
cleanup
yuki-kimoto authored on 2010-10-17
66

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

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

            
added helper method
yuki-kimoto authored on 2010-10-17
98
our $AUTOLOAD;
99
sub AUTOLOAD {
100
    my $self = shift;
101

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
105
    # Call method
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
106
    $self->{_methods} ||= {};
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
107
    if (my $method = $self->{_methods}->{$mname}) {
108
        return $self->$method(@_)
109
    }
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
110
    elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
111
        $self->dbh->$dbh_method(@_);
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
112
    }
113
    else {
cleanup
Yuki Kimoto authored on 2011-04-25
114
        croak qq{Can't locate object method "$mname" via "$package" }
115
            . _subname;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
116
    }
added helper method
yuki-kimoto authored on 2010-10-17
117
}
118

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
234
sub delete {
235
    my ($self, %opt) = @_;
236
    warn "delete method where_param option is DEPRECATED!"
237
      if $opt{where_param};
238
    
cleanup
Yuki Kimoto authored on 2011-10-21
239
    # Don't allow delete all rows
cleanup
Yuki Kimoto authored on 2011-10-21
240
    croak qq{delete method where or id option must be specified } . _subname
241
      if !$opt{where} && !defined $opt{id} && !$opt{allow_delete_all};
242
    
243
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
244
    my $wcp = $self->_where_clause_and_param($opt{where}, $opt{where_param},
245
      delete $opt{id}, $opt{primary_key}, $opt{table});
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
246

            
cleanup
Yuki Kimoto authored on 2011-04-02
247
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-10-21
248
    my $sql = "delete ";
cleanup
Yuki Kimoto authored on 2011-10-21
249
    $sql .= "$opt{prefix} " if defined $opt{prefix};
cleanup
Yuki Kimoto authored on 2011-10-25
250
    $sql .= "from " . $self->_q($opt{table}) . " $wcp->{clause} ";
packaging one directory
yuki-kimoto authored on 2009-11-16
251
    
252
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
253
    $opt{statement} = 'delete';
cleanup
Yuki Kimoto authored on 2011-10-25
254
    $self->execute($sql, $wcp->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
255
}
256

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

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

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

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

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
298
    my $user_column_info = $self->user_column_info;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
299
    
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
300
    if ($user_column_info) {
301
        $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
302
    }
303
    else {
304
    
305
        my $re = $self->exclude_table || $options{exclude_table};
306
        # Tables
307
        my %tables;
308
        $self->each_table(sub { $tables{$_[1]}++ });
added SQL Server test
Yuki Kimoto authored on 2011-08-14
309

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
310
        # Iterate all tables
311
        my @tables = sort keys %tables;
312
        for (my $i = 0; $i < @tables; $i++) {
313
            my $table = $tables[$i];
314
            
315
            # Iterate all columns
316
            my $sth_columns;
317
            eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
318
            next if $@;
319
            while (my $column_info = $sth_columns->fetchrow_hashref) {
320
                my $column = $column_info->{COLUMN_NAME};
321
                $self->$cb($table, $column, $column_info);
322
            }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
323
        }
324
    }
325
}
326

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
327
sub each_table {
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
328
    my ($self, $cb, %option) = @_;
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
329
    
cleanup test
Yuki Kimoto authored on 2011-08-16
330
    my $user_table_infos = $self->user_table_info;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
331
    
added test
Yuki Kimoto authored on 2011-08-16
332
    # Iterate tables
333
    if ($user_table_infos) {
334
        $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
335
    }
336
    else {
337
        my $re = $self->exclude_table || $option{exclude};
338
        my $sth_tables = $self->dbh->table_info;
339
        while (my $table_info = $sth_tables->fetchrow_hashref) {
340
            
341
            # Table
342
            my $table = $table_info->{TABLE_NAME};
343
            next if defined $re && $table =~ /$re/;
344
            $self->$cb($table, $table_info);
345
        }
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
346
    }
347
}
348

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

            
353
    # Options
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
354
    my $param;
355
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
356
    my %opt = @_;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
357
    warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
358
    $param ||= $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-10-21
359
    my $tables = $opt{table} || [];
cleanup
Yuki Kimoto authored on 2011-04-02
360
    $tables = [$tables] unless ref $tables eq 'ARRAY';
micro optimization
Yuki Kimoto authored on 2011-10-23
361
    my $filter = ref $opt{filter} eq 'ARRAY' ?
362
      _array_to_hash($opt{filter}) : $opt{filter};
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
363
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
364
    # Append
365
    $sql .= $opt{append} if defined $opt{append} && !ref $sql;
366
    
367
    # Query
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
368
    my $query;
369
    if (ref $sql) { $query = $sql }
370
    else {
371
        $query = $opt{reuse}->{$sql} if $opt{reuse};
372
        $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter})
373
          unless $query;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
374
        $query->statement($opt{statement} || '');
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
375
        $opt{reuse}->{$sql} = $query if $opt{reuse};
376
    }
377
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
378
    # Save query
micro optimization
Yuki Kimoto authored on 2011-10-23
379
    $self->{last_sql} = $query->{sql};
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
380

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
381
    # Return query
382
    return $query if $opt{query};
micro optimization
Yuki Kimoto authored on 2011-07-30
383
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
384
    # Merge query filter(DEPRECATED!)
DBIx::Custom::Query filter m...
Yuki Kimoto authored on 2011-07-30
385
    $filter ||= $query->{filter} || {};
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
386
    
cleanup
Yuki Kimoto authored on 2011-04-02
387
    # Tables
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
388
    unshift @$tables, @{$query->{tables} || []};
micro optimization
Yuki Kimoto authored on 2011-07-30
389
    my $main_table = @{$tables}[-1];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
390

            
391
    # Merge id to parameter
392
    my @cleanup;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
393
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
394
        croak "execute id option must be specified with primary_key option"
395
          unless $opt{primary_key};
396
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
397
        $opt{id} = [$opt{id}] unless ref $opt{id};
398
        my $statement = $query->statement;
399
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
400
           my $key = $opt{primary_key}->[$i];
401
           $key = "$main_table.$key" if $statement eq 'update' ||
402
             $statement eq 'delete' || $statement eq 'select';
403
           next if exists $param->{$key};
404
           $param->{$key} = $opt{id}->[$i];
405
           push @cleanup, $key;
406
        }
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
407
    }
micro optimization
Yuki Kimoto authored on 2011-07-30
408
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
409
    # Cleanup tables(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
410
    $tables = $self->_remove_duplicate_table($tables, $main_table)
411
      if @$tables > 1;
cleanup
Yuki Kimoto authored on 2011-04-02
412
    
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
413
    # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
414
    my $type_filters = {};
micro optimization
Yuki Kimoto authored on 2011-10-23
415
    if ($self->{_type_rule_is_called}) {
416
        unless ($opt{type_rule_off}) {
417
            my $type_rule_off_parts = {
418
                1 => $opt{type_rule1_off},
419
                2 => $opt{type_rule2_off}
420
            };
421
            for my $i (1, 2) {
422
                unless ($type_rule_off_parts->{$i}) {
423
                    $type_filters->{$i} = {};
424
                    my $table_alias = $opt{table_alias} || {};
425
                    for my $alias (keys %$table_alias) {
426
                        my $table = $table_alias->{$alias};
427
                        
428
                        for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
429
                            $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
430
                        }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
431
                    }
micro optimization
Yuki Kimoto authored on 2011-10-23
432
                    $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
433
                      if $main_table;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
434
                }
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
435
            }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
436
        }
437
    }
cleanup
Yuki Kimoto authored on 2011-04-02
438
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
439
    # Applied filter(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
440
    if ($self->{filter}{on}) {
441
        my $applied_filter = {};
cleanup
Yuki Kimoto authored on 2011-10-21
442
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-07-30
443
            $applied_filter = {
444
                %$applied_filter,
445
                %{$self->{filter}{out}->{$table} || {}}
446
            }
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
447
        }
micro optimization
Yuki Kimoto authored on 2011-07-30
448
        $filter = {%$applied_filter, %$filter};
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
449
    }
450
    
cleanup
Yuki Kimoto authored on 2011-04-02
451
    # Replace filter name to code
cleanup
Yuki Kimoto authored on 2011-10-21
452
    for my $column (keys %$filter) {
cleanup
Yuki Kimoto authored on 2011-04-02
453
        my $name = $filter->{$column};
454
        if (!defined $name) {
455
            $filter->{$column} = undef;
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
456
        }
cleanup
Yuki Kimoto authored on 2011-04-02
457
        elsif (ref $name ne 'CODE') {
cleanup
Yuki Kimoto authored on 2011-04-25
458
          croak qq{Filter "$name" is not registered" } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
459
            unless exists $self->filters->{$name};
460
          $filter->{$column} = $self->filters->{$name};
cleanup
Yuki Kimoto authored on 2010-12-21
461
        }
462
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
463
    
cleanup
Yuki Kimoto authored on 2011-04-02
464
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
465
    my ($bind, $bind_types) = $self->_create_bind_values($param, $query->columns,
466
      $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
467

            
cleanup
yuki-kimoto authored on 2010-10-17
468
    # Execute
micro optimization
Yuki Kimoto authored on 2011-10-23
469
    my $sth = $query->{sth};
cleanup
yuki-kimoto authored on 2010-10-17
470
    my $affected;
cleanup
Yuki Kimoto authored on 2011-03-21
471
    eval {
micro optimization
Yuki Kimoto authored on 2011-10-23
472
        if ($opt{bind_type} || $opt{type}) {
473
            $sth->bind_param($_ + 1, $bind->[$_],
474
                $bind_types->[$_] ? $bind_types->[$_] : ())
475
              for (0 .. @$bind - 1);
476
            $affected = $sth->execute;
477
        }
478
        else {
479
            $affected = $sth->execute(@$bind);
480
        }
cleanup
Yuki Kimoto authored on 2011-03-21
481
    };
improved error messages
Yuki Kimoto authored on 2011-04-18
482
    
micro optimization
Yuki Kimoto authored on 2011-07-30
483
    $self->_croak($@, qq{. Following SQL is executed.\n}
484
      . qq{$query->{sql}\n} . _subname) if $@;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
485

            
486
    # Remove id from parameter
487
    delete $param->{$_} for @cleanup;
cleanup
yuki-kimoto authored on 2010-10-17
488
    
improved debug message
Yuki Kimoto authored on 2011-05-23
489
    # DEBUG message
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
490
    if ($ENV{DBIX_CUSTOM_DEBUG}) {
491
        warn "SQL:\n" . $query->sql . "\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
492
        my @output;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
493
        for my $value (@$bind) {
improved debug message
Yuki Kimoto authored on 2011-05-23
494
            $value = 'undef' unless defined $value;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
495
            $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
improved debug message
Yuki Kimoto authored on 2011-05-23
496
              if utf8::is_utf8($value);
497
            push @output, $value;
498
        }
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
499
        warn "Bind values: " . join(', ', @output) . "\n\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
500
    }
added environment variable D...
Yuki Kimoto authored on 2011-04-02
501
    
micro optimization
Yuki Kimoto authored on 2011-10-23
502
    # Not select statement
503
    return $affected unless $sth->{NUM_OF_FIELDS};
504

            
505
    # Filter(DEPRECATED!)
506
    my $infilter = {};
507
    if ($self->{filter}{on}) {
508
        $infilter->{in}  = {};
509
        $infilter->{end} = {};
510
        push @$tables, $main_table if $main_table;
511
        for my $table (@$tables) {
512
            for my $way (qw/in end/) {
513
                $infilter->{$way} = {%{$infilter->{$way}},
514
                  %{$self->{filter}{$way}{$table} || {}}};
cleanup
Yuki Kimoto authored on 2011-04-02
515
            }
cleanup
Yuki Kimoto authored on 2011-01-12
516
        }
cleanup
yuki-kimoto authored on 2010-10-17
517
    }
micro optimization
Yuki Kimoto authored on 2011-10-23
518
    
519
    # Result
520
    my $result = $self->result_class->new(
521
        sth => $sth,
522
        dbi => $self,
523
        default_filter => $self->{default_in_filter},
524
        filter => $infilter->{in} || {},
525
        end_filter => $infilter->{end} || {},
526
        type_rule => {
527
            from1 => $self->type_rule->{from1},
528
            from2 => $self->type_rule->{from2}
529
        },
530
    );
531
    $result;
cleanup
yuki-kimoto authored on 2010-10-17
532
}
533

            
added test
Yuki Kimoto authored on 2011-08-16
534
sub get_table_info {
cleanup
Yuki Kimoto authored on 2011-10-21
535
    my ($self, %opt) = @_;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
536
    
cleanup
Yuki Kimoto authored on 2011-10-21
537
    my $exclude = delete $opt{exclude};
538
    croak qq/"$_" is wrong option/ for keys %opt;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
539
    
added test
Yuki Kimoto authored on 2011-08-16
540
    my $table_info = [];
541
    $self->each_table(
542
        sub { push @$table_info, {table => $_[1], info => $_[2] } },
543
        exclude => $exclude
544
    );
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
545
    
cleanup test
Yuki Kimoto authored on 2011-08-16
546
    return [sort {$a->{table} cmp $b->{table} } @$table_info];
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
547
}
548

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
549
sub get_column_info {
cleanup
Yuki Kimoto authored on 2011-10-21
550
    my ($self, %opt) = @_;
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
551
    
cleanup
Yuki Kimoto authored on 2011-10-21
552
    my $exclude_table = delete $opt{exclude_table};
553
    croak qq/"$_" is wrong option/ for keys %opt;
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
554
    
555
    my $column_info = [];
556
    $self->each_column(
557
        sub { push @$column_info, {table => $_[1], column => $_[2], info => $_[3] } },
558
        exclude_table => $exclude_table
559
    );
560
    
561
    return [
562
      sort {$a->{table} cmp $b->{table} || $a->{column} cmp $b->{column} }
cleanup
Yuki Kimoto authored on 2011-08-16
563
        @$column_info];
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
564
}
565

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
566
sub helper {
567
    my $self = shift;
568
    
569
    # Register method
570
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
571
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
572
    
573
    return $self;
574
}
575

            
cleanup
yuki-kimoto authored on 2010-10-17
576
sub insert {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
577
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
578
    
cleanup
Yuki Kimoto authored on 2011-10-21
579
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
580
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
581
    my %opt = @_;
micro optimization
Yuki Kimoto authored on 2011-10-23
582
    warn "insert method param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
583
    $param ||= delete $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
584
    
585
    # Timestamp
cleanup
Yuki Kimoto authored on 2011-10-21
586
    if ($opt{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
587
        my $columns = $insert_timestamp->[0];
588
        $columns = [$columns] unless ref $columns eq 'ARRAY';
589
        my $value = $insert_timestamp->[1];
590
        $value = $value->() if ref $value eq 'CODE';
591
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
592
    }
cleanup
Yuki Kimoto authored on 2011-10-21
593
    
594
    # Merge id to parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
595
    my @cleanup;
micro optimization
Yuki Kimoto authored on 2011-10-23
596
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
597
        croak "insert id option must be specified with primary_key option"
micro optimization
Yuki Kimoto authored on 2011-10-23
598
          unless $opt{primary_key};
599
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
600
        $opt{id} = [$opt{id}] unless ref $opt{id};
601
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
602
           my $key = $opt{primary_key}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
603
           next if exists $param->{$key};
micro optimization
Yuki Kimoto authored on 2011-10-23
604
           $param->{$key} = $opt{id}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
605
           push @cleanup, $key;
micro optimization
Yuki Kimoto authored on 2011-10-23
606
        }
607
    }
cleanup
Yuki Kimoto authored on 2011-10-21
608
    
cleanup
Yuki Kimoto authored on 2011-04-02
609
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-10-21
610
    my $sql = "insert ";
cleanup
Yuki Kimoto authored on 2011-10-21
611
    $sql .= "$opt{prefix} " if defined $opt{prefix};
612
    $sql .= "into " . $self->_q($opt{table}) . " "
613
      . $self->values_clause($param, {wrap => $opt{wrap}}) . " ";
micro optimization
Yuki Kimoto authored on 2011-10-23
614

            
615
    # Remove id from parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
616
    delete $param->{$_} for @cleanup;
packaging one directory
yuki-kimoto authored on 2009-11-16
617
    
618
    # Execute query
micro optimization
Yuki Kimoto authored on 2011-10-23
619
    $opt{statement} = 'insert';
micro optimization
Yuki Kimoto authored on 2011-10-23
620
    $self->execute($sql, $param, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
621
}
622

            
micro optimization
Yuki Kimoto authored on 2011-10-23
623
sub _merge_id_to_param {
624
    my ($self, $id, $primary_keys, $param) = @_;
625
    
626
    # Create parameter
627
    $id = [$id] unless ref $id;
628
    
629
    return $param;
630
}
631

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
632
sub insert_timestamp {
633
    my $self = shift;
634
    
635
    if (@_) {
636
        $self->{insert_timestamp} = [@_];
637
        
638
        return $self;
639
    }
640
    return $self->{insert_timestamp};
641
}
642

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
643
sub include_model {
644
    my ($self, $name_space, $model_infos) = @_;
645
    
cleanup
Yuki Kimoto authored on 2011-04-02
646
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
647
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
648
    
649
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
650
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
651

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
652
        # Load name space module
cleanup
Yuki Kimoto authored on 2011-04-25
653
        croak qq{"$name_space" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
654
          if $name_space =~ /[^\w:]/;
655
        eval "use $name_space";
cleanup
Yuki Kimoto authored on 2011-04-25
656
        croak qq{Name space module "$name_space.pm" is needed. $@ }
657
            . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
658
          if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
659
        
660
        # Search model modules
661
        my $path = $INC{"$name_space.pm"};
662
        $path =~ s/\.pm$//;
663
        opendir my $dh, $path
cleanup
Yuki Kimoto authored on 2011-04-25
664
          or croak qq{Can't open directory "$path": $! } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
665
        $model_infos = [];
666
        while (my $module = readdir $dh) {
667
            push @$model_infos, $module
668
              if $module =~ s/\.pm$//;
669
        }
670
        close $dh;
671
    }
672
    
cleanup
Yuki Kimoto authored on 2011-04-02
673
    # Include models
cleanup
Yuki Kimoto authored on 2011-10-21
674
    for my $model_info (@$model_infos) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
675
        
cleanup
Yuki Kimoto authored on 2011-04-02
676
        # Load model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
677
        my $model_class;
678
        my $model_name;
679
        my $model_table;
680
        if (ref $model_info eq 'HASH') {
681
            $model_class = $model_info->{class};
682
            $model_name  = $model_info->{name};
683
            $model_table = $model_info->{table};
684
            
685
            $model_name  ||= $model_class;
686
            $model_table ||= $model_name;
687
        }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
688
        else { $model_class = $model_name = $model_table = $model_info }
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
689
        my $mclass = "${name_space}::$model_class";
cleanup
Yuki Kimoto authored on 2011-04-25
690
        croak qq{"$mclass" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
691
          if $mclass =~ /[^\w:]/;
692
        unless ($mclass->can('isa')) {
693
            eval "use $mclass";
cleanup
Yuki Kimoto authored on 2011-04-25
694
            croak "$@ " . _subname if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
695
        }
696
        
cleanup
Yuki Kimoto authored on 2011-04-02
697
        # Create model
cleanup
Yuki Kimoto authored on 2011-10-21
698
        my $opt = {};
699
        $opt->{model_class} = $mclass if $mclass;
700
        $opt->{name}        = $model_name if $model_name;
701
        $opt->{table}       = $model_table if $model_table;
702
        $self->create_model($opt);
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
703
    }
704
    
705
    return $self;
706
}
707

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

            
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
710
sub mapper {
711
    my $self = shift;
712
    return DBIx::Custom::Mapper->new(@_);
713
}
714

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
715
sub merge_param {
716
    my ($self, @params) = @_;
717
    
cleanup
Yuki Kimoto authored on 2011-04-02
718
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
719
    my $merge = {};
cleanup
Yuki Kimoto authored on 2011-10-21
720
    for my $param (@params) {
721
        for my $column (keys %$param) {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
722
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
723
            
724
            if (exists $merge->{$column}) {
725
                $merge->{$column} = [$merge->{$column}]
726
                  unless ref $merge->{$column} eq 'ARRAY';
727
                push @{$merge->{$column}},
728
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
729
            }
730
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
731
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
732
            }
733
        }
734
    }
735
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
736
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
737
}
738

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
739
sub model {
740
    my ($self, $name, $model) = @_;
741
    
cleanup
Yuki Kimoto authored on 2011-04-02
742
    # Set model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
743
    if ($model) {
744
        $self->models->{$name} = $model;
745
        return $self;
746
    }
747
    
748
    # Check model existance
cleanup
Yuki Kimoto authored on 2011-04-25
749
    croak qq{Model "$name" is not included } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
750
      unless $self->models->{$name};
751
    
cleanup
Yuki Kimoto authored on 2011-04-02
752
    # Get model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
753
    return $self->models->{$name};
754
}
755

            
cleanup
Yuki Kimoto authored on 2011-03-21
756
sub mycolumn {
757
    my ($self, $table, $columns) = @_;
758
    
cleanup
Yuki Kimoto authored on 2011-04-02
759
    # Create column clause
760
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
761
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
762
    push @column, $self->_q($table) . "." . $self->_q($_) .
763
      " as " . $self->_q($_)
764
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
765
    
766
    return join (', ', @column);
767
}
768

            
added dbi_options attribute
kimoto authored on 2010-12-20
769
sub new {
770
    my $self = shift->SUPER::new(@_);
771
    
cleanup
Yuki Kimoto authored on 2011-04-02
772
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
773
    my @attrs = keys %$self;
cleanup
Yuki Kimoto authored on 2011-10-21
774
    for my $attr (@attrs) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
775
        croak qq{Invalid attribute: "$attr" } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
776
          unless $self->can($attr);
777
    }
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
778

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
779
    # DEPRECATED
cleanup
Yuki Kimoto authored on 2011-08-13
780
    $self->{_tags} = {
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
781
        '?'     => \&DBIx::Custom::Tag::placeholder,
782
        '='     => \&DBIx::Custom::Tag::equal,
783
        '<>'    => \&DBIx::Custom::Tag::not_equal,
784
        '>'     => \&DBIx::Custom::Tag::greater_than,
785
        '<'     => \&DBIx::Custom::Tag::lower_than,
786
        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
787
        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
788
        'like'  => \&DBIx::Custom::Tag::like,
789
        'in'    => \&DBIx::Custom::Tag::in,
790
        'insert_param' => \&DBIx::Custom::Tag::insert_param,
791
        'update_param' => \&DBIx::Custom::Tag::update_param
cleanup
Yuki Kimoto authored on 2011-08-13
792
    };
793
    
794
    return $self;
795
}
796

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

            
799
sub order {
800
    my $self = shift;
801
    return DBIx::Custom::Order->new(dbi => $self, @_);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
802
}
803

            
cleanup
yuki-kimoto authored on 2010-10-17
804
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
805
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
806
    
807
    # Register filter
808
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
809
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
810
    
cleanup
Yuki Kimoto authored on 2011-04-02
811
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
812
}
packaging one directory
yuki-kimoto authored on 2009-11-16
813

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
817
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
818
    my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
819
               : defined $opt{table} ? [$opt{table}]
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
820
               : [];
cleanup
Yuki Kimoto authored on 2011-10-21
821
    $opt{table} = $tables;
cleanup
Yuki Kimoto authored on 2011-10-21
822
    my $where_param = $opt{where_param} || delete $opt{param} || {};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
823
    
cleanup
Yuki Kimoto authored on 2011-03-09
824
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
825
    if ($opt{relation}) {
826
        warn "select() relation option is DEPRECATED!";
827
        $self->_add_relation_table($tables, $opt{relation});
828
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
829
    
cleanup
Yuki Kimoto authored on 2011-04-02
830
    # Select statement
micro optimization
Yuki Kimoto authored on 2011-09-30
831
    my $sql = 'select ';
packaging one directory
yuki-kimoto authored on 2009-11-16
832
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
833
    # Prefix
cleanup
Yuki Kimoto authored on 2011-10-21
834
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
835
    
cleanup
Yuki Kimoto authored on 2011-10-21
836
    # Column
cleanup
Yuki Kimoto authored on 2011-10-21
837
    if (defined $opt{column}) {
838
        my $columns
839
          = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
cleanup
Yuki Kimoto authored on 2011-10-21
840
        for my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
841
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
842
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
843
            }
844
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
845
                if (@$column == 3 && $column->[1] eq 'as') {
846
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
847
                    splice @$column, 1, 1;
848
                }
849
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
850
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
851
            }
cleanup
Yuki Kimoto authored on 2011-04-02
852
            unshift @$tables, @{$self->_search_tables($column)};
micro optimization
Yuki Kimoto authored on 2011-09-30
853
            $sql .= "$column, ";
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
854
        }
micro optimization
Yuki Kimoto authored on 2011-09-30
855
        $sql =~ s/, $/ /;
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
856
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
857
    else { $sql .= '* ' }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
858
    
859
    # Table
micro optimization
Yuki Kimoto authored on 2011-09-30
860
    $sql .= 'from ';
cleanup
Yuki Kimoto authored on 2011-10-21
861
    if ($opt{relation}) {
cleanup
Yuki Kimoto authored on 2011-03-30
862
        my $found = {};
cleanup
Yuki Kimoto authored on 2011-10-21
863
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-09-30
864
            $sql .= $self->_q($table) . ', ' unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
865
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
866
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
867
    }
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
868
    else { $sql .= $self->_q($tables->[-1] || '') . ' ' }
micro optimization
Yuki Kimoto authored on 2011-09-30
869
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2011-10-21
870
    croak "select method table option must be specified " . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
871
      unless $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
872

            
cleanup
Yuki Kimoto authored on 2011-04-02
873
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
874
    unshift @$tables,
875
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
876
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
877
    # Where
cleanup
Yuki Kimoto authored on 2011-10-21
878
    my $where = defined $opt{id}
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
879
              ? $self->_id_to_param(delete $opt{id}, $opt{primary_key}, $tables->[-1])
cleanup
Yuki Kimoto authored on 2011-10-21
880
              : $opt{where};
881
    my $w = $self->_where_clause_and_param($where, $where_param);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
882
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
883
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-10-21
884
    unshift @$tables, @{$self->_search_tables($w->{clause})};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
885
    
cleanup
Yuki Kimoto authored on 2011-10-21
886
    # Join statement
cleanup
Yuki Kimoto authored on 2011-10-21
887
    $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
888
    
cleanup
Yuki Kimoto authored on 2011-03-09
889
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-10-21
890
    $sql .= "$w->{clause} ";
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
891
    
cleanup
Yuki Kimoto authored on 2011-03-08
892
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
893
    $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
cleanup
Yuki Kimoto authored on 2011-10-21
894
      if $opt{relation};
cleanup
Yuki Kimoto authored on 2011-03-08
895
    
packaging one directory
yuki-kimoto authored on 2009-11-16
896
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
897
    $opt{statement} = 'select';
cleanup
Yuki Kimoto authored on 2011-10-21
898
    my $result = $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
899
    
micro optimization
Yuki Kimoto authored on 2011-10-23
900
    $result;
packaging one directory
yuki-kimoto authored on 2009-11-16
901
}
902

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
903
sub setup_model {
904
    my $self = shift;
905
    
cleanup
Yuki Kimoto authored on 2011-04-02
906
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
907
    $self->each_column(
908
        sub {
909
            my ($self, $table, $column, $column_info) = @_;
910
            if (my $model = $self->models->{$table}) {
911
                push @{$model->columns}, $column;
912
            }
913
        }
914
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
915
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
916
}
917

            
update pod
Yuki Kimoto authored on 2011-08-10
918
sub show_datatype {
919
    my ($self, $table) = @_;
920
    croak "Table name must be specified" unless defined $table;
921
    print "$table\n";
922
    
923
    my $result = $self->select(table => $table, where => "'0' <> '0'");
924
    my $sth = $result->sth;
925

            
926
    my $columns = $sth->{NAME};
927
    my $data_types = $sth->{TYPE};
928
    
929
    for (my $i = 0; $i < @$columns; $i++) {
930
        my $column = $columns->[$i];
931
        my $data_type = $data_types->[$i];
932
        print "$column: $data_type\n";
933
    }
934
}
935

            
936
sub show_typename {
937
    my ($self, $t) = @_;
938
    croak "Table name must be specified" unless defined $t;
939
    print "$t\n";
940
    
941
    $self->each_column(sub {
942
        my ($self, $table, $column, $infos) = @_;
943
        return unless $table eq $t;
944
        my $typename = $infos->{TYPE_NAME};
945
        print "$column: $typename\n";
946
    });
947
    
948
    return $self;
949
}
950

            
test cleanup
Yuki Kimoto authored on 2011-08-15
951
sub show_tables {
952
    my $self = shift;
953
    
954
    my %tables;
955
    $self->each_table(sub { $tables{$_[1]}++ });
956
    print join("\n", sort keys %tables) . "\n";
957
    return $self;
958
}
959

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

            
963
    $self->{_type_rule_is_called} = 1;
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
964
    
965
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
966
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
967
        
968
        # Into
cleanup
Yuki Kimoto authored on 2011-10-21
969
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
970
            my $into = "into$i";
cleanup
Yuki Kimoto authored on 2011-08-16
971
            my $exists_into = exists $type_rule->{$into};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
972
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
973
            $self->{type_rule} = $type_rule;
974
            $self->{"_$into"} = {};
cleanup
Yuki Kimoto authored on 2011-10-21
975
            for my $type_name (keys %{$type_rule->{$into} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
976
                croak qq{type name of $into section must be lower case}
977
                  if $type_name =~ /[A-Z]/;
978
            }
cleanup
Yuki Kimoto authored on 2011-08-16
979
            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
980
            $self->each_column(sub {
981
                my ($dbi, $table, $column, $column_info) = @_;
982
                
983
                my $type_name = lc $column_info->{TYPE_NAME};
984
                if ($type_rule->{$into} &&
985
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
986
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
987
                    return unless exists $type_rule->{$into}->{$type_name};
988
                    if  (defined $filter && ref $filter ne 'CODE') 
989
                    {
990
                        my $fname = $filter;
991
                        croak qq{Filter "$fname" is not registered" } . _subname
992
                          unless exists $self->filters->{$fname};
993
                        
994
                        $filter = $self->filters->{$fname};
995
                    }
996

            
micro optimization
Yuki Kimoto authored on 2011-07-30
997
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
998
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
999
                }
1000
            });
1001
        }
1002

            
1003
        # From
cleanup
Yuki Kimoto authored on 2011-10-21
1004
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1005
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
cleanup
Yuki Kimoto authored on 2011-10-21
1006
            for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1007
                croak qq{data type of from$i section must be lower case or number}
1008
                  if $data_type =~ /[A-Z]/;
1009
                my $fname = $type_rule->{"from$i"}{$data_type};
1010
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1011
                    croak qq{Filter "$fname" is not registered" } . _subname
1012
                      unless exists $self->filters->{$fname};
1013
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1014
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1015
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1016
            }
1017
        }
1018
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1019
        return $self;
1020
    }
1021
    
1022
    return $self->{type_rule} || {};
1023
}
1024

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1028
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1029
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
1030
    my %opt = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1031
    warn "update param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
1032
    warn "update method where_param option is DEPRECATED!"
1033
      if $opt{where_param};
cleanup
Yuki Kimoto authored on 2011-10-21
1034
    $param ||= $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1035
    
cleanup
Yuki Kimoto authored on 2011-10-21
1036
    # Don't allow update all rows
1037
    croak qq{update method where option must be specified } . _subname
1038
      if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1039
    
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1040
    # Timestamp
cleanup
Yuki Kimoto authored on 2011-10-21
1041
    if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1042
        my $columns = $update_timestamp->[0];
1043
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1044
        my $value = $update_timestamp->[1];
1045
        $value = $value->() if ref $value eq 'CODE';
1046
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1047
    }
1048

            
cleanup
Yuki Kimoto authored on 2011-10-21
1049
    # Assign clause
cleanup
Yuki Kimoto authored on 2011-10-21
1050
    my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
cleanup
Yuki Kimoto authored on 2011-10-21
1051
    
1052
    # Convert id to where parameter
1053
    my $where = defined $opt{id}
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
1054
      ? $self->_id_to_param(delete $opt{id}, $opt{primary_key}, $opt{table})
cleanup
Yuki Kimoto authored on 2011-10-21
1055
      : $opt{where};
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1056

            
1057
    # Where
cleanup
Yuki Kimoto authored on 2011-10-21
1058
    my $w = $self->_where_clause_and_param($where, $opt{where_param});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1059
    
cleanup
Yuki Kimoto authored on 2011-10-21
1060
    # Merge where parameter to parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1061
    $param = $self->merge_param($param, $w->{param}) if keys %{$w->{param}};
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1062
    
cleanup
Yuki Kimoto authored on 2011-04-02
1063
    # Update statement
cleanup
Yuki Kimoto authored on 2011-10-21
1064
    my $sql = "update ";
1065
    $sql .= "$opt{prefix} " if defined $opt{prefix};
cleanup
Yuki Kimoto authored on 2011-10-21
1066
    $sql .= $self->_q($opt{table}) . " set $assign_clause $w->{clause} ";
cleanup
Yuki Kimoto authored on 2011-01-27
1067
    
cleanup
yuki-kimoto authored on 2010-10-17
1068
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
1069
    $opt{statement} = 'update';
micro optimization
Yuki Kimoto authored on 2011-10-23
1070
    $self->execute($sql, $param, %opt);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1071
}
1072

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1075
sub update_or_insert {
1076
    my $self = shift;
1077

            
cleanup
Yuki Kimoto authored on 2011-10-21
1078
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1079
    my $param  = shift;
1080
    my %opt = @_;
1081
    my $id = $opt{id};
1082
    my $primary_key = $opt{primary_key};
1083
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
1084
    croak "update_or_insert method need primary_key option " .
1085
          "when id is specified" . _subname
1086
      if defined $id && !defined $primary_key;
1087
    my $table  = $opt{table};
1088
    croak qq{"table" option must be specified } . _subname
1089
      unless defined $table;
1090
    my $select_option = $opt{select_option};
1091
    
1092
    my $rows = $self->select(table => $table, id => $id,
1093
        primary_key => $primary_key, %$select_option)->all;
1094
    
1095
    croak "selected row count must be one or zero" . _subname
1096
      if @$rows > 1;
1097
    
1098
    my $row = $rows->[0];
1099
    my @opt = (table => $table);
1100
    push @opt, id => $id, primary_key => $primary_key if defined $id;
1101
    push @opt, %opt;
1102
    
1103
    if ($row) {
1104
        return $self->update($param, @opt);
1105
    }
1106
    else {
1107
        return $self->insert($param, @opt);
1108
    }
1109
}
1110

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1111
sub update_timestamp {
1112
    my $self = shift;
1113
    
1114
    if (@_) {
1115
        $self->{update_timestamp} = [@_];
1116
        
1117
        return $self;
1118
    }
1119
    return $self->{update_timestamp};
1120
}
1121

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1122
sub values_clause {
1123
    my ($self, $param, $opts) = @_;
1124
    
1125
    my $wrap = $opts->{wrap} || {};
1126
    
1127
    # Create insert parameter tag
micro optimization
Yuki Kimoto authored on 2011-10-23
1128
    my $safety = $self->{safety_character} || $self->safety_character;
improved performance
Yuki Kimoto authored on 2011-10-22
1129
    my $qp = $self->_q('');
fixed some quoted bug
Yuki Kimoto authored on 2011-10-22
1130
    my $q = substr($qp, 0, 1) || '';
1131
    my $p = substr($qp, 1, 1) || '';
improved performance
Yuki Kimoto authored on 2011-10-22
1132
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1133
    # Check unsafety keys
1134
    unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
1135
        for my $column (keys %$param) {
1136
            croak qq{"$column" is not safety column name } . _subname
1137
              unless $column =~ /^[$safety\.]+$/;
1138
        }
1139
    }
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1140
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1141
    # values clause(performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
1142
    '(' .
1143
    join(
1144
      ', ',
1145
      map { "$q$_$p" } sort keys %$param
1146
    ) .
1147
    ') values (' .
1148
    join(
1149
      ', ',
1150
      map {
1151
          ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1152
          $wrap->{$_} ? $wrap->{$_}->(":$_") :
1153
          ":$_";
1154
      } sort keys %$param
1155
    ) .
1156
    ')'
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1157
}
1158

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1161
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1162
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1163
    my ($self, $source, $after_build_sql) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1164
    
updated pod
Yuki Kimoto authored on 2011-06-21
1165
    # Cache
1166
    my $cache = $self->cache;
1167
    
1168
    # Query
1169
    my $query;
1170
    
1171
    # Get cached query
1172
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1173
        
updated pod
Yuki Kimoto authored on 2011-06-21
1174
        # Get query
1175
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1176
        
updated pod
Yuki Kimoto authored on 2011-06-21
1177
        # Create query
1178
        if ($q) {
1179
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1180
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1181
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1182
    }
1183
    
1184
    # Create query
1185
    unless ($query) {
1186

            
1187
        # Create query
1188
        my $builder = $self->query_builder;
1189
        $query = $builder->build_query($source);
1190

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

            
1197
        # Save query to cache
1198
        $self->cache_method->(
1199
            $self, $source,
1200
            {
1201
                sql     => $query->sql, 
1202
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1203
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1204
            }
1205
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1206
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1207

            
1208
    # Filter SQL
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1209
    if ($after_build_sql) {
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1210
        my $sql = $query->sql;
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1211
        $sql = $after_build_sql->($sql);
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1212
        $query->sql($sql);
1213
    }
1214
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1215
    # Save sql
1216
    $self->last_sql($query->sql);
1217
    
updated pod
Yuki Kimoto authored on 2011-06-21
1218
    # Prepare statement handle
1219
    my $sth;
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1220
    eval { $sth = $self->dbh->prepare($query->{sql}) };
updated pod
Yuki Kimoto authored on 2011-06-21
1221
    
1222
    if ($@) {
1223
        $self->_croak($@, qq{. Following SQL is executed.\n}
1224
                        . qq{$query->{sql}\n} . _subname);
1225
    }
1226
    
1227
    # Set statement handle
1228
    $query->sth($sth);
1229
    
1230
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1231
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1232
    
1233
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1234
}
1235

            
cleanup
Yuki Kimoto authored on 2011-04-02
1236
sub _create_bind_values {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1237
    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1238
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1239
    $bind_type = _array_to_hash($bind_type) if ref $bind_type eq 'ARRAY';
1240
    
cleanup
Yuki Kimoto authored on 2011-04-02
1241
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
1242
    my @bind;
1243
    my @types;
1244
    my %count;
1245
    my %not_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1246
    for my $column (@$columns) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
1247
        
micro optimization
Yuki Kimoto authored on 2011-10-23
1248
        # Bind value
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1249
        if(ref $params->{$column} eq 'ARRAY') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1250
            my $i = $count{$column} || 0;
1251
            $i += $not_exists{$column} || 0;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1252
            my $found;
1253
            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1254
                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1255
                    $not_exists{$column}++;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1256
                }
1257
                else  {
micro optimization
Yuki Kimoto authored on 2011-10-23
1258
                    push @bind, $params->{$column}->[$k];
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1259
                    $found = 1;
1260
                    last
1261
                }
1262
            }
1263
            next unless $found;
1264
        }
micro optimization
Yuki Kimoto authored on 2011-10-23
1265
        else { push @bind, $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1266
        
cleanup
Yuki Kimoto authored on 2011-01-12
1267
        # Filter
micro optimization
Yuki Kimoto authored on 2011-10-23
1268
        if (my $f = $filter->{$column} || $self->{default_out_filter} || '') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1269
            $bind[-1] = $f->($bind[-1]);
micro optimization
Yuki Kimoto authored on 2011-10-23
1270
        }
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1271
        
1272
        # Type rule
micro optimization
Yuki Kimoto authored on 2011-10-23
1273
        if ($self->{_type_rule_is_called}) {
1274
            my $tf1 = $self->{"_into1"}->{dot}->{$column}
1275
              || $type_filters->{1}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1276
            $bind[-1] = $tf1->($bind[-1]) if $tf1;
micro optimization
Yuki Kimoto authored on 2011-10-23
1277
            my $tf2 = $self->{"_into2"}->{dot}->{$column}
1278
              || $type_filters->{2}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1279
            $bind[-1] = $tf2->($bind[-1]) if $tf2;
micro optimization
Yuki Kimoto authored on 2011-10-23
1280
        }
micro optimization
Yuki Kimoto authored on 2011-10-22
1281
       
micro optimization
Yuki Kimoto authored on 2011-10-23
1282
        # Bind types
micro optimization
Yuki Kimoto authored on 2011-10-23
1283
        push @types, $bind_type->{$column};
removed reconnect method
yuki-kimoto authored on 2010-05-28
1284
        
1285
        # Count up 
micro optimization
Yuki Kimoto authored on 2011-10-23
1286
        $count{$column}++;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1287
    }
1288
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1289
    return (\@bind, \@types);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1290
}
1291

            
cleanup
Yuki Kimoto authored on 2011-10-21
1292
sub _id_to_param {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1293
    my ($self, $id, $primary_keys, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1294
    
1295
    # Check primary key
cleanup
Yuki Kimoto authored on 2011-10-21
1296
    croak "primary_key option " .
1297
          "must be specified with id option " . _subname
1298
      unless defined $primary_keys;
1299
    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
improved error messages
Yuki Kimoto authored on 2011-04-18
1300
    
cleanup
Yuki Kimoto authored on 2011-06-08
1301
    # Create parameter
1302
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1303
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1304
        $id = [$id] unless ref $id;
1305
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1306
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1307
          unless !ref $id || ref $id eq 'ARRAY';
1308
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1309
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1310
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1311
        for(my $i = 0; $i < @$primary_keys; $i ++) {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1312
           my $key = $primary_keys->[$i];
1313
           $key = "$table." . $key if $table;
1314
           $param->{$key} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1315
        }
1316
    }
1317
    
cleanup
Yuki Kimoto authored on 2011-06-08
1318
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1319
}
1320

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1321
sub _connect {
1322
    my $self = shift;
1323
    
1324
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1325
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1326
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1327
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1328
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1329
    croak qq{"dsn" must be specified } . _subname
1330
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1331
    my $user        = $self->user;
1332
    my $password    = $self->password;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1333
    my $option = $self->_option;
1334
    $option = {%{$self->default_option}, %$option};
cleanup
Yuki Kimoto authored on 2011-08-16
1335
    
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1336
    # Connect
cleanup
Yuki Kimoto authored on 2011-08-16
1337
    my $dbh;
1338
    eval {
1339
        $dbh = DBI->connect(
1340
            $dsn,
1341
            $user,
1342
            $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1343
            $option
cleanup
Yuki Kimoto authored on 2011-08-16
1344
        );
1345
    };
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1346
    
1347
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1348
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1349
    
1350
    return $dbh;
1351
}
1352

            
cleanup
yuki-kimoto authored on 2010-10-17
1353
sub _croak {
1354
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1355
    
1356
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1357
    $append ||= "";
1358
    
1359
    # Verbose
1360
    if ($Carp::Verbose) { croak $error }
1361
    
1362
    # Not verbose
1363
    else {
1364
        
1365
        # Remove line and module infromation
1366
        my $at_pos = rindex($error, ' at ');
1367
        $error = substr($error, 0, $at_pos);
1368
        $error =~ s/\s+$//;
1369
        croak "$error$append";
1370
    }
1371
}
1372

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1375
sub _need_tables {
1376
    my ($self, $tree, $need_tables, $tables) = @_;
1377
    
cleanup
Yuki Kimoto authored on 2011-04-02
1378
    # Get needed tables
cleanup
Yuki Kimoto authored on 2011-10-21
1379
    for my $table (@$tables) {
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1380
        if ($tree->{$table}) {
1381
            $need_tables->{$table} = 1;
1382
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1383
        }
1384
    }
1385
}
1386

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1387
sub _option {
1388
    my $self = shift;
1389
    my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1390
    warn "dbi_options is DEPRECATED! use option instead\n"
1391
      if keys %{$self->dbi_options};
1392
    warn "dbi_option is DEPRECATED! use option instead\n"
1393
      if keys %{$self->dbi_option};
1394
    return $option;
1395
}
1396

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1397
sub _push_join {
1398
    my ($self, $sql, $join, $join_tables) = @_;
1399
    
cleanup
Yuki Kimoto authored on 2011-10-21
1400
    $join = [$join] unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-10-21
1401
    
cleanup
Yuki Kimoto authored on 2011-04-02
1402
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1403
    return unless @$join;
1404
    
cleanup
Yuki Kimoto authored on 2011-04-02
1405
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1406
    my $tree = {};
1407
    for (my $i = 0; $i < @$join; $i++) {
1408
        
cleanup
Yuki Kimoto authored on 2011-07-28
1409
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1410
        my $join_clause;;
1411
        my $option;
1412
        if (ref $join->[$i] eq 'HASH') {
1413
            $join_clause = $join->[$i]->{clause};
1414
            $option = {table => $join->[$i]->{table}};
1415
        }
1416
        else {
1417
            $join_clause = $join->[$i];
1418
            $option = {};
1419
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1420

            
1421
        # Find tables in join clause
added join new syntax
Yuki Kimoto authored on 2011-07-28
1422
        my $table1;
1423
        my $table2;
1424
        if (my $table = $option->{table}) {
1425
            $table1 = $table->[0];
1426
            $table2 = $table->[1];
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1427
        }
cleanup
Yuki Kimoto authored on 2011-07-28
1428
        else {
1429
            my $q = $self->_quote;
1430
            my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1431
            $j_clause =~ s/'.+?'//g;
1432
            my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1433
            $j_clause =~ s/[$q_re]//g;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1434
            
1435
            my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
cleanup
Yuki Kimoto authored on 2011-07-28
1436
            my $c = $self->safety_character;
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1437
            my $join_re = qr/($c+)\.$c+[^$c].*?($c+)\.$c+/sm;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1438
            for my $clause (@j_clauses) {
1439
                if ($clause =~ $join_re) {
1440
                    $table1 = $1;
1441
                    $table2 = $2;
1442
                    last;
1443
                }                
cleanup
Yuki Kimoto authored on 2011-07-28
1444
            }
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1445
        }
added join new syntax
Yuki Kimoto authored on 2011-07-28
1446
        croak qq{join clause must have two table name after "on" keyword. } .
1447
              qq{"$join_clause" is passed }  . _subname
1448
          unless defined $table1 && defined $table2;
1449
        croak qq{right side table of "$join_clause" must be unique }
1450
            . _subname
1451
          if exists $tree->{$table2};
1452
        croak qq{Same table "$table1" is specified} . _subname
1453
          if $table1 eq $table2;
1454
        $tree->{$table2}
1455
          = {position => $i, parent => $table1, join => $join_clause};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1456
    }
1457
    
cleanup
Yuki Kimoto authored on 2011-04-02
1458
    # Search need tables
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1459
    my $need_tables = {};
1460
    $self->_need_tables($tree, $need_tables, $join_tables);
cleanup
Yuki Kimoto authored on 2011-10-21
1461
    my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} }
1462
      keys %$need_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1463
    
1464
    # Add join clause
cleanup
Yuki Kimoto authored on 2011-10-21
1465
    $$sql .= $tree->{$_}{join} . ' ' for @need_tables;
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1466
}
cleanup
Yuki Kimoto authored on 2011-03-08
1467

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1468
sub _quote {
1469
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-22
1470
    return $self->{reserved_word_quote} || $self->quote || '';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1471
}
1472

            
cleanup
Yuki Kimoto authored on 2011-07-29
1473
sub _q {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1474
    my ($self, $value, $quotemeta) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1475
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1476
    my $quote = $self->{reserved_word_quote}
1477
      || $self->{quote} || $self->quote || '';
1478
    return "$quote$value$quote"
1479
      if !$quotemeta && ($quote eq '`' || $quote eq '"');
1480
    
cleanup
Yuki Kimoto authored on 2011-07-29
1481
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1482
    my $p;
1483
    if (defined $quote && length $quote > 1) {
1484
        $p = substr($quote, 1, 1);
1485
    }
1486
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1487
    
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1488
    if ($quotemeta) {
1489
        $q = quotemeta($q);
1490
        $p = quotemeta($p);
1491
    }
1492
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1493
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1494
}
1495

            
cleanup
Yuki Kimoto authored on 2011-04-02
1496
sub _remove_duplicate_table {
1497
    my ($self, $tables, $main_table) = @_;
1498
    
1499
    # Remove duplicate table
1500
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1501
    delete $tables{$main_table} if $main_table;
1502
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1503
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1504
    if (my $q = $self->_quote) {
1505
        $q = quotemeta($q);
1506
        $_ =~ s/[$q]//g for @$new_tables;
1507
    }
1508

            
1509
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1510
}
1511

            
cleanup
Yuki Kimoto authored on 2011-04-02
1512
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1513
    my ($self, $source) = @_;
1514
    
cleanup
Yuki Kimoto authored on 2011-04-02
1515
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1516
    my $tables = [];
1517
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1518
    my $q = $self->_quote;
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1519
    my $quoted_safety_character_re = $self->_q("?([$safety_character]+)", 1);
1520
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1521
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1522
    while ($source =~ /$table_re/g) {
1523
        push @$tables, $1;
1524
    }
1525
    
1526
    return $tables;
1527
}
1528

            
cleanup
Yuki Kimoto authored on 2011-04-02
1529
sub _where_to_obj {
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1530
    my ($self, $where) = @_;
1531
    
cleanup
Yuki Kimoto authored on 2011-04-02
1532
    my $obj;
1533
    
1534
    # Hash
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1535
    if (ref $where eq 'HASH') {
1536
        my $clause = ['and'];
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1537
        my $q = $self->_quote;
cleanup
Yuki Kimoto authored on 2011-10-21
1538
        for my $column (keys %$where) {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1539
            my $table;
1540
            my $c;
1541
            if ($column =~ /(?:(.*?)\.)?(.*)/) {
1542
                $table = $1;
1543
                $c = $2;
1544
            }
1545
            
1546
            my $table_quote;
1547
            $table_quote = $self->_q($table) if defined $table;
1548
            my $column_quote = $self->_q($c);
1549
            $column_quote = $table_quote . '.' . $column_quote
1550
              if defined $table_quote;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1551
            push @$clause, "$column_quote = :$column" for keys %$where;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1552
        }
cleanup
Yuki Kimoto authored on 2011-04-02
1553
        $obj = $self->where(clause => $clause, param => $where);
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1554
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1555
    
1556
    # DBIx::Custom::Where object
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1557
    elsif (ref $where eq 'DBIx::Custom::Where') {
cleanup
Yuki Kimoto authored on 2011-04-02
1558
        $obj = $where;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1559
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1560
    
updated pod
Yuki Kimoto authored on 2011-06-21
1561
    # Array
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1562
    elsif (ref $where eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-04-02
1563
        $obj = $self->where(
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1564
            clause => $where->[0],
1565
            param  => $where->[1]
1566
        );
1567
    }
1568
    
cleanup
Yuki Kimoto authored on 2011-04-02
1569
    # Check where argument
improved error messages
Yuki Kimoto authored on 2011-04-18
1570
    croak qq{"where" must be hash reference or DBIx::Custom::Where object}
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
1571
        . qq{or array reference, which contains where clause and parameter}
cleanup
Yuki Kimoto authored on 2011-04-25
1572
        . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
1573
      unless ref $obj eq 'DBIx::Custom::Where';
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1574
    
cleanup
Yuki Kimoto authored on 2011-04-02
1575
    return $obj;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1576
}
1577

            
cleanup
Yuki Kimoto authored on 2011-10-21
1578
sub _where_clause_and_param {
cleanup
Yuki Kimoto authored on 2011-10-25
1579
    my ($self, $where, $param, $id, $primary_key, $table) = @_;
1580

            
cleanup
Yuki Kimoto authored on 2011-10-21
1581
    $where ||= {};
cleanup
Yuki Kimoto authored on 2011-10-25
1582
    $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
cleanup
Yuki Kimoto authored on 2011-10-21
1583
    $param ||= {};
1584
    my $w = {};
1585
    my $where_clause = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1586

            
cleanup
Yuki Kimoto authored on 2011-10-21
1587
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1588
        $w->{clause} = "where " . $where->[0];
1589
        $w->{param} = $where->[1];
1590
    }
1591
    elsif (ref $where) {
1592
        $where = $self->_where_to_obj($where);
1593
        $w->{param} = keys %$param
1594
                    ? $self->merge_param($param, $where->param)
1595
                    : $where->param;
1596
        $w->{clause} = $where->to_string;
1597
    }
1598
    elsif ($where) {
1599
        $w->{clause} = "where $where";
1600
        $w->{param} = $param;
1601
    }
1602
    
1603
    return $w;
1604
}
1605

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

            
1609
    # Initialize filters
1610
    $self->{filter} ||= {};
micro optimization
Yuki Kimoto authored on 2011-07-30
1611
    $self->{filter}{on} = 1;
updated pod
Yuki Kimoto authored on 2011-06-21
1612
    $self->{filter}{out} ||= {};
1613
    $self->{filter}{in} ||= {};
1614
    $self->{filter}{end} ||= {};
1615
    
1616
    # Usage
1617
    my $usage = "Usage: \$dbi->apply_filter(" .
1618
                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1619
                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1620
    
1621
    # Apply filter
1622
    for (my $i = 0; $i < @cinfos; $i += 2) {
1623
        
1624
        # Column
1625
        my $column = $cinfos[$i];
1626
        if (ref $column eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-10-21
1627
            for my $c (@$column) {
updated pod
Yuki Kimoto authored on 2011-06-21
1628
                push @cinfos, $c, $cinfos[$i + 1];
1629
            }
1630
            next;
1631
        }
1632
        
1633
        # Filter infomation
1634
        my $finfo = $cinfos[$i + 1] || {};
1635
        croak "$usage (table: $table) " . _subname
1636
          unless  ref $finfo eq 'HASH';
cleanup
Yuki Kimoto authored on 2011-10-21
1637
        for my $ftype (keys %$finfo) {
updated pod
Yuki Kimoto authored on 2011-06-21
1638
            croak "$usage (table: $table) " . _subname
1639
              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1640
        }
1641
        
1642
        # Set filters
cleanup
Yuki Kimoto authored on 2011-10-21
1643
        for my $way (qw/in out end/) {
updated pod
Yuki Kimoto authored on 2011-06-21
1644
        
1645
            # Filter
1646
            my $filter = $finfo->{$way};
1647
            
1648
            # Filter state
1649
            my $state = !exists $finfo->{$way} ? 'not_exists'
1650
                      : !defined $filter        ? 'not_defined'
1651
                      : ref $filter eq 'CODE'   ? 'code'
1652
                      : 'name';
1653
            
1654
            # Filter is not exists
1655
            next if $state eq 'not_exists';
1656
            
1657
            # Check filter name
1658
            croak qq{Filter "$filter" is not registered } . _subname
1659
              if  $state eq 'name'
1660
               && ! exists $self->filters->{$filter};
1661
            
1662
            # Set filter
1663
            my $f = $state eq 'not_defined' ? undef
1664
                  : $state eq 'code'        ? $filter
1665
                  : $self->filters->{$filter};
1666
            $self->{filter}{$way}{$table}{$column} = $f;
1667
            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1668
            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1669
            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1670
        }
1671
    }
1672
    
1673
    return $self;
1674
}
1675

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1676
# DEPRECATED!
1677
has 'data_source';
1678
has dbi_options => sub { {} };
1679
has filter_check  => 1;
1680
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1681
has dbi_option => sub { {} };
1682
has default_dbi_option => sub {
1683
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1684
    return shift->default_option;
1685
};
1686

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1687
# DEPRECATED!
1688
sub method {
1689
    warn "method is DEPRECATED! use helper instead";
1690
    return shift->helper(@_);
1691
}
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1692

            
1693
# DEPRECATED!
1694
sub assign_param {
1695
    my $self = shift;
1696
    warn "assing_param is DEPRECATED! use assign_clause instead";
1697
    return $self->assign_clause(@_);
1698
}
1699

            
1700
# DEPRECATED
1701
sub update_param {
1702
    my ($self, $param, $opts) = @_;
1703
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1704
    warn "update_param is DEPRECATED! use assign_clause instead.";
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1705
    
1706
    # Create update parameter tag
1707
    my $tag = $self->assign_clause($param, $opts);
1708
    $tag = "set $tag" unless $opts->{no_set};
1709

            
1710
    return $tag;
1711
}
1712

            
updated pod
Yuki Kimoto authored on 2011-06-21
1713
# DEPRECATED!
1714
sub create_query {
1715
    warn "create_query is DEPRECATED! use query option of each method";
1716
    shift->_create_query(@_);
1717
}
1718

            
cleanup
Yuki Kimoto authored on 2011-06-13
1719
# DEPRECATED!
1720
sub apply_filter {
1721
    my $self = shift;
1722
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1723
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1724
    return $self->_apply_filter(@_);
1725
}
1726

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1733
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1734
    my $primary_keys = delete $opt{primary_key};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1735
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1736
    my $where = delete $opt{where};
1737
    my $param = delete $opt{param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1738
    
1739
    # Table
1740
    croak qq{"table" option must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1741
      unless $opt{table};
1742
    my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1743
    
1744
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1745
    my $where_param = $self->_id_to_param($where, $primary_keys);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1746
    
cleanup
Yuki Kimoto authored on 2011-10-21
1747
    return $self->select(where => $where_param, %opt);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1748
}
1749

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1754
    warn "delete_at is DEPRECATED! use delete method id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1755
    
cleanup
Yuki Kimoto authored on 2011-10-21
1756
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1757
    my $primary_keys = delete $opt{primary_key};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1758
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1759
    my $where = delete $opt{where};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1760
    
1761
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1762
    my $where_param = $self->_id_to_param($where, $primary_keys);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1763
    
cleanup
Yuki Kimoto authored on 2011-10-21
1764
    return $self->delete(where => $where_param, %opt);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1765
}
1766

            
cleanup
Yuki Kimoto authored on 2011-06-08
1767
# DEPRECATED!
1768
sub update_at {
1769
    my $self = shift;
1770

            
cleanup
Yuki Kimoto authored on 2011-10-21
1771
    warn "update_at is DEPRECATED! use update method id option instead";
cleanup
Yuki Kimoto authored on 2011-06-08
1772
    
cleanup
Yuki Kimoto authored on 2011-10-21
1773
    # Options
cleanup
Yuki Kimoto authored on 2011-06-08
1774
    my $param;
1775
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1776
    my %opt = @_;
1777
    my $primary_keys = delete $opt{primary_key};
cleanup
Yuki Kimoto authored on 2011-06-08
1778
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1779
    my $where = delete $opt{where};
1780
    my $p = delete $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-06-08
1781
    $param  ||= $p;
1782
    
1783
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1784
    my $where_param = $self->_id_to_param($where, $primary_keys);
cleanup
Yuki Kimoto authored on 2011-06-08
1785
    
cleanup
Yuki Kimoto authored on 2011-10-21
1786
    return $self->update(where => $where_param, param => $param, %opt);
cleanup
Yuki Kimoto authored on 2011-06-08
1787
}
1788

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1789
# DEPRECATED!
1790
sub insert_at {
1791
    my $self = shift;
1792
    
cleanup
Yuki Kimoto authored on 2011-10-21
1793
    warn "insert_at is DEPRECATED! use insert method id option instead";
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1794
    
cleanup
Yuki Kimoto authored on 2011-10-21
1795
    # Options
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1796
    my $param;
1797
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1798
    my %opt = @_;
1799
    my $primary_key = delete $opt{primary_key};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1800
    $primary_key = [$primary_key] unless ref $primary_key;
cleanup
Yuki Kimoto authored on 2011-10-21
1801
    my $where = delete $opt{where};
1802
    my $p = delete $opt{param} || {};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1803
    $param  ||= $p;
1804
    
1805
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1806
    my $where_param = $self->_id_to_param($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1807
    $param = $self->merge_param($where_param, $param);
1808
    
cleanup
Yuki Kimoto authored on 2011-10-21
1809
    return $self->insert(param => $param, %opt);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1810
}
1811

            
added warnings
Yuki Kimoto authored on 2011-06-07
1812
# DEPRECATED!
1813
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1814
    my $self = shift;
1815
    
added warnings
Yuki Kimoto authored on 2011-06-07
1816
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1817
    
1818
    # Merge tag
1819
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1820
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1821
    
1822
    return $self;
1823
}
1824

            
1825
# DEPRECATED!
1826
sub register_tag_processor {
1827
    my $self = shift;
1828
    warn "register_tag_processor is DEPRECATED!";
1829
    # Merge tag
1830
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1831
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1832
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1833
}
1834

            
cleanup
Yuki Kimoto authored on 2011-01-25
1835
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1836
sub default_bind_filter {
1837
    my $self = shift;
1838
    
cleanup
Yuki Kimoto authored on 2011-06-13
1839
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1840
    
cleanup
Yuki Kimoto authored on 2011-01-12
1841
    if (@_) {
1842
        my $fname = $_[0];
1843
        
1844
        if (@_ && !$fname) {
1845
            $self->{default_out_filter} = undef;
1846
        }
1847
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1848
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1849
              unless exists $self->filters->{$fname};
1850
        
1851
            $self->{default_out_filter} = $self->filters->{$fname};
1852
        }
1853
        return $self;
1854
    }
1855
    
1856
    return $self->{default_out_filter};
1857
}
1858

            
cleanup
Yuki Kimoto authored on 2011-01-25
1859
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1860
sub default_fetch_filter {
1861
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1862

            
cleanup
Yuki Kimoto authored on 2011-06-13
1863
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1864
    
1865
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1866
        my $fname = $_[0];
1867

            
cleanup
Yuki Kimoto authored on 2011-01-12
1868
        if (@_ && !$fname) {
1869
            $self->{default_in_filter} = undef;
1870
        }
1871
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1872
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1873
              unless exists $self->filters->{$fname};
1874
        
1875
            $self->{default_in_filter} = $self->filters->{$fname};
1876
        }
1877
        
1878
        return $self;
1879
    }
1880
    
many changed
Yuki Kimoto authored on 2011-01-23
1881
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1882
}
1883

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1884
# DEPRECATED!
1885
sub insert_param {
1886
    my $self = shift;
1887
    warn "insert_param is DEPRECATED! use values_clause instead";
1888
    return $self->values_clause(@_);
1889
}
1890

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1891
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1892
sub insert_param_tag {
1893
    warn "insert_param_tag is DEPRECATED! " .
1894
         "use insert_param instead!";
1895
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1896
}
1897

            
1898
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1899
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1900
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1901
         "use update_param instead";
1902
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1903
}
cleanup
Yuki Kimoto authored on 2011-03-08
1904
# DEPRECATED!
1905
sub _push_relation {
1906
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1907
    
1908
    if (keys %{$relation || {}}) {
micro optimization
Yuki Kimoto authored on 2011-09-30
1909
        $$sql .= $need_where ? 'where ' : 'and ';
cleanup
Yuki Kimoto authored on 2011-10-21
1910
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1911
            my $table1 = (split (/\./, $rcolumn))[0];
1912
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1913
            push @$tables, ($table1, $table2);
micro optimization
Yuki Kimoto authored on 2011-09-30
1914
            $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
cleanup
Yuki Kimoto authored on 2011-03-08
1915
        }
1916
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
1917
    $$sql =~ s/and $/ /;
cleanup
Yuki Kimoto authored on 2011-03-08
1918
}
1919

            
1920
# DEPRECATED!
1921
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1922
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1923
    
1924
    if (keys %{$relation || {}}) {
cleanup
Yuki Kimoto authored on 2011-10-21
1925
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1926
            my $table1 = (split (/\./, $rcolumn))[0];
1927
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1928
            my $table1_exists;
1929
            my $table2_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1930
            for my $table (@$tables) {
cleanup
Yuki Kimoto authored on 2011-03-08
1931
                $table1_exists = 1 if $table eq $table1;
1932
                $table2_exists = 1 if $table eq $table2;
1933
            }
1934
            unshift @$tables, $table1 unless $table1_exists;
1935
            unshift @$tables, $table2 unless $table2_exists;
1936
        }
1937
    }
1938
}
1939

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1942
=head1 NAME
1943

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

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

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1948
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1949
    
1950
    # Connect
1951
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1952
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1953
        user => 'ken',
1954
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1955
        option => {mysql_enable_utf8 => 1}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1956
    );
cleanup
yuki-kimoto authored on 2010-08-05
1957

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1958
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1959
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1960
    
1961
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
1962
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
1963
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1964
    
1965
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
1966
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
1967

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1972
    # Select, more complex
1973
    my $result = $dbi->select(
1974
        table  => 'book',
1975
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
1976
            {book => [qw/title author/]},
1977
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1978
        ],
1979
        where  => {'book.author' => 'Ken'},
1980
        join => ['left outer join company on book.company_id = company.id'],
1981
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
1982
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1983
    
removed register_format()
yuki-kimoto authored on 2010-05-26
1984
    # Fetch
1985
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1986
        
removed register_format()
yuki-kimoto authored on 2010-05-26
1987
    }
1988
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1989
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
1990
    while (my $row = $result->fetch_hash) {
1991
        
1992
    }
1993
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1994
    # Execute SQL with parameter.
1995
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1996
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
1997
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1998
    );
1999
    
fix heading typos
Terrence Brannon authored on 2011-08-17
2000
=head1 DESCRIPTION
removed reconnect method
yuki-kimoto authored on 2010-05-28
2001

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2017
Named place holder support
2018

            
2019
=item *
2020

            
cleanup
Yuki Kimoto authored on 2011-07-29
2021
Model support
2022

            
2023
=item *
2024

            
2025
Connection manager support
2026

            
2027
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2028

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

            
2033
=item *
2034

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

            
2037
=item *
2038

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

            
2041
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2042

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2050
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2051
L<DBIx::Custom::Result>,
2052
L<DBIx::Custom::Query>,
2053
L<DBIx::Custom::Where>,
2054
L<DBIx::Custom::Model>,
2055
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2056

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

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

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

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

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

            
2070
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2071
        "dbi:mysql:database=$database",
2072
        $user,
2073
        $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2074
        DBIx::Custom->new->default_option
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2075
    );
2076
    
updated pod
Yuki Kimoto authored on 2011-06-21
2077
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2078

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

            
2082
    my $dbi = DBIx::Custom->connect(
2083
      dsn => $dsn, user => $user, password => $password, connector => 1);
2084
    
2085
    my $connector = $dbi->connector; # DBIx::Connector
2086

            
2087
Note that L<DBIx::Connector> must be installed.
2088

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

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

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

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

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2104
    {
2105
        RaiseError => 1,
2106
        PrintError => 0,
2107
        AutoCommit => 1,
2108
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2109

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

            
2112
    my $exclude_table = $dbi->exclude_table;
2113
    $dbi = $dbi->exclude_table(qr/pg_/);
2114

            
2115
Excluded table regex.
2116
C<each_column>, C<each_table>, C<type_rule>,
2117
and C<setup_model> methods ignore matching tables.
2118

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

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

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

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

            
2128
    my $last_sql = $dbi->last_sql;
2129
    $dbi = $dbi->last_sql($last_sql);
2130

            
2131
Get last successed SQL executed by C<execute> method.
2132

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

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

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

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

            
2142
    my $option = $dbi->option;
2143
    $dbi = $dbi->option($option);
2144

            
2145
L<DBI> option, used when C<connect> method is executed.
2146
Each value in option override the value of C<default_option>.
2147

            
cleanup
yuki-kimoto authored on 2010-10-17
2148
=head2 C<password>
2149

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2170
You can set quote pair.
2171

            
2172
    $dbi->quote('[]');
2173

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2183
    my $safety_character = $dbi->safety_character;
2184
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2185

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

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

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

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

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

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

            
2202
    my $tag_parse = $dbi->tag_parse(0);
2203
    $dbi = $dbi->tag_parse;
2204

            
2205
Enable DEPRECATED tag parsing functionality, default to 1.
2206
If you want to disable tag parsing functionality, set to 0.
2207

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

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

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

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

            
2217
    my $user_column_info = $dbi->user_column_info;
2218
    $dbi = $dbi->user_column_info($user_column_info);
2219

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

            
2222
    [
2223
        {table => 'book', column => 'title', info => {...}},
2224
        {table => 'author', column => 'name', info => {...}}
2225
    ]
2226

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

            
2229
    my $user_column_info
2230
      = $dbi->get_column_info(exclude_table => qr/^system/);
2231
    $dbi->user_column_info($user_column_info);
2232

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

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

            
2238
    my $user_table_info = $dbi->user_table_info;
2239
    $dbi = $dbi->user_table_info($user_table_info);
2240

            
2241
You can set the following data.
2242

            
2243
    [
2244
        {table => 'book', info => {...}},
2245
        {table => 'author', info => {...}}
2246
    ]
2247

            
2248
Usually, you can set return value of C<get_table_info>.
2249

            
2250
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2251
    $dbi->user_table_info($user_table_info);
2252

            
2253
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2254
to find table info.
2255

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2292
Create column clause. The follwoing column clause is created.
2293

            
2294
    book.author as "book.author",
2295
    book.title as "book.title"
2296

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2299
    # Separator is hyphen
2300
    $dbi->separator('-');
2301
    
2302
    book.author as "book-author",
2303
    book.title as "book-title"
2304
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2305
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2306

            
update pod
Yuki Kimoto authored on 2011-03-13
2307
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2308
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2309
        user => 'ken',
2310
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2311
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2312
    );
2313

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

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

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

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

            
2324
Get rows count.
2325

            
2326
Options is same as C<select> method's ones.
2327

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2330
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2331
        table => 'book',
2332
        primary_key => 'id',
2333
        join => [
2334
            'inner join company on book.comparny_id = company.id'
2335
        ],
2336
    );
2337

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

            
2341
   $dbi->model('book')->select(...);
2342

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

            
2345
    my $dbh = $dbi->dbh;
2346

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

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

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

            
2354
Execute delete statement.
2355

            
2356
The following opitons are available.
2357

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

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

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

            
2365
=item C<id>
2366

            
2367
    id => 4
2368
    id => [4, 5]
2369

            
2370
ID corresponding to C<primary_key>.
2371
You can delete rows by C<id> and C<primary_key>.
2372

            
2373
    $dbi->delete(
fixed pod
Yuki Kimoto authored on 2011-10-20
2374
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2375
        id => [4, 5],
2376
        table => 'book',
2377
    );
2378

            
2379
The above is same as the followin one.
2380

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

            
2383
=item C<prefix>
2384

            
2385
    prefix => 'some'
2386

            
2387
prefix before table name section.
2388

            
2389
    delete some from book
2390

            
2391
=item C<table>
2392

            
2393
    table => 'book'
2394

            
2395
Table name.
2396

            
2397
=item C<where>
2398

            
2399
Same as C<select> method's C<where> option.
2400

            
2401
=back
2402

            
2403
=head2 C<delete_all>
2404

            
2405
    $dbi->delete_all(table => $table);
2406

            
2407
Execute delete statement for all rows.
2408
Options is same as C<delete>.
2409

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

            
2412
    $dbi->each_column(
2413
        sub {
2414
            my ($dbi, $table, $column, $column_info) = @_;
2415
            
2416
            my $type = $column_info->{TYPE_NAME};
2417
            
2418
            if ($type eq 'DATE') {
2419
                # ...
2420
            }
2421
        }
2422
    );
2423

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

            
2429
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2430
infromation, you can improve the performance of C<each_column> in
2431
the following way.
2432

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

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

            
2439
    $dbi->each_table(
2440
        sub {
2441
            my ($dbi, $table, $table_info) = @_;
2442
            
2443
            my $table_name = $table_info->{TABLE_NAME};
2444
        }
2445
    );
2446

            
improved pod
Yuki Kimoto authored on 2011-10-14
2447
Iterate all table informationsfrom in database.
2448
Argument is callback which is executed when one table is found.
2449
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2450
C<table information>.
2451

            
2452
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2453
infromation, you can improve the performance of C<each_table> in
2454
the following way.
2455

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

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

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

            
2467
    my $result = $dbi->execute(
2468
      "select * from book where title = :book.title and author like :book.author",
2469
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2470
    );
2471

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2478
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2479
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2480
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2481
    select * from book where title = :title and author like :author
2482
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2483
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2484
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2485

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2489
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2490
    select * from book where :title{=} and :author{like}
2491
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2492
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2493
    select * from where title = ? and author like ?;
2494

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

            
2499
    select * from where title = "aa\\:bb";
2500

            
cleanup
Yuki Kimoto authored on 2011-10-20
2501
B<OPTIONS>
2502

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

            
2505
=over 4
2506

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

            
2509
You can filter sql after the sql is build.
2510

            
2511
    after_build_sql => $code_ref
2512

            
2513
The following one is one example.
2514

            
2515
    $dbi->select(
2516
        table => 'book',
2517
        column => 'distinct(name)',
2518
        after_build_sql => sub {
2519
            "select count(*) from ($_[0]) as t1"
2520
        }
2521
    );
2522

            
2523
The following SQL is executed.
2524

            
2525
    select count(*) from (select distinct(name) from book) as t1;
2526

            
cleanup
Yuki Kimoto authored on 2011-10-20
2527
=item C<append>
2528

            
2529
    append => 'order by name'
2530

            
2531
Append some statement after SQL.
2532

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

            
2535
Specify database bind data type.
2536

            
2537
    bind_type => [image => DBI::SQL_BLOB]
2538
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2539

            
2540
This is used to bind parameter by C<bind_param> of statment handle.
2541

            
2542
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2543

            
update pod
Yuki Kimoto authored on 2011-03-13
2544
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2545
    
2546
    filter => {
2547
        title  => sub { uc $_[0] }
2548
        author => sub { uc $_[0] }
2549
    }
update pod
Yuki Kimoto authored on 2011-03-13
2550

            
updated pod
Yuki Kimoto authored on 2011-06-09
2551
    # Filter name
2552
    filter => {
2553
        title  => 'upper_case',
2554
        author => 'upper_case'
2555
    }
2556
        
2557
    # At once
2558
    filter => [
2559
        [qw/title author/]  => sub { uc $_[0] }
2560
    ]
2561

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

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

            
2569
    id => 4
2570
    id => [4, 5]
2571

            
2572
ID corresponding to C<primary_key>.
2573
You can delete rows by C<id> and C<primary_key>.
2574

            
2575
    $dbi->execute(
2576
        "select * from book where id1 = :id1 and id2 = :id2",
2577
        {},
fixed pod
Yuki Kimoto authored on 2011-10-20
2578
        primary_key => ['id1', 'id2'],
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2579
        id => [4, 5],
2580
    );
2581

            
2582
The above is same as the followin one.
2583

            
2584
    $dbi->execute(
2585
        "select * from book where id1 = :id1 and id2 = :id2",
2586
        {id1 => 4, id2 => 5}
2587
    );
2588

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

            
2591
    query => 1
2592

            
2593
C<execute> method return L<DBIx::Custom::Query> object, not executing SQL.
cleanup
Yuki Kimoto authored on 2011-07-30
2594
You can check SQL or get statment handle.
updated pod
Yuki Kimoto authored on 2011-06-21
2595

            
2596
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2597
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2598
    my $columns = $query->columns;
2599
    
2600
If you want to execute SQL fast, you can do the following way.
2601

            
2602
    my $query;
cleanup
Yuki Kimoto authored on 2011-10-21
2603
    for my $row (@$rows) {
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2604
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
cleanup
Yuki Kimoto authored on 2011-10-20
2605
      $dbi->execute($query, $row);
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2606
    }
2607

            
2608
Statement handle is reused and SQL parsing is finished,
2609
so you can get more performance than normal way.
cleanup
Yuki Kimoto authored on 2011-07-30
2610

            
2611
If you want to execute SQL as possible as fast and don't need filtering.
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2612
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2613
    
2614
    my $query;
2615
    my $sth;
cleanup
Yuki Kimoto authored on 2011-10-21
2616
    for my $row (@$rows) {
cleanup
Yuki Kimoto authored on 2011-07-30
2617
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2618
      $sth ||= $query->sth;
2619
      $sth->execute(map { $row->{$_} } sort keys %$row);
2620
    }
2621

            
2622
Note that $row must be simple hash reference, such as
2623
{title => 'Perl', author => 'Ken'}.
2624
and don't forget to sort $row values by $row key asc order.
updated document
Yuki Kimoto authored on 2011-06-09
2625

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2628
    primary_key => 'id'
2629
    primary_key => ['id1', 'id2']
2630

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2633
=item C<table>
2634
    
2635
    table => 'author'
2636

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2644
    # Same
2645
    $dbi->execute(
2646
      "select * from book where title = :book.title and author = :book.author",
2647
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2648

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

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

            
2653
Table alias. Key is real table name, value is alias table name.
2654
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2655
on alias table name.
2656

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2657
=item C<reuse EXPERIMENTAL>
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2658
    
micro optimization
Yuki Kimoto authored on 2011-10-23
2659
    reuse => $has_ref
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2660

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2661
Reuse query object if the hash reference variable is set.
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2662
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2663
    my $queries = {};
2664
    $dbi->execute($sql, $param, reuse => $queries);
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2665

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

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

            
2671
    type_rule_off => 1
2672

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

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

            
2677
    type_rule1_off => 1
2678

            
2679
Turn C<into1> type rule off.
2680

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

            
2683
    type_rule2_off => 1
2684

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

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

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

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

            
2693
get column infomation except for one which match C<exclude_table> pattern.
2694

            
2695
    [
2696
        {table => 'book', column => 'title', info => {...}},
2697
        {table => 'author', column => 'name' info => {...}}
2698
    ]
2699

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

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

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

            
2706
    [
2707
        {table => 'book', info => {...}},
2708
        {table => 'author', info => {...}}
2709
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2710

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

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

            
2715
    $dbi->helper(
2716
        update_or_insert => sub {
2717
            my $self = shift;
2718
            
2719
            # Process
2720
        },
2721
        find_or_create   => sub {
2722
            my $self = shift;
2723
            
2724
            # Process
2725
        }
2726
    );
2727

            
2728
Register helper. These helper is called directly from L<DBIx::Custom> object.
2729

            
2730
    $dbi->update_or_insert;
2731
    $dbi->find_or_create;
2732

            
cleanup
yuki-kimoto authored on 2010-10-17
2733
=head2 C<insert>
2734

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

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

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

            
2743
    {date => \"NOW()"}
2744

            
cleanup
Yuki Kimoto authored on 2011-10-20
2745
B<options>
2746

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2754
    id => 4
2755
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2756

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2760
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2761
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
2762
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2763
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2764
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2765
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2766

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

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

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

            
2776
    prefix => 'or replace'
2777

            
2778
prefix before table name section
2779

            
2780
    insert or replace into book
2781

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

            
2784
    table => 'book'
2785

            
2786
Table name.
2787

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2788
=item C<timestamp>
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
2789

            
2790
    timestamp => 1
2791

            
2792
If this value is set to 1,
2793
automatically created timestamp column is set based on
2794
C<timestamp> attribute's C<insert> value.
2795

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

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

            
2800
placeholder wrapped string.
2801

            
2802
If the following statement
2803

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

            
2807
is executed, the following SQL is executed.
2808

            
2809
    insert into book price values ( ? + 5 );
2810

            
update pod
Yuki Kimoto authored on 2011-03-13
2811
=back
2812

            
2813
=over 4
2814

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2822
    lib / MyModel.pm
2823
        / MyModel / book.pm
2824
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2825

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

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

            
2830
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2831
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2832
    
2833
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2834

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2839
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2840
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2841
    
2842
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2843

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2846
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2847
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2848
    
2849
    1;
2850
    
updated pod
Yuki Kimoto authored on 2011-06-21
2851
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2852

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2860
=head2 C<insert_timestamp>
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2861

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
2862
    $dbi->insert_timestamp(
2863
      [qw/created_at updated_at/]
2864
        => sub { Time::Piece->localtime->strftime("%Y-%m-%d %H:%M:%S") }
2865
    );
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2866

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2867
Timestamp value when C<insert> method is executed
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2868
with C<timestamp> option.
2869

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2870
If C<insert_timestamp> is set and C<insert> method is executed
2871
with C<timestamp> option, column C<created_at> and C<update_at>
2872
is automatically set to the value like "2010-10-11 10:12:54".
2873

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
2874
    $dbi->insert($param, table => 'book', timestamp => 1);
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2875

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

            
2878
    my $like_value = $dbi->like_value
2879

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

            
2882
    sub { "%$_[0]%" }
2883

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

            
2886
    my $mapper = $dbi->mapper(param => $param);
2887

            
2888
Create a new L<DBIx::Custom::Mapper> object.
2889

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

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

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

            
2896
    {key1 => [1, 1], key2 => 2}
2897

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

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

            
2902
    my $model = $dbi->model('book');
2903

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

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

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

            
2911
Create column clause for myself. The follwoing column clause is created.
2912

            
2913
    book.author as author,
2914
    book.title as title
2915

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

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

            
2925
Create a new L<DBIx::Custom> object.
2926

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

            
2929
    my $not_exists = $dbi->not_exists;
2930

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

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

            
2936
    my $order = $dbi->order;
2937

            
2938
Create a new L<DBIx::Custom::Order> object.
2939

            
cleanup
yuki-kimoto authored on 2010-10-17
2940
=head2 C<register_filter>
2941

            
update pod
Yuki Kimoto authored on 2011-03-13
2942
    $dbi->register_filter(
2943
        # Time::Piece object to database DATE format
2944
        tp_to_date => sub {
2945
            my $tp = shift;
2946
            return $tp->strftime('%Y-%m-%d');
2947
        },
2948
        # database DATE format to Time::Piece object
2949
        date_to_tp => sub {
2950
           my $date = shift;
2951
           return Time::Piece->strptime($date, '%Y-%m-%d');
2952
        }
2953
    );
cleanup
yuki-kimoto authored on 2010-10-17
2954
    
update pod
Yuki Kimoto authored on 2011-03-13
2955
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2956

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2959
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2960
        table  => 'book',
2961
        column => ['author', 'title'],
2962
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2963
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2964
    
updated document
Yuki Kimoto authored on 2011-06-09
2965
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2966

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2974
=item C<column>
2975
    
updated document
Yuki Kimoto authored on 2011-06-09
2976
    column => 'author'
2977
    column => ['author', 'title']
2978

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2987
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2988
        {book => [qw/author title/]},
2989
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2990
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2991

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

            
2994
    book.author as "book.author",
2995
    book.title as "book.title",
2996
    person.name as "person.name",
2997
    person.age as "person.age"
2998

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

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

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

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

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

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

            
3014
=item C<id>
3015

            
3016
    id => 4
3017
    id => [4, 5]
3018

            
3019
ID corresponding to C<primary_key>.
3020
You can select rows by C<id> and C<primary_key>.
3021

            
3022
    $dbi->select(
fixed pod
Yuki Kimoto authored on 2011-10-20
3023
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3024
        id => [4, 5],
3025
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3026
    );
3027

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3030
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3031
        where => {id1 => 4, id2 => 5},
3032
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3033
    );
3034
    
cleanup
Yuki Kimoto authored on 2011-10-20
3035
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3036

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

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

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

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

            
3049
    prefix => 'SQL_CALC_FOUND_ROWS'
3050

            
3051
Prefix of column cluase
3052

            
3053
    select SQL_CALC_FOUND_ROWS title, author from book;
3054

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

            
3057
    join => [
3058
        'left outer join company on book.company_id = company_id',
3059
        'left outer join location on company.location_id = location.id'
3060
    ]
3061
        
3062
Join clause. If column cluase or where clause contain table name like "company.name",
3063
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3064

            
3065
    $dbi->select(
3066
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3067
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3068
        where => {'company.name' => 'Orange'},
3069
        join => [
3070
            'left outer join company on book.company_id = company.id',
3071
            'left outer join location on company.location_id = location.id'
3072
        ]
3073
    );
3074

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3078
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3079
    from book
3080
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3081
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3082

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3083
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
3084
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3085

            
3086
    $dbi->select(
3087
        table => 'book',
3088
        column => ['company.location_id as location_id'],
3089
        where => {'company.name' => 'Orange'},
3090
        join => [
3091
            {
3092
                clause => 'left outer join location on company.location_id = location.id',
3093
                table => ['company', 'location']
3094
            }
3095
        ]
3096
    );
3097

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3102
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3103

            
updated document
Yuki Kimoto authored on 2011-06-09
3104
=item C<where>
3105
    
3106
    # Hash refrence
3107
    where => {author => 'Ken', 'title' => 'Perl'}
3108
    
3109
    # DBIx::Custom::Where object
3110
    where => $dbi->where(
3111
        clause => ['and', 'author = :author', 'title like :title'],
3112
        param  => {author => 'Ken', title => '%Perl%'}
3113
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3114
    
3115
    # Array reference 1 (array reference, hash referenc). same as above
3116
    where => [
3117
        ['and', 'author = :author', 'title like :title'],
3118
        {author => 'Ken', title => '%Perl%'}
3119
    ];    
3120
    
3121
    # Array reference 2 (String, hash reference)
3122
    where => [
3123
        'title like :title',
3124
        {title => '%Perl%'}
3125
    ]
3126
    
3127
    # String
3128
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3129

            
cleanup
Yuki Kimoto authored on 2011-10-20
3130
Where clause. See L<DBIx::Custom::Where>.
updated document
Yuki Kimoto authored on 2011-06-09
3131
    
update pod
Yuki Kimoto authored on 2011-03-12
3132
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3133

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

            
3136
    $dbi->setup_model;
3137

            
3138
Setup all model objects.
3139
C<columns> of model object is automatically set, parsing database information.
3140

            
3141
=head2 C<type_rule>
3142

            
3143
    $dbi->type_rule(
3144
        into1 => {
3145
            date => sub { ... },
3146
            datetime => sub { ... }
3147
        },
3148
        into2 => {
3149
            date => sub { ... },
3150
            datetime => sub { ... }
3151
        },
3152
        from1 => {
3153
            # DATE
3154
            9 => sub { ... },
3155
            # DATETIME or TIMESTAMP
3156
            11 => sub { ... },
3157
        }
3158
        from2 => {
3159
            # DATE
3160
            9 => sub { ... },
3161
            # DATETIME or TIMESTAMP
3162
            11 => sub { ... },
3163
        }
3164
    );
3165

            
3166
Filtering rule when data is send into and get from database.
3167
This has a little complex problem.
3168

            
3169
In C<into1> and C<into2> you can specify
3170
type name as same as type name defined
3171
by create table, such as C<DATETIME> or C<DATE>.
3172

            
3173
Note that type name and data type don't contain upper case.
3174
If these contain upper case charactor, you convert it to lower case.
3175

            
3176
C<into2> is executed after C<into1>.
3177

            
3178
Type rule of C<into1> and C<into2> is enabled on the following
3179
column name.
3180

            
3181
=over 4
3182

            
3183
=item 1. column name
3184

            
3185
    issue_date
3186
    issue_datetime
3187

            
3188
This need C<table> option in each method.
3189

            
3190
=item 2. table name and column name, separator is dot
3191

            
3192
    book.issue_date
3193
    book.issue_datetime
3194

            
3195
=back
3196

            
3197
You get all type name used in database by C<available_typename>.
3198

            
3199
    print $dbi->available_typename;
3200

            
3201
In C<from1> and C<from2> you specify data type, not type name.
3202
C<from2> is executed after C<from1>.
3203
You get all data type by C<available_datatype>.
3204

            
3205
    print $dbi->available_datatype;
3206

            
3207
You can also specify multiple types at once.
3208

            
3209
    $dbi->type_rule(
3210
        into1 => [
3211
            [qw/DATE DATETIME/] => sub { ... },
3212
        ],
3213
    );
3214

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

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

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

            
3221
If you want to set constant value to row data, use scalar reference
3222
as parameter value.
3223

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3235
    id => 4
3236
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3237

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3241
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3242
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
3243
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3244
        id => [4, 5],
3245
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3246
    );
update pod
Yuki Kimoto authored on 2011-03-13
3247

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3250
    $dbi->update(
3251
        {title => 'Perl', author => 'Ken'}
3252
        where => {id1 => 4, id2 => 5},
3253
        table => 'book'
3254
    );
update pod
Yuki Kimoto authored on 2011-03-13
3255

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

            
3258
    prefix => 'or replace'
3259

            
3260
prefix before table name section
3261

            
3262
    update or replace book
3263

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3270
=item C<timestamp>
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
3271

            
3272
    timestamp => 1
3273

            
3274
If this value is set to 1,
3275
automatically updated timestamp column is set based on
3276
C<timestamp> attribute's C<update> value.
3277

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

            
3280
Same as C<select> method's C<where> option.
3281

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

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

            
3286
placeholder wrapped string.
3287

            
3288
If the following statement
3289

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

            
3293
is executed, the following SQL is executed.
3294

            
3295
    update book set price =  ? + 5;
3296

            
updated pod
Yuki Kimoto authored on 2011-06-08
3297
=back
update pod
Yuki Kimoto authored on 2011-03-13
3298

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

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

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

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3306
=head2 C<update_or_insert EXPERIMENTAL>
3307
    
3308
    # Where
3309
    $dbi->update_or_insert(
3310
        {id => 1, title => 'Perl'},
3311
        table => 'book',
3312
        where => {id => 1},
3313
        select_option => {append => 'for update'}
3314
    );
3315
    
3316
    # ID
3317
    $dbi->update_or_insert(
3318
        {title => 'Perl'},
3319
        table => 'book',
3320
        id => 1,
3321
        primary_key => 'id',
3322
        select_option => {append => 'for update'}
3323
    );
3324
    
3325
Update or insert.
3326

            
3327
In both examples, the following SQL is executed.
3328

            
3329
    # In case insert
3330
    insert into book (id, title) values (?, ?)
3331
    
3332
    # In case update
3333
    update book set (id = ?, title = ?) where book.id = ?
3334

            
3335
The following opitons are available adding to C<update> option.
3336

            
3337
=over 4
3338

            
3339
=item C<select_option>
3340

            
3341
    select_option => {append => 'for update'}
3342

            
3343
select method option,
3344
select method is used to check the row is already exists.
3345

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3346
=head2 C<update_timestamp>
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
3347

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3348
    $dbi->update_timestamp(
3349
      updated_at
3350
        => sub { Time::Piece->localtime->strftime("%Y-%m-%d %H:%M:%S") }
cleanup
Yuki Kimoto authored on 2011-03-09
3351
    );
fix tests
Yuki Kimoto authored on 2011-01-18
3352

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3353
Timestamp value when C<update> method is executed
3354
with C<timestamp> option.
cleanup
Yuki Kimoto authored on 2011-01-12
3355

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3356
If C<insert_timestamp> is set and C<insert> method is executed
3357
with C<timestamp> option, column C<update_at>
3358
is automatically set to the value like "2010-10-11 10:12:54".
cleanup
Yuki Kimoto authored on 2011-01-12
3359

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3360
>|perl|
3361
$dbi->update($param, table => 'book', timestamp => 1);
3362
||<
cleanup
Yuki Kimoto authored on 2011-01-12
3363

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

            
3366
    $dbi->show_datatype($table);
3367

            
3368
Show data type of the columns of specified table.
3369

            
3370
    book
3371
    title: 5
3372
    issue_date: 91
3373

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

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

            
3378
    $dbi->show_tables;
3379

            
3380
Show tables.
3381

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

            
3384
    $dbi->show_typename($table);
3385

            
3386
Show type name of the columns of specified table.
3387

            
3388
    book
3389
    title: varchar
3390
    issue_date: date
3391

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

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

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

            
3398
Create values clause.
3399

            
3400
    (title, author) values (title = :title, age = :age);
3401

            
3402
You can use this in insert statement.
3403

            
3404
    my $insert_sql = "insert into book $values_clause";
3405

            
3406
=head2 C<where>
3407

            
3408
    my $where = $dbi->where(
3409
        clause => ['and', 'title = :title', 'author = :author'],
3410
        param => {title => 'Perl', author => 'Ken'}
3411
    );
3412

            
3413
Create a new L<DBIx::Custom::Where> object.
3414

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

            
3417
=head2 C<DBIX_CUSTOM_DEBUG>
3418

            
3419
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3420
executed SQL and bind values are printed to STDERR.
3421

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

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

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

            
3428
L<DBIx::Custom>
3429

            
3430
    # Attribute methods
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
3431
    default_dbi_option # will be removed 2017/1/1
3432
    dbi_option # will be removed 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3433
    data_source # will be removed at 2017/1/1
3434
    dbi_options # will be removed at 2017/1/1
3435
    filter_check # will be removed at 2017/1/1
3436
    reserved_word_quote # will be removed at 2017/1/1
3437
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3438
    
3439
    # Methods
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3440
    method # will be removed at 2017/1/1
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
3441
    assign_param # will be removed at 2017/1/1
3442
    update_param # will be removed at 2017/1/1
3443
    insert_param # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3444
    create_query # will be removed at 2017/1/1
3445
    apply_filter # will be removed at 2017/1/1
3446
    select_at # will be removed at 2017/1/1
3447
    delete_at # will be removed at 2017/1/1
3448
    update_at # will be removed at 2017/1/1
3449
    insert_at # will be removed at 2017/1/1
3450
    register_tag # will be removed at 2017/1/1
3451
    default_bind_filter # will be removed at 2017/1/1
3452
    default_fetch_filter # will be removed at 2017/1/1
3453
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3454
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3455
    register_tag_processor # will be removed at 2017/1/1
3456
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3457
    
3458
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
3459
    select method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3460
    delete method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3461
    update method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3462
    insert method param option # will be removed at 2017/1/1
insert method's id option is...
Yuki Kimoto authored on 2011-10-10
3463
    insert method id option # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3464
    select method relation option # will be removed at 2017/1/1
3465
    select method column option [COLUMN, as => ALIAS] format
3466
      # will be removed at 2017/1/1
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3467
    execute method's sqlfilter option # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3468
    
3469
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3470
    execute("select * from {= title}"); # execute method's
3471
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3472
                                        # will be removed at 2017/1/1
3473
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3474

            
3475
L<DBIx::Custom::Model>
3476

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3477
    # Attribute methods
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3478
    method # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3479
    filter # will be removed at 2017/1/1
3480
    name # will be removed at 2017/1/1
3481
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3482

            
3483
L<DBIx::Custom::Query>
3484
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3485
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3486
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3487
    table # will be removed at 2017/1/1
3488
    filters # will be removed at 2017/1/1
3489
    
3490
    # Methods
3491
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3492

            
3493
L<DBIx::Custom::QueryBuilder>
3494
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3495
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3496
    tags # will be removed at 2017/1/1
3497
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3498
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3499
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3500
    register_tag # will be removed at 2017/1/1
3501
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3502
    
3503
    # Others
3504
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3505
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3506

            
3507
L<DBIx::Custom::Result>
3508
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3509
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3510
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3511
    
3512
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3513
    end_filter # will be removed at 2017/1/1
3514
    remove_end_filter # will be removed at 2017/1/1
3515
    remove_filter # will be removed at 2017/1/1
3516
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3517

            
3518
L<DBIx::Custom::Tag>
3519

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

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

            
3524
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3525
except for attribute method.
3526
You can check all DEPRECATED functionalities by document.
3527
DEPRECATED functionality is removed after five years,
3528
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
3529
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3530

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

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

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

            
3537
C<< <kimoto.yuki at gmail.com> >>
3538

            
3539
L<http://github.com/yuki-kimoto/DBIx-Custom>
3540

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3541
=head1 AUTHOR
3542

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

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

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

            
3549
This program is free software; you can redistribute it and/or modify it
3550
under the same terms as Perl itself.
3551

            
3552
=cut