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

            
micro optimization
Yuki Kimoto authored on 2011-11-16
4
our $VERSION = '0.2100';
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
5
use 5.008001;
cleanup
yuki-kimoto authored on 2009-12-22
6

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

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

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

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

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

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

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
129
sub assign_clause {
updated pod
Yuki Kimoto authored on 2011-09-02
130
    my ($self, $param, $opts) = @_;
131
    
132
    my $wrap = $opts->{wrap} || {};
micro optimization
Yuki Kimoto authored on 2011-11-16
133
    my ($q, $p) = split //, $self->q('');
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
134
    
micro optimization
Yuki Kimoto authored on 2011-10-23
135
    # Assign clause (performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
136
    join(
137
      ', ',
138
      map {
139
          ref $param->{$_} eq 'SCALAR' ? "$q$_$p = " . ${$param->{$_}}
140
          : $wrap->{$_} ? "$q$_$p = " . $wrap->{$_}->(":$_")
141
          : "$q$_$p = :$_";
142
      } sort keys %$param
143
    );
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
144
}
145

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
500
    # Execute
micro optimization
Yuki Kimoto authored on 2011-10-23
501
    my $sth = $query->{sth};
cleanup
yuki-kimoto authored on 2010-10-17
502
    my $affected;
micro optimization
Yuki Kimoto authored on 2011-11-16
503
    if (!$query->{duplicate} && $type_rule_off && !keys %$filter &&
504
      !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG})
505
    {
506
        eval { $affected = $sth->execute(map { $param->{$_} } @{$query->{columns}}) };
507
    }
508
    else {
509
        # Create bind values
510
        my ($bind, $bind_types) = $self->_create_bind_values($param, $query->{columns},
511
          $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
512

            
513
        # Execute
514
        eval {
515
            if ($opt{bind_type} || $opt{type}) {
516
                $sth->bind_param($_ + 1, $bind->[$_],
517
                    $bind_types->[$_] ? $bind_types->[$_] : ())
518
                  for (0 .. @$bind - 1);
519
                $affected = $sth->execute;
520
            }
521
            else {
522
                $affected = $sth->execute(@$bind);
523
            }
524

            
525
            # DEBUG message
526
            if ($ENV{DBIX_CUSTOM_DEBUG}) {
527
                warn "SQL:\n" . $query->{sql} . "\n";
528
                my @output;
529
                for my $value (@$bind) {
530
                    $value = 'undef' unless defined $value;
531
                    $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
532
                      if utf8::is_utf8($value);
533
                    push @output, $value;
534
                }
535
                warn "Bind values: " . join(', ', @output) . "\n\n";
536
            }
537
        };
538
    }
improved error messages
Yuki Kimoto authored on 2011-04-18
539
    
micro optimization
Yuki Kimoto authored on 2011-07-30
540
    $self->_croak($@, qq{. Following SQL is executed.\n}
541
      . qq{$query->{sql}\n} . _subname) if $@;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
542

            
543
    # Remove id from parameter
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
544
    delete $param->{$_} for (@cleanup, @{$opt{cleanup} || []});
cleanup
yuki-kimoto authored on 2010-10-17
545
    
micro optimization
Yuki Kimoto authored on 2011-10-23
546
    # Not select statement
547
    return $affected unless $sth->{NUM_OF_FIELDS};
548

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

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

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

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
609
sub helper {
610
    my $self = shift;
611
    
612
    # Register method
613
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
614
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
615
    
616
    return $self;
617
}
618

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

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

            
675
    # Remove id from parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
676
    delete $param->{$_} for @cleanup;
packaging one directory
yuki-kimoto authored on 2009-11-16
677
    
678
    # Execute query
micro optimization
Yuki Kimoto authored on 2011-10-23
679
    $opt{statement} = 'insert';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
680
    $opt{cleanup} = \@timestamp_cleanup;
micro optimization
Yuki Kimoto authored on 2011-10-23
681
    $self->execute($sql, $param, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
682
}
683

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

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

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

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

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

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

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

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

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

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

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

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

            
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
861
sub q {
862
    my ($self, $value, $quotemeta) = @_;
863
    
864
    my $quote = $self->{reserved_word_quote}
865
      || $self->{quote} || $self->quote || '';
866
    return "$quote$value$quote"
867
      if !$quotemeta && ($quote eq '`' || $quote eq '"');
868
    
869
    my $q = substr($quote, 0, 1) || '';
870
    my $p;
871
    if (defined $quote && length $quote > 1) {
872
        $p = substr($quote, 1, 1);
873
    }
874
    else { $p = $q }
875
    
876
    if ($quotemeta) {
877
        $q = quotemeta($q);
878
        $p = quotemeta($p);
879
    }
880
    
881
    return "$q$value$p";
882
}
883

            
cleanup
yuki-kimoto authored on 2010-10-17
884
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
885
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
886
    
887
    # Register filter
888
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
889
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
890
    
cleanup
Yuki Kimoto authored on 2011-04-02
891
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
892
}
packaging one directory
yuki-kimoto authored on 2009-11-16
893

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
897
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
898
    my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
899
               : defined $opt{table} ? [$opt{table}]
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
900
               : [];
cleanup
Yuki Kimoto authored on 2011-10-21
901
    $opt{table} = $tables;
cleanup
Yuki Kimoto authored on 2011-10-21
902
    my $where_param = $opt{where_param} || delete $opt{param} || {};
select method where_param op...
Yuki Kimoto authored on 2011-10-25
903
    warn "select method where_param option is DEPRECATED!"
904
      if $opt{where_param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
905
    
cleanup
Yuki Kimoto authored on 2011-03-09
906
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
907
    if ($opt{relation}) {
908
        warn "select() relation option is DEPRECATED!";
909
        $self->_add_relation_table($tables, $opt{relation});
910
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
911
    
cleanup
Yuki Kimoto authored on 2011-04-02
912
    # Select statement
micro optimization
Yuki Kimoto authored on 2011-09-30
913
    my $sql = 'select ';
packaging one directory
yuki-kimoto authored on 2009-11-16
914
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
915
    # Prefix
cleanup
Yuki Kimoto authored on 2011-10-21
916
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
917
    
cleanup
Yuki Kimoto authored on 2011-10-21
918
    # Column
cleanup
Yuki Kimoto authored on 2011-10-21
919
    if (defined $opt{column}) {
920
        my $columns
921
          = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
cleanup
Yuki Kimoto authored on 2011-10-21
922
        for my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
923
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
924
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
925
            }
926
            elsif (ref $column eq 'ARRAY') {
- insert method created_at a...
Yuki Kimoto authored on 2011-10-27
927
                warn "select column option [COLUMN => ALIAS] syntax is DEPRECATED!" .
928
                  "use q method to quote the value";
- select method column optio...
Yuki Kimoto authored on 2011-07-11
929
                if (@$column == 3 && $column->[1] eq 'as') {
930
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
931
                    splice @$column, 1, 1;
932
                }
933
                
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
934
                $column = join(' ', $column->[0], 'as', $self->q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
935
            }
cleanup
Yuki Kimoto authored on 2011-04-02
936
            unshift @$tables, @{$self->_search_tables($column)};
micro optimization
Yuki Kimoto authored on 2011-09-30
937
            $sql .= "$column, ";
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
938
        }
micro optimization
Yuki Kimoto authored on 2011-09-30
939
        $sql =~ s/, $/ /;
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
940
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
941
    else { $sql .= '* ' }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
942
    
943
    # Table
micro optimization
Yuki Kimoto authored on 2011-09-30
944
    $sql .= 'from ';
cleanup
Yuki Kimoto authored on 2011-10-21
945
    if ($opt{relation}) {
cleanup
Yuki Kimoto authored on 2011-03-30
946
        my $found = {};
cleanup
Yuki Kimoto authored on 2011-10-21
947
        for my $table (@$tables) {
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
948
            $sql .= $self->q($table) . ', ' unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
949
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
950
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
951
    }
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
952
    else { $sql .= $self->q($tables->[-1] || '') . ' ' }
micro optimization
Yuki Kimoto authored on 2011-09-30
953
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2011-10-21
954
    croak "select method table option must be specified " . _subname
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-10-26
955
      unless defined $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
956

            
cleanup
Yuki Kimoto authored on 2011-04-02
957
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
958
    unshift @$tables,
959
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
960
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
961
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
962
    my $w = $self->_where_clause_and_param($opt{where}, $where_param,
963
      delete $opt{id}, $opt{primary_key}, $tables->[-1]);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
964
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
965
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-10-21
966
    unshift @$tables, @{$self->_search_tables($w->{clause})};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
967
    
cleanup
Yuki Kimoto authored on 2011-10-21
968
    # Join statement
cleanup
Yuki Kimoto authored on 2011-10-21
969
    $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
970
    
cleanup
Yuki Kimoto authored on 2011-03-09
971
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-10-21
972
    $sql .= "$w->{clause} ";
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
973
    
cleanup
Yuki Kimoto authored on 2011-03-08
974
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
975
    $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
cleanup
Yuki Kimoto authored on 2011-10-21
976
      if $opt{relation};
cleanup
Yuki Kimoto authored on 2011-03-08
977
    
packaging one directory
yuki-kimoto authored on 2009-11-16
978
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
979
    $opt{statement} = 'select';
cleanup
Yuki Kimoto authored on 2011-10-21
980
    my $result = $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
981
    
micro optimization
Yuki Kimoto authored on 2011-10-23
982
    $result;
packaging one directory
yuki-kimoto authored on 2009-11-16
983
}
984

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
985
sub setup_model {
986
    my $self = shift;
987
    
cleanup
Yuki Kimoto authored on 2011-04-02
988
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
989
    $self->each_column(
990
        sub {
991
            my ($self, $table, $column, $column_info) = @_;
992
            if (my $model = $self->models->{$table}) {
993
                push @{$model->columns}, $column;
994
            }
995
        }
996
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
997
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
998
}
999

            
update pod
Yuki Kimoto authored on 2011-08-10
1000
sub show_datatype {
1001
    my ($self, $table) = @_;
1002
    croak "Table name must be specified" unless defined $table;
1003
    print "$table\n";
1004
    
1005
    my $result = $self->select(table => $table, where => "'0' <> '0'");
1006
    my $sth = $result->sth;
1007

            
1008
    my $columns = $sth->{NAME};
1009
    my $data_types = $sth->{TYPE};
1010
    
1011
    for (my $i = 0; $i < @$columns; $i++) {
1012
        my $column = $columns->[$i];
show_datatype method return ...
Yuki Kimoto authored on 2011-11-03
1013
        my $data_type = lc $data_types->[$i];
update pod
Yuki Kimoto authored on 2011-08-10
1014
        print "$column: $data_type\n";
1015
    }
1016
}
1017

            
1018
sub show_typename {
1019
    my ($self, $t) = @_;
1020
    croak "Table name must be specified" unless defined $t;
1021
    print "$t\n";
1022
    
1023
    $self->each_column(sub {
1024
        my ($self, $table, $column, $infos) = @_;
1025
        return unless $table eq $t;
show_datatype method return ...
Yuki Kimoto authored on 2011-11-03
1026
        my $typename = lc $infos->{TYPE_NAME};
update pod
Yuki Kimoto authored on 2011-08-10
1027
        print "$column: $typename\n";
1028
    });
1029
    
1030
    return $self;
1031
}
1032

            
test cleanup
Yuki Kimoto authored on 2011-08-15
1033
sub show_tables {
1034
    my $self = shift;
1035
    
1036
    my %tables;
1037
    $self->each_table(sub { $tables{$_[1]}++ });
1038
    print join("\n", sort keys %tables) . "\n";
1039
    return $self;
1040
}
1041

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

            
1045
    $self->{_type_rule_is_called} = 1;
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1046
    
1047
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
1048
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1049
        
1050
        # Into
cleanup
Yuki Kimoto authored on 2011-10-21
1051
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1052
            my $into = "into$i";
cleanup
Yuki Kimoto authored on 2011-08-16
1053
            my $exists_into = exists $type_rule->{$into};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1054
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1055
            $self->{type_rule} = $type_rule;
1056
            $self->{"_$into"} = {};
cleanup
Yuki Kimoto authored on 2011-10-21
1057
            for my $type_name (keys %{$type_rule->{$into} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1058
                croak qq{type name of $into section must be lower case}
1059
                  if $type_name =~ /[A-Z]/;
1060
            }
cleanup
Yuki Kimoto authored on 2011-08-16
1061
            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1062
            $self->each_column(sub {
1063
                my ($dbi, $table, $column, $column_info) = @_;
1064
                
1065
                my $type_name = lc $column_info->{TYPE_NAME};
1066
                if ($type_rule->{$into} &&
1067
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1068
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1069
                    return unless exists $type_rule->{$into}->{$type_name};
1070
                    if  (defined $filter && ref $filter ne 'CODE') 
1071
                    {
1072
                        my $fname = $filter;
1073
                        croak qq{Filter "$fname" is not registered" } . _subname
1074
                          unless exists $self->filters->{$fname};
1075
                        
1076
                        $filter = $self->filters->{$fname};
1077
                    }
1078

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1079
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1080
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1081
                }
1082
            });
1083
        }
1084

            
1085
        # From
cleanup
Yuki Kimoto authored on 2011-10-21
1086
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1087
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
cleanup
Yuki Kimoto authored on 2011-10-21
1088
            for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1089
                croak qq{data type of from$i section must be lower case or number}
1090
                  if $data_type =~ /[A-Z]/;
1091
                my $fname = $type_rule->{"from$i"}{$data_type};
1092
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1093
                    croak qq{Filter "$fname" is not registered" } . _subname
1094
                      unless exists $self->filters->{$fname};
1095
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1096
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1097
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1098
            }
1099
        }
1100
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1101
        return $self;
1102
    }
1103
    
1104
    return $self->{type_rule} || {};
1105
}
1106

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1110
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1111
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
1112
    my %opt = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1113
    warn "update param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
1114
    warn "update method where_param option is DEPRECATED!"
1115
      if $opt{where_param};
cleanup
Yuki Kimoto authored on 2011-10-21
1116
    $param ||= $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1117
    
cleanup
Yuki Kimoto authored on 2011-10-21
1118
    # Don't allow update all rows
1119
    croak qq{update method where option must be specified } . _subname
1120
      if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1121
    
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1122
    # Timestamp(DEPRECATED!)
cleanup
Yuki Kimoto authored on 2011-10-21
1123
    if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
1124
        warn "update timestamp option is DEPRECATED! use updated_at and now method";
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1125
        my $columns = $update_timestamp->[0];
1126
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1127
        my $value = $update_timestamp->[1];
1128
        $value = $value->() if ref $value eq 'CODE';
1129
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1130
    }
1131

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1132
    # Created time and updated time
1133
    my @timestamp_cleanup;
1134
    if (defined $opt{updated_at}) {
- insert method created_at a...
Yuki Kimoto authored on 2011-10-27
1135
        my $now = $self->now;
1136
        $now = $now->() if ref $now eq 'CODE';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1137
        $param->{$opt{updated_at}} = $self->now->();
1138
        push @timestamp_cleanup, $opt{updated_at};
1139
    }
1140

            
cleanup
Yuki Kimoto authored on 2011-10-21
1141
    # Assign clause
cleanup
Yuki Kimoto authored on 2011-10-21
1142
    my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
cleanup
Yuki Kimoto authored on 2011-10-21
1143
    
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1144
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
1145
    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
1146
      delete $opt{id}, $opt{primary_key}, $opt{table});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1147
    
cleanup
Yuki Kimoto authored on 2011-04-02
1148
    # Update statement
cleanup
Yuki Kimoto authored on 2011-10-21
1149
    my $sql = "update ";
1150
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1151
    $sql .= $self->q($opt{table}) . " set $assign_clause $w->{clause} ";
cleanup
Yuki Kimoto authored on 2011-01-27
1152
    
cleanup
yuki-kimoto authored on 2010-10-17
1153
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
1154
    $opt{statement} = 'update';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1155
    $opt{cleanup} = \@timestamp_cleanup;
micro optimization and
Yuki Kimoto authored on 2011-10-25
1156
    $self->execute($sql, [$param, $w->{param}], %opt);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1157
}
1158

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1161
sub update_or_insert {
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
1162
    my ($self, $param, %opt) = @_;
1163
    croak "update_or_insert method need primary_key and id option "
1164
      unless defined $opt{id} && defined $opt{primary_key};
1165
    my $statement_opt = $opt{option} || {};
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1166

            
1167
    my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
1168
    if (@$rows == 0) {
1169
        return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
1170
    }
1171
    elsif (@$rows == 1) {
1172
        return $self->update($param, %opt, %{$statement_opt->{update} || {}});
1173
    }
1174
    else {
1175
        croak "selected row must be one " . _subname;
1176
    }
cleanup
Yuki Kimoto authored on 2011-10-21
1177
}
1178

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1179
sub update_timestamp {
1180
    my $self = shift;
1181
    
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
1182
    warn "update_timestamp method is DEPRECATED! use now method";
1183
    
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1184
    if (@_) {
1185
        $self->{update_timestamp} = [@_];
1186
        
1187
        return $self;
1188
    }
1189
    return $self->{update_timestamp};
1190
}
1191

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1192
sub values_clause {
1193
    my ($self, $param, $opts) = @_;
1194
    
1195
    my $wrap = $opts->{wrap} || {};
1196
    
1197
    # Create insert parameter tag
micro optimization
Yuki Kimoto authored on 2011-11-16
1198
    my ($q, $p) = split //, $self->q('');
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1199
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1200
    # values clause(performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
1201
    '(' .
1202
    join(
1203
      ', ',
1204
      map { "$q$_$p" } sort keys %$param
1205
    ) .
1206
    ') values (' .
1207
    join(
1208
      ', ',
1209
      map {
1210
          ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1211
          $wrap->{$_} ? $wrap->{$_}->(":$_") :
1212
          ":$_";
1213
      } sort keys %$param
1214
    ) .
1215
    ')'
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1216
}
1217

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

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

            
1246
        # Create query
cleanup
Yuki Kimoto authored on 2011-11-16
1247
        if (exists $ENV{DBIX_CUSTOM_TAG_PARSE} && !$ENV{DBIX_CUSTOM_TAG_PARSE}) {
1248
            $source ||= '';
1249
            my $columns = [];
1250
            my $c = $self->{safety_character} || $self->safety_character;
1251
            my %duplicate;
1252
            my $duplicate;
1253
            # Parameter regex
1254
            $source =~ s/([0-9]):/$1\\:/g;
1255
            while ($source =~ /(^|.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/sg) {
1256
                push @$columns, $2;
1257
                $duplicate = 1 if ++$duplicate{$columns->[-1]} > 1;
1258
                $source = defined $3 ? "$1$2 $3 ?$4" : "$1?$4";
1259
            }
1260
            $source =~ s/\\:/:/g if index($source, "\\:") != -1;
1261

            
1262
            # Create query
1263
            $query = {sql => $source, columns => $columns, duplicate => $duplicate};
1264
        }
1265
        else {
1266
            $query = $self->query_builder->build_query($source);
1267
        }
cleanup
Yuki Kimoto authored on 2011-11-16
1268
        
updated pod
Yuki Kimoto authored on 2011-06-21
1269
        # Save query to cache
1270
        $self->cache_method->(
1271
            $self, $source,
1272
            {
micro optimization
Yuki Kimoto authored on 2011-11-16
1273
                sql     => $query->{sql}, 
1274
                columns => $query->{columns},
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1275
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1276
            }
1277
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1278
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1279

            
1280
    # Filter SQL
micro optimization
Yuki Kimoto authored on 2011-11-16
1281
    $query->{sql} = $after_build_sql->($query->{sql}) if $after_build_sql;
1282
    
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1283
    # Save sql
micro optimization
Yuki Kimoto authored on 2011-11-16
1284
    $self->{last_sql} = $query->{sql};
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1285
    
updated pod
Yuki Kimoto authored on 2011-06-21
1286
    # Prepare statement handle
1287
    my $sth;
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1288
    eval { $sth = $self->dbh->prepare($query->{sql}) };
updated pod
Yuki Kimoto authored on 2011-06-21
1289
    
1290
    if ($@) {
1291
        $self->_croak($@, qq{. Following SQL is executed.\n}
1292
                        . qq{$query->{sql}\n} . _subname);
1293
    }
1294
    
1295
    # Set statement handle
micro optimization
Yuki Kimoto authored on 2011-11-16
1296
    $query->{sth} = $sth;
updated pod
Yuki Kimoto authored on 2011-06-21
1297
    
1298
    # Set filters
cleanup
Yuki Kimoto authored on 2011-11-16
1299
    $query->{filters} = $self->{filters} || $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1300
    
1301
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1302
}
1303

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1360
sub _id_to_param {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1361
    my ($self, $id, $primary_keys, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1362
    
1363
    # Check primary key
cleanup
Yuki Kimoto authored on 2011-10-21
1364
    croak "primary_key option " .
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1365
          "must be specified when id option is used" . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1366
      unless defined $primary_keys;
1367
    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
improved error messages
Yuki Kimoto authored on 2011-04-18
1368
    
cleanup
Yuki Kimoto authored on 2011-06-08
1369
    # Create parameter
1370
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1371
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1372
        $id = [$id] unless ref $id;
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1373
        for(my $i = 0; $i < @$id; $i++) {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1374
           my $key = $primary_keys->[$i];
1375
           $key = "$table." . $key if $table;
1376
           $param->{$key} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1377
        }
1378
    }
1379
    
cleanup
Yuki Kimoto authored on 2011-06-08
1380
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1381
}
1382

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
1535
sub _remove_duplicate_table {
1536
    my ($self, $tables, $main_table) = @_;
1537
    
1538
    # Remove duplicate table
1539
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1540
    delete $tables{$main_table} if $main_table;
1541
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1542
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1543
    if (my $q = $self->_quote) {
1544
        $q = quotemeta($q);
1545
        $_ =~ s/[$q]//g for @$new_tables;
1546
    }
1547

            
1548
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1549
}
1550

            
cleanup
Yuki Kimoto authored on 2011-04-02
1551
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1552
    my ($self, $source) = @_;
1553
    
cleanup
Yuki Kimoto authored on 2011-04-02
1554
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1555
    my $tables = [];
1556
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1557
    my $q = $self->_quote;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1558
    my $quoted_safety_character_re = $self->q("?([$safety_character]+)", 1);
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1559
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1560
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1561
    while ($source =~ /$table_re/g) {
1562
        push @$tables, $1;
1563
    }
1564
    
1565
    return $tables;
1566
}
1567

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1571
    $where ||= {};
cleanup
Yuki Kimoto authored on 2011-10-25
1572
    $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
cleanup
Yuki Kimoto authored on 2011-10-25
1573
    $where_param ||= {};
cleanup
Yuki Kimoto authored on 2011-10-21
1574
    my $w = {};
1575
    my $where_clause = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1576

            
cleanup
Yuki Kimoto authored on 2011-10-25
1577
    my $obj;
1578
    
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1579
    if (ref $where) {
cleanup
Yuki Kimoto authored on 2011-10-25
1580
        if (ref $where eq 'HASH') {
1581
            my $clause = ['and'];
cleanup
Yuki Kimoto authored on 2011-11-01
1582
            my $column_join = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1583
            for my $column (keys %$where) {
cleanup
Yuki Kimoto authored on 2011-11-01
1584
                $column_join .= $column;
cleanup
Yuki Kimoto authored on 2011-10-25
1585
                my $table;
1586
                my $c;
1587
                if ($column =~ /(?:(.*?)\.)?(.*)/) {
1588
                    $table = $1;
1589
                    $c = $2;
1590
                }
1591
                
1592
                my $table_quote;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1593
                $table_quote = $self->q($table) if defined $table;
1594
                my $column_quote = $self->q($c);
cleanup
Yuki Kimoto authored on 2011-10-25
1595
                $column_quote = $table_quote . '.' . $column_quote
1596
                  if defined $table_quote;
cleanup
Yuki Kimoto authored on 2011-11-01
1597
                push @$clause, "$column_quote = :$column";
cleanup
Yuki Kimoto authored on 2011-10-25
1598
            }
cleanup
Yuki Kimoto authored on 2011-11-01
1599

            
1600
            # Check unsafety column
1601
            my $safety = $self->safety_character;
1602
            unless ($column_join =~ /^[$safety\.]+$/) {
1603
                for my $column (keys %$where) {
1604
                    croak qq{"$column" is not safety column name } . _subname
1605
                      unless $column =~ /^[$safety\.]+$/;
1606
                }
1607
            }
1608
            
cleanup
Yuki Kimoto authored on 2011-10-25
1609
            $obj = $self->where(clause => $clause, param => $where);
1610
        }
cleanup
Yuki Kimoto authored on 2011-11-01
1611
        elsif (ref $where eq 'DBIx::Custom::Where') { $obj = $where }
cleanup
Yuki Kimoto authored on 2011-10-25
1612
        elsif (ref $where eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-11-01
1613
            $obj = $self->where(clause => $where->[0], param => $where->[1]);
cleanup
Yuki Kimoto authored on 2011-10-25
1614
        }
1615
        
1616
        # Check where argument
1617
        croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1618
            . qq{or array reference, which contains where clause and parameter}
1619
            . _subname
1620
          unless ref $obj eq 'DBIx::Custom::Where';
1621

            
1622
        $w->{param} = keys %$where_param
1623
                    ? $self->merge_param($where_param, $obj->param)
1624
                    : $obj->param;
1625
        $w->{clause} = $obj->to_string;
cleanup
Yuki Kimoto authored on 2011-10-21
1626
    }
1627
    elsif ($where) {
1628
        $w->{clause} = "where $where";
cleanup
Yuki Kimoto authored on 2011-10-25
1629
        $w->{param} = $where_param;
cleanup
Yuki Kimoto authored on 2011-10-21
1630
    }
1631
    
1632
    return $w;
1633
}
1634

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

            
1638
    # Initialize filters
1639
    $self->{filter} ||= {};
micro optimization
Yuki Kimoto authored on 2011-07-30
1640
    $self->{filter}{on} = 1;
updated pod
Yuki Kimoto authored on 2011-06-21
1641
    $self->{filter}{out} ||= {};
1642
    $self->{filter}{in} ||= {};
1643
    $self->{filter}{end} ||= {};
1644
    
1645
    # Usage
1646
    my $usage = "Usage: \$dbi->apply_filter(" .
1647
                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1648
                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1649
    
1650
    # Apply filter
1651
    for (my $i = 0; $i < @cinfos; $i += 2) {
1652
        
1653
        # Column
1654
        my $column = $cinfos[$i];
1655
        if (ref $column eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-10-21
1656
            for my $c (@$column) {
updated pod
Yuki Kimoto authored on 2011-06-21
1657
                push @cinfos, $c, $cinfos[$i + 1];
1658
            }
1659
            next;
1660
        }
1661
        
1662
        # Filter infomation
1663
        my $finfo = $cinfos[$i + 1] || {};
1664
        croak "$usage (table: $table) " . _subname
1665
          unless  ref $finfo eq 'HASH';
cleanup
Yuki Kimoto authored on 2011-10-21
1666
        for my $ftype (keys %$finfo) {
updated pod
Yuki Kimoto authored on 2011-06-21
1667
            croak "$usage (table: $table) " . _subname
1668
              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1669
        }
1670
        
1671
        # Set filters
cleanup
Yuki Kimoto authored on 2011-10-21
1672
        for my $way (qw/in out end/) {
updated pod
Yuki Kimoto authored on 2011-06-21
1673
        
1674
            # Filter
1675
            my $filter = $finfo->{$way};
1676
            
1677
            # Filter state
1678
            my $state = !exists $finfo->{$way} ? 'not_exists'
1679
                      : !defined $filter        ? 'not_defined'
1680
                      : ref $filter eq 'CODE'   ? 'code'
1681
                      : 'name';
1682
            
1683
            # Filter is not exists
1684
            next if $state eq 'not_exists';
1685
            
1686
            # Check filter name
1687
            croak qq{Filter "$filter" is not registered } . _subname
1688
              if  $state eq 'name'
1689
               && ! exists $self->filters->{$filter};
1690
            
1691
            # Set filter
1692
            my $f = $state eq 'not_defined' ? undef
1693
                  : $state eq 'code'        ? $filter
1694
                  : $self->filters->{$filter};
1695
            $self->{filter}{$way}{$table}{$column} = $f;
1696
            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1697
            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1698
            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1699
        }
1700
    }
1701
    
1702
    return $self;
1703
}
1704

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1705
# DEPRECATED!
1706
has 'data_source';
1707
has dbi_options => sub { {} };
1708
has filter_check  => 1;
1709
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1710
has dbi_option => sub { {} };
1711
has default_dbi_option => sub {
1712
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1713
    return shift->default_option;
1714
};
1715

            
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
1716
# DEPRECATED
1717
sub tag_parse {
1718
   my $self = shift;
1719
   warn "tag_parse is DEPRECATED! use \$ENV{DBIX_CUSTOM_TAG_PARSE} " .
1720
         "environment variable";
1721
    if (@_) {
1722
        $self->{tag_parse} = $_[0];
1723
        return $self;
1724
    }
1725
    return $self->{tag_parse};
1726
}
1727

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1728
# DEPRECATED!
1729
sub method {
1730
    warn "method is DEPRECATED! use helper instead";
1731
    return shift->helper(@_);
1732
}
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1733

            
1734
# DEPRECATED!
1735
sub assign_param {
1736
    my $self = shift;
1737
    warn "assing_param is DEPRECATED! use assign_clause instead";
1738
    return $self->assign_clause(@_);
1739
}
1740

            
1741
# DEPRECATED
1742
sub update_param {
1743
    my ($self, $param, $opts) = @_;
1744
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1745
    warn "update_param is DEPRECATED! use assign_clause instead.";
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1746
    
1747
    # Create update parameter tag
1748
    my $tag = $self->assign_clause($param, $opts);
1749
    $tag = "set $tag" unless $opts->{no_set};
1750

            
1751
    return $tag;
1752
}
1753

            
updated pod
Yuki Kimoto authored on 2011-06-21
1754
# DEPRECATED!
1755
sub create_query {
1756
    warn "create_query is DEPRECATED! use query option of each method";
1757
    shift->_create_query(@_);
1758
}
1759

            
cleanup
Yuki Kimoto authored on 2011-06-13
1760
# DEPRECATED!
1761
sub apply_filter {
1762
    my $self = shift;
1763
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1764
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1765
    return $self->_apply_filter(@_);
1766
}
1767

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1774
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1775
    my $primary_keys = delete $opt{primary_key};
1776
    my $where = delete $opt{where};
1777
    my $param = delete $opt{param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1778
    
1779
    # Table
1780
    croak qq{"table" option must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1781
      unless $opt{table};
1782
    my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1783
    
1784
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1785
    my $where_param = $self->_id_to_param($where, $primary_keys);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1786
    
cleanup
Yuki Kimoto authored on 2011-10-21
1787
    return $self->select(where => $where_param, %opt);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1788
}
1789

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1794
    warn "delete_at is DEPRECATED! use delete method id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1795
    
cleanup
Yuki Kimoto authored on 2011-10-21
1796
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1797
    my $primary_keys = delete $opt{primary_key};
1798
    my $where = delete $opt{where};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1799
    
1800
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1801
    my $where_param = $self->_id_to_param($where, $primary_keys);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1802
    
cleanup
Yuki Kimoto authored on 2011-10-21
1803
    return $self->delete(where => $where_param, %opt);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1804
}
1805

            
cleanup
Yuki Kimoto authored on 2011-06-08
1806
# DEPRECATED!
1807
sub update_at {
1808
    my $self = shift;
1809

            
cleanup
Yuki Kimoto authored on 2011-10-21
1810
    warn "update_at is DEPRECATED! use update method id option instead";
cleanup
Yuki Kimoto authored on 2011-06-08
1811
    
cleanup
Yuki Kimoto authored on 2011-10-21
1812
    # Options
cleanup
Yuki Kimoto authored on 2011-06-08
1813
    my $param;
1814
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1815
    my %opt = @_;
1816
    my $primary_keys = delete $opt{primary_key};
1817
    my $where = delete $opt{where};
1818
    my $p = delete $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-06-08
1819
    $param  ||= $p;
1820
    
1821
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1822
    my $where_param = $self->_id_to_param($where, $primary_keys);
cleanup
Yuki Kimoto authored on 2011-06-08
1823
    
cleanup
Yuki Kimoto authored on 2011-10-21
1824
    return $self->update(where => $where_param, param => $param, %opt);
cleanup
Yuki Kimoto authored on 2011-06-08
1825
}
1826

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1827
# DEPRECATED!
1828
sub insert_at {
1829
    my $self = shift;
1830
    
cleanup
Yuki Kimoto authored on 2011-10-21
1831
    warn "insert_at is DEPRECATED! use insert method id option instead";
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1832
    
cleanup
Yuki Kimoto authored on 2011-10-21
1833
    # Options
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1834
    my $param;
1835
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1836
    my %opt = @_;
1837
    my $primary_key = delete $opt{primary_key};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1838
    $primary_key = [$primary_key] unless ref $primary_key;
cleanup
Yuki Kimoto authored on 2011-10-21
1839
    my $where = delete $opt{where};
1840
    my $p = delete $opt{param} || {};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1841
    $param  ||= $p;
1842
    
1843
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1844
    my $where_param = $self->_id_to_param($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1845
    $param = $self->merge_param($where_param, $param);
1846
    
cleanup
Yuki Kimoto authored on 2011-10-21
1847
    return $self->insert(param => $param, %opt);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1848
}
1849

            
added warnings
Yuki Kimoto authored on 2011-06-07
1850
# DEPRECATED!
1851
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1852
    my $self = shift;
1853
    
added warnings
Yuki Kimoto authored on 2011-06-07
1854
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1855
    
1856
    # Merge tag
1857
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1858
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1859
    
1860
    return $self;
1861
}
1862

            
1863
# DEPRECATED!
1864
sub register_tag_processor {
1865
    my $self = shift;
1866
    warn "register_tag_processor is DEPRECATED!";
1867
    # Merge tag
1868
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1869
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1870
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1871
}
1872

            
cleanup
Yuki Kimoto authored on 2011-01-25
1873
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1874
sub default_bind_filter {
1875
    my $self = shift;
1876
    
cleanup
Yuki Kimoto authored on 2011-06-13
1877
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1878
    
cleanup
Yuki Kimoto authored on 2011-01-12
1879
    if (@_) {
1880
        my $fname = $_[0];
1881
        
1882
        if (@_ && !$fname) {
1883
            $self->{default_out_filter} = undef;
1884
        }
1885
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1886
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1887
              unless exists $self->filters->{$fname};
1888
        
1889
            $self->{default_out_filter} = $self->filters->{$fname};
1890
        }
1891
        return $self;
1892
    }
1893
    
1894
    return $self->{default_out_filter};
1895
}
1896

            
cleanup
Yuki Kimoto authored on 2011-01-25
1897
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1898
sub default_fetch_filter {
1899
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1900

            
cleanup
Yuki Kimoto authored on 2011-06-13
1901
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1902
    
1903
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1904
        my $fname = $_[0];
1905

            
cleanup
Yuki Kimoto authored on 2011-01-12
1906
        if (@_ && !$fname) {
1907
            $self->{default_in_filter} = undef;
1908
        }
1909
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1910
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1911
              unless exists $self->filters->{$fname};
1912
        
1913
            $self->{default_in_filter} = $self->filters->{$fname};
1914
        }
1915
        
1916
        return $self;
1917
    }
1918
    
many changed
Yuki Kimoto authored on 2011-01-23
1919
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1920
}
1921

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1922
# DEPRECATED!
1923
sub insert_param {
1924
    my $self = shift;
1925
    warn "insert_param is DEPRECATED! use values_clause instead";
1926
    return $self->values_clause(@_);
1927
}
1928

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1929
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1930
sub insert_param_tag {
1931
    warn "insert_param_tag is DEPRECATED! " .
1932
         "use insert_param instead!";
1933
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1934
}
1935

            
1936
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1937
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1938
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1939
         "use update_param instead";
1940
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1941
}
cleanup
Yuki Kimoto authored on 2011-03-08
1942
# DEPRECATED!
1943
sub _push_relation {
1944
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1945
    
1946
    if (keys %{$relation || {}}) {
micro optimization
Yuki Kimoto authored on 2011-09-30
1947
        $$sql .= $need_where ? 'where ' : 'and ';
cleanup
Yuki Kimoto authored on 2011-10-21
1948
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1949
            my $table1 = (split (/\./, $rcolumn))[0];
1950
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1951
            push @$tables, ($table1, $table2);
micro optimization
Yuki Kimoto authored on 2011-09-30
1952
            $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
cleanup
Yuki Kimoto authored on 2011-03-08
1953
        }
1954
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
1955
    $$sql =~ s/and $/ /;
cleanup
Yuki Kimoto authored on 2011-03-08
1956
}
1957

            
1958
# DEPRECATED!
1959
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1960
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1961
    
1962
    if (keys %{$relation || {}}) {
cleanup
Yuki Kimoto authored on 2011-10-21
1963
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1964
            my $table1 = (split (/\./, $rcolumn))[0];
1965
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1966
            my $table1_exists;
1967
            my $table2_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1968
            for my $table (@$tables) {
cleanup
Yuki Kimoto authored on 2011-03-08
1969
                $table1_exists = 1 if $table eq $table1;
1970
                $table2_exists = 1 if $table eq $table2;
1971
            }
1972
            unshift @$tables, $table1 unless $table1_exists;
1973
            unshift @$tables, $table2 unless $table2_exists;
1974
        }
1975
    }
1976
}
1977

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1980
=head1 NAME
1981

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

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

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1986
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1987
    
1988
    # Connect
1989
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1990
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1991
        user => 'ken',
1992
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1993
        option => {mysql_enable_utf8 => 1}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1994
    );
cleanup
yuki-kimoto authored on 2010-08-05
1995

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1996
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1997
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1998
    
1999
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
2000
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
2001
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
2002
    
2003
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
2004
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
2005

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2055
Named place holder support
2056

            
2057
=item *
2058

            
cleanup
Yuki Kimoto authored on 2011-07-29
2059
Model support
2060

            
2061
=item *
2062

            
2063
Connection manager support
2064

            
2065
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2066

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

            
2071
=item *
2072

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

            
2075
=item *
2076

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

            
2079
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2080

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2088
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2089
L<DBIx::Custom::Result>,
2090
L<DBIx::Custom::Query>,
2091
L<DBIx::Custom::Where>,
2092
L<DBIx::Custom::Model>,
2093
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2094

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

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

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

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

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

            
2108
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2109
        "dbi:mysql:database=$database",
2110
        $user,
2111
        $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2112
        DBIx::Custom->new->default_option
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2113
    );
2114
    
updated pod
Yuki Kimoto authored on 2011-06-21
2115
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2116

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

            
2120
    my $dbi = DBIx::Custom->connect(
2121
      dsn => $dsn, user => $user, password => $password, connector => 1);
2122
    
2123
    my $connector = $dbi->connector; # DBIx::Connector
2124

            
2125
Note that L<DBIx::Connector> must be installed.
2126

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

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

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

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

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2142
    {
2143
        RaiseError => 1,
2144
        PrintError => 0,
2145
        AutoCommit => 1,
2146
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2147

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

            
2150
    my $exclude_table = $dbi->exclude_table;
2151
    $dbi = $dbi->exclude_table(qr/pg_/);
2152

            
2153
Excluded table regex.
2154
C<each_column>, C<each_table>, C<type_rule>,
2155
and C<setup_model> methods ignore matching tables.
2156

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

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

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

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

            
2166
    my $last_sql = $dbi->last_sql;
2167
    $dbi = $dbi->last_sql($last_sql);
2168

            
2169
Get last successed SQL executed by C<execute> method.
2170

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

            
2173
    my $now = $dbi->now;
2174
    $dbi = $dbi->now($now);
2175

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

            
2178
    sub {
2179
        my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2180
        $mon++;
2181
        $year += 1900;
2182
        return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2183
    }
2184

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

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

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

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

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

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

            
2199
    my $option = $dbi->option;
2200
    $dbi = $dbi->option($option);
2201

            
2202
L<DBI> option, used when C<connect> method is executed.
2203
Each value in option override the value of C<default_option>.
2204

            
cleanup
yuki-kimoto authored on 2010-10-17
2205
=head2 C<password>
2206

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2227
You can set quote pair.
2228

            
2229
    $dbi->quote('[]');
2230

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2240
    my $safety_character = $dbi->safety_character;
2241
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2242

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

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

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

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

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

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

            
2259
    my $tag_parse = $dbi->tag_parse(0);
2260
    $dbi = $dbi->tag_parse;
2261

            
2262
Enable DEPRECATED tag parsing functionality, default to 1.
2263
If you want to disable tag parsing functionality, set to 0.
2264

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

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

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

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

            
2274
    my $user_column_info = $dbi->user_column_info;
2275
    $dbi = $dbi->user_column_info($user_column_info);
2276

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

            
2279
    [
2280
        {table => 'book', column => 'title', info => {...}},
2281
        {table => 'author', column => 'name', info => {...}}
2282
    ]
2283

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

            
2286
    my $user_column_info
2287
      = $dbi->get_column_info(exclude_table => qr/^system/);
2288
    $dbi->user_column_info($user_column_info);
2289

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

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

            
2295
    my $user_table_info = $dbi->user_table_info;
2296
    $dbi = $dbi->user_table_info($user_table_info);
2297

            
2298
You can set the following data.
2299

            
2300
    [
2301
        {table => 'book', info => {...}},
2302
        {table => 'author', info => {...}}
2303
    ]
2304

            
2305
Usually, you can set return value of C<get_table_info>.
2306

            
2307
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2308
    $dbi->user_table_info($user_table_info);
2309

            
2310
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2311
to find table info.
2312

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2349
Create column clause. The follwoing column clause is created.
2350

            
2351
    book.author as "book.author",
2352
    book.title as "book.title"
2353

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2356
    # Separator is hyphen
2357
    $dbi->separator('-');
2358
    
2359
    book.author as "book-author",
2360
    book.title as "book-title"
2361
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2362
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2363

            
update pod
Yuki Kimoto authored on 2011-03-13
2364
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2365
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2366
        user => 'ken',
2367
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2368
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2369
    );
2370

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

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

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

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

            
2381
Get rows count.
2382

            
2383
Options is same as C<select> method's ones.
2384

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2387
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2388
        table => 'book',
2389
        primary_key => 'id',
2390
        join => [
2391
            'inner join company on book.comparny_id = company.id'
2392
        ],
2393
    );
2394

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

            
2398
   $dbi->model('book')->select(...);
2399

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

            
2402
    my $dbh = $dbi->dbh;
2403

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

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

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

            
2411
Execute delete statement.
2412

            
2413
The following opitons are available.
2414

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

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

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

            
2422
=item C<id>
2423

            
2424
    id => 4
2425
    id => [4, 5]
2426

            
2427
ID corresponding to C<primary_key>.
2428
You can delete rows by C<id> and C<primary_key>.
2429

            
2430
    $dbi->delete(
fixed pod
Yuki Kimoto authored on 2011-10-20
2431
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2432
        id => [4, 5],
2433
        table => 'book',
2434
    );
2435

            
2436
The above is same as the followin one.
2437

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

            
2440
=item C<prefix>
2441

            
2442
    prefix => 'some'
2443

            
2444
prefix before table name section.
2445

            
2446
    delete some from book
2447

            
2448
=item C<table>
2449

            
2450
    table => 'book'
2451

            
2452
Table name.
2453

            
2454
=item C<where>
2455

            
2456
Same as C<select> method's C<where> option.
2457

            
2458
=back
2459

            
2460
=head2 C<delete_all>
2461

            
2462
    $dbi->delete_all(table => $table);
2463

            
2464
Execute delete statement for all rows.
2465
Options is same as C<delete>.
2466

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

            
2469
    $dbi->each_column(
2470
        sub {
2471
            my ($dbi, $table, $column, $column_info) = @_;
2472
            
2473
            my $type = $column_info->{TYPE_NAME};
2474
            
2475
            if ($type eq 'DATE') {
2476
                # ...
2477
            }
2478
        }
2479
    );
2480

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

            
2486
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2487
infromation, you can improve the performance of C<each_column> in
2488
the following way.
2489

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

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

            
2496
    $dbi->each_table(
2497
        sub {
2498
            my ($dbi, $table, $table_info) = @_;
2499
            
2500
            my $table_name = $table_info->{TABLE_NAME};
2501
        }
2502
    );
2503

            
improved pod
Yuki Kimoto authored on 2011-10-14
2504
Iterate all table informationsfrom in database.
2505
Argument is callback which is executed when one table is found.
2506
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2507
C<table information>.
2508

            
2509
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2510
infromation, you can improve the performance of C<each_table> in
2511
the following way.
2512

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

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

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

            
2524
    my $result = $dbi->execute(
2525
      "select * from book where title = :book.title and author like :book.author",
2526
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2527
    );
2528

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2535
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2536
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2537
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2538
    select * from book where title = :title and author like :author
2539
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2540
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2541
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2542

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2546
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2547
    select * from book where :title{=} and :author{like}
2548
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2549
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2550
    select * from where title = ? and author like ?;
2551

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

            
2556
    select * from where title = "aa\\:bb";
2557

            
cleanup
Yuki Kimoto authored on 2011-10-20
2558
B<OPTIONS>
2559

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

            
2562
=over 4
2563

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

            
2566
You can filter sql after the sql is build.
2567

            
2568
    after_build_sql => $code_ref
2569

            
2570
The following one is one example.
2571

            
2572
    $dbi->select(
2573
        table => 'book',
2574
        column => 'distinct(name)',
2575
        after_build_sql => sub {
2576
            "select count(*) from ($_[0]) as t1"
2577
        }
2578
    );
2579

            
2580
The following SQL is executed.
2581

            
2582
    select count(*) from (select distinct(name) from book) as t1;
2583

            
cleanup
Yuki Kimoto authored on 2011-10-20
2584
=item C<append>
2585

            
2586
    append => 'order by name'
2587

            
2588
Append some statement after SQL.
2589

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

            
2592
Specify database bind data type.
2593

            
2594
    bind_type => [image => DBI::SQL_BLOB]
2595
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2596

            
2597
This is used to bind parameter by C<bind_param> of statment handle.
2598

            
2599
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2600

            
update pod
Yuki Kimoto authored on 2011-03-13
2601
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2602
    
2603
    filter => {
2604
        title  => sub { uc $_[0] }
2605
        author => sub { uc $_[0] }
2606
    }
update pod
Yuki Kimoto authored on 2011-03-13
2607

            
updated pod
Yuki Kimoto authored on 2011-06-09
2608
    # Filter name
2609
    filter => {
2610
        title  => 'upper_case',
2611
        author => 'upper_case'
2612
    }
2613
        
2614
    # At once
2615
    filter => [
2616
        [qw/title author/]  => sub { uc $_[0] }
2617
    ]
2618

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

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

            
2626
    query => 1
2627

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

            
DBIx::Custom::Query is DEPRE...
Yuki Kimoto authored on 2011-11-15
2631
    my $sql = $query->{sql};
2632
    my $columns = $query->{columns};
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2633
    
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
2634
=item C<reuse>
2635
    
2636
    reuse => $hash_ref
2637

            
2638
Reuse query object if the hash reference variable is set.
2639
    
2640
    my $queries = {};
2641
    $dbi->execute($sql, $param, reuse => $queries);
2642

            
2643
This will improved performance when you want to execute same query repeatedly
2644
because generally creating query object is slow.
2645

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2648
    primary_key => 'id'
2649
    primary_key => ['id1', 'id2']
2650

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2653
=item C<table>
2654
    
2655
    table => 'author'
2656

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2664
    # Same
2665
    $dbi->execute(
2666
      "select * from book where title = :book.title and author = :book.author",
2667
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2668

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

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

            
2673
Table alias. Key is real table name, value is alias table name.
2674
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2675
on alias table name.
2676

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

            
2679
    type_rule_off => 1
2680

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

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

            
2685
    type_rule1_off => 1
2686

            
2687
Turn C<into1> type rule off.
2688

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

            
2691
    type_rule2_off => 1
2692

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

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

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

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

            
2701
get column infomation except for one which match C<exclude_table> pattern.
2702

            
2703
    [
2704
        {table => 'book', column => 'title', info => {...}},
2705
        {table => 'author', column => 'name' info => {...}}
2706
    ]
2707

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

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

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

            
2714
    [
2715
        {table => 'book', info => {...}},
2716
        {table => 'author', info => {...}}
2717
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2718

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

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

            
2723
    $dbi->helper(
2724
        find_or_create   => sub {
2725
            my $self = shift;
2726
            
2727
            # Process
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
2728
        },
2729
        ...
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2730
    );
2731

            
2732
Register helper. These helper is called directly from L<DBIx::Custom> object.
2733

            
2734
    $dbi->find_or_create;
2735

            
cleanup
yuki-kimoto authored on 2010-10-17
2736
=head2 C<insert>
2737

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

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

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

            
2746
    {date => \"NOW()"}
2747

            
cleanup
Yuki Kimoto authored on 2011-10-20
2748
B<options>
2749

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

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

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

            
2757
    created_at => 'created_datetime'
2758

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2765
    id => 4
2766
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2767

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2771
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2772
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
2773
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2774
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2775
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2776
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2777

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

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

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

            
2787
    prefix => 'or replace'
2788

            
2789
prefix before table name section
2790

            
2791
    insert or replace into book
2792

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

            
2795
    table => 'book'
2796

            
2797
Table name.
2798

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

            
2801
This option is same as C<update> method C<updated_at> option.
2802

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

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

            
2807
placeholder wrapped string.
2808

            
2809
If the following statement
2810

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

            
2814
is executed, the following SQL is executed.
2815

            
2816
    insert into book price values ( ? + 5 );
2817

            
update pod
Yuki Kimoto authored on 2011-03-13
2818
=back
2819

            
2820
=over 4
2821

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2829
    lib / MyModel.pm
2830
        / MyModel / book.pm
2831
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2832

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

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

            
2837
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2838
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2839
    
2840
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2841

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2844
B<MyModel/book.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::book;
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;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2850

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2853
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2854
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2855
    
2856
    1;
2857
    
updated pod
Yuki Kimoto authored on 2011-06-21
2858
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2859

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

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

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

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

            
2869
    my $like_value = $dbi->like_value
2870

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

            
2873
    sub { "%$_[0]%" }
2874

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

            
2877
    my $mapper = $dbi->mapper(param => $param);
2878

            
2879
Create a new L<DBIx::Custom::Mapper> object.
2880

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

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

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

            
2887
    {key1 => [1, 1], key2 => 2}
2888

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

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

            
2893
    my $model = $dbi->model('book');
2894

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

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

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

            
2902
Create column clause for myself. The follwoing column clause is created.
2903

            
2904
    book.author as author,
2905
    book.title as title
2906

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

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

            
2916
Create a new L<DBIx::Custom> object.
2917

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

            
2920
    my $not_exists = $dbi->not_exists;
2921

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

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

            
2927
    my $order = $dbi->order;
2928

            
2929
Create a new L<DBIx::Custom::Order> object.
2930

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

            
2933
    my $quooted = $dbi->q("title");
2934

            
2935
Quote string by value of C<quote>.
2936

            
cleanup
yuki-kimoto authored on 2010-10-17
2937
=head2 C<register_filter>
2938

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

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

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

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

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

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

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

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

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

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

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

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

            
2991
    book.author as "book.author",
2992
    book.title as "book.title",
2993
    person.name as "person.name",
2994
    person.age as "person.age"
2995

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

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

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

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

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

            
3009
    id => 4
3010
    id => [4, 5]
3011

            
3012
ID corresponding to C<primary_key>.
3013
You can select rows by C<id> and C<primary_key>.
3014

            
3015
    $dbi->select(
fixed pod
Yuki Kimoto authored on 2011-10-20
3016
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3017
        id => [4, 5],
3018
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3019
    );
3020

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3023
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3024
        where => {id1 => 4, id2 => 5},
3025
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3026
    );
3027
    
cleanup
Yuki Kimoto authored on 2011-10-20
3028
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3029

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

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

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

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

            
3042
    prefix => 'SQL_CALC_FOUND_ROWS'
3043

            
3044
Prefix of column cluase
3045

            
3046
    select SQL_CALC_FOUND_ROWS title, author from book;
3047

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

            
3050
    join => [
3051
        'left outer join company on book.company_id = company_id',
3052
        'left outer join location on company.location_id = location.id'
3053
    ]
3054
        
3055
Join clause. If column cluase or where clause contain table name like "company.name",
3056
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3057

            
3058
    $dbi->select(
3059
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3060
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3061
        where => {'company.name' => 'Orange'},
3062
        join => [
3063
            'left outer join company on book.company_id = company.id',
3064
            'left outer join location on company.location_id = location.id'
3065
        ]
3066
    );
3067

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3071
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3072
    from book
3073
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3074
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3075

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3076
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
3077
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3078

            
3079
    $dbi->select(
3080
        table => 'book',
3081
        column => ['company.location_id as location_id'],
3082
        where => {'company.name' => 'Orange'},
3083
        join => [
3084
            {
3085
                clause => 'left outer join location on company.location_id = location.id',
3086
                table => ['company', 'location']
3087
            }
3088
        ]
3089
    );
3090

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3095
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3096

            
updated document
Yuki Kimoto authored on 2011-06-09
3097
=item C<where>
3098
    
3099
    # Hash refrence
3100
    where => {author => 'Ken', 'title' => 'Perl'}
3101
    
3102
    # DBIx::Custom::Where object
3103
    where => $dbi->where(
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3104
        clause => ['and', ':author{=}', ':title{like}'],
updated document
Yuki Kimoto authored on 2011-06-09
3105
        param  => {author => 'Ken', title => '%Perl%'}
3106
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3107
    
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3108
    # Array reference, this is same as above
updated pod
Yuki Kimoto authored on 2011-06-21
3109
    where => [
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3110
        ['and', ':author{=}', ':title{like}'],
updated pod
Yuki Kimoto authored on 2011-06-21
3111
        {author => 'Ken', title => '%Perl%'}
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3112
    ];
updated pod
Yuki Kimoto authored on 2011-06-21
3113
    
3114
    # String
3115
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3116

            
cleanup
Yuki Kimoto authored on 2011-10-20
3117
Where clause. See L<DBIx::Custom::Where>.
updated document
Yuki Kimoto authored on 2011-06-09
3118
    
update pod
Yuki Kimoto authored on 2011-03-12
3119
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3120

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

            
3123
    $dbi->setup_model;
3124

            
3125
Setup all model objects.
3126
C<columns> of model object is automatically set, parsing database information.
3127

            
3128
=head2 C<type_rule>
3129

            
3130
    $dbi->type_rule(
3131
        into1 => {
3132
            date => sub { ... },
3133
            datetime => sub { ... }
3134
        },
3135
        into2 => {
3136
            date => sub { ... },
3137
            datetime => sub { ... }
3138
        },
3139
        from1 => {
3140
            # DATE
3141
            9 => sub { ... },
3142
            # DATETIME or TIMESTAMP
3143
            11 => sub { ... },
3144
        }
3145
        from2 => {
3146
            # DATE
3147
            9 => sub { ... },
3148
            # DATETIME or TIMESTAMP
3149
            11 => sub { ... },
3150
        }
3151
    );
3152

            
3153
Filtering rule when data is send into and get from database.
3154
This has a little complex problem.
3155

            
3156
In C<into1> and C<into2> you can specify
3157
type name as same as type name defined
3158
by create table, such as C<DATETIME> or C<DATE>.
3159

            
3160
Note that type name and data type don't contain upper case.
3161
If these contain upper case charactor, you convert it to lower case.
3162

            
3163
C<into2> is executed after C<into1>.
3164

            
3165
Type rule of C<into1> and C<into2> is enabled on the following
3166
column name.
3167

            
3168
=over 4
3169

            
3170
=item 1. column name
3171

            
3172
    issue_date
3173
    issue_datetime
3174

            
3175
This need C<table> option in each method.
3176

            
3177
=item 2. table name and column name, separator is dot
3178

            
3179
    book.issue_date
3180
    book.issue_datetime
3181

            
3182
=back
3183

            
3184
You get all type name used in database by C<available_typename>.
3185

            
3186
    print $dbi->available_typename;
3187

            
3188
In C<from1> and C<from2> you specify data type, not type name.
3189
C<from2> is executed after C<from1>.
3190
You get all data type by C<available_datatype>.
3191

            
3192
    print $dbi->available_datatype;
3193

            
3194
You can also specify multiple types at once.
3195

            
3196
    $dbi->type_rule(
3197
        into1 => [
3198
            [qw/DATE DATETIME/] => sub { ... },
3199
        ],
3200
    );
3201

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

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

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

            
3208
If you want to set constant value to row data, use scalar reference
3209
as parameter value.
3210

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3222
    id => 4
3223
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3224

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3228
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3229
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
3230
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3231
        id => [4, 5],
3232
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3233
    );
update pod
Yuki Kimoto authored on 2011-03-13
3234

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3237
    $dbi->update(
3238
        {title => 'Perl', author => 'Ken'}
3239
        where => {id1 => 4, id2 => 5},
3240
        table => 'book'
3241
    );
update pod
Yuki Kimoto authored on 2011-03-13
3242

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

            
3245
    prefix => 'or replace'
3246

            
3247
prefix before table name section
3248

            
3249
    update or replace book
3250

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

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

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

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

            
3259
Same as C<select> method's C<where> option.
3260

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

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

            
3265
placeholder wrapped string.
3266

            
3267
If the following statement
3268

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

            
3272
is executed, the following SQL is executed.
3273

            
3274
    update book set price =  ? + 5;
3275

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

            
3278
    updated_at => 'updated_datetime'
3279

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3284
=back
update pod
Yuki Kimoto authored on 2011-03-13
3285

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

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

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

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3293
=head2 C<update_or_insert>
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3294
    
3295
    # ID
3296
    $dbi->update_or_insert(
3297
        {title => 'Perl'},
3298
        table => 'book',
3299
        id => 1,
3300
        primary_key => 'id',
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3301
        option => {
3302
            select => {
3303
                 append => 'for update'
3304
            }
3305
        }
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3306
    );
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3307

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3308
Update or insert.
3309

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

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3314
C<OPTIONS>
3315

            
3316
C<update_or_insert> method use all common option
3317
in C<select>, C<update>, C<delete>, and has the following new ones.
3318

            
3319
=over 4
3320

            
3321
=item C<option>
3322

            
3323
    option => {
3324
        select => {
3325
            append => '...'
3326
        },
3327
        insert => {
3328
            prefix => '...'
3329
        },
3330
        update => {
3331
            filter => {}
3332
        }
3333
    }
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3334

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

            
3338
=over 4
3339

            
3340
=item C<select_option>
3341

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

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

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

            
3349
    $dbi->show_datatype($table);
3350

            
3351
Show data type of the columns of specified table.
3352

            
3353
    book
3354
    title: 5
3355
    issue_date: 91
3356

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

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

            
3361
    $dbi->show_tables;
3362

            
3363
Show tables.
3364

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

            
3367
    $dbi->show_typename($table);
3368

            
3369
Show type name of the columns of specified table.
3370

            
3371
    book
3372
    title: varchar
3373
    issue_date: date
3374

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

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

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

            
3381
Create values clause.
3382

            
3383
    (title, author) values (title = :title, age = :age);
3384

            
3385
You can use this in insert statement.
3386

            
3387
    my $insert_sql = "insert into book $values_clause";
3388

            
3389
=head2 C<where>
3390

            
3391
    my $where = $dbi->where(
3392
        clause => ['and', 'title = :title', 'author = :author'],
3393
        param => {title => 'Perl', author => 'Ken'}
3394
    );
3395

            
3396
Create a new L<DBIx::Custom::Where> object.
3397

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

            
3400
=head2 C<DBIX_CUSTOM_DEBUG>
3401

            
3402
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3403
executed SQL and bind values are printed to STDERR.
3404

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

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

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

            
3411
If you set DBIX_CUSTOM_TAG_PARSE to 0, tag parsing is off.
3412

            
3413
=head2 C<DBIX_CUSTOM_DISABLE_MODEL_EXECUTE>
3414

            
3415
If you set DBIX_CUSTOM_DISABLE_MODEL_EXECUTE to 1,
3416
L<DBIx::Custom::Model> execute method call L<DBIx::Custom> execute.
3417

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

            
3420
L<DBIx::Custom>
3421

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

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

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

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

            
3487
This module is DEPRECATED! # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3488
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3489
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3490
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3491
    table # will be removed at 2017/1/1
3492
    filters # will be removed at 2017/1/1
3493
    
3494
    # Methods
3495
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3496

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

            
3499
This module is DEPRECATED! # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3500
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3501
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3502
    tags # will be removed at 2017/1/1
3503
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3504
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3505
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3506
    register_tag # will be removed at 2017/1/1
3507
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3508
    
3509
    # Others
3510
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3511
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3512

            
3513
L<DBIx::Custom::Result>
3514
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3515
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3516
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3517
    
3518
    # Methods
- DBIx::Custom::Result filte...
Yuki Kimoto authored on 2011-11-03
3519
    filter_on # will be removed at 2017/1/1
3520
    filter_off # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3521
    end_filter # will be removed at 2017/1/1
3522
    remove_end_filter # will be removed at 2017/1/1
3523
    remove_filter # will be removed at 2017/1/1
3524
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3525

            
3526
L<DBIx::Custom::Tag>
3527

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

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

            
3532
    # Other
3533
    prepend method array reference receiving
3534
      $order->prepend(['book', 'desc']); # will be removed 2017/1/1
3535

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

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

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

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

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

            
3551
C<< <kimoto.yuki at gmail.com> >>
3552

            
3553
L<http://github.com/yuki-kimoto/DBIx-Custom>
3554

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3555
=head1 AUTHOR
3556

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

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

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

            
3563
This program is free software; you can redistribute it and/or modify it
3564
under the same terms as Perl itself.
3565

            
3566
=cut