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

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

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

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

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
23
has [qw/connector dsn password quote user exclude_table user_table_info
cleanup
Yuki Kimoto authored on 2011-11-18
24
        user_column_info safety_character/],
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',
cleanup test
Yuki Kimoto authored on 2011-08-10
73
    separator => '.',
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
74
    stash => sub { {} };
cleanup
yuki-kimoto authored on 2010-10-17
75

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
895
sub select {
- select method can receive ...
Yuki Kimoto authored on 2011-11-18
896
    my $self = shift;
897
    my $column = shift if @_ % 2;
898
    my %opt = @_;
899
    $opt{column} = $column if defined $column;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
900

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1171
    my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
1172
    if (@$rows == 0) {
1173
        return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
1174
    }
1175
    elsif (@$rows == 1) {
- fixed update_or_insert bug...
Yuki Kimoto authored on 2011-11-18
1176
        return 0 unless keys %$param;
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1177
        return $self->update($param, %opt, %{$statement_opt->{update} || {}});
1178
    }
1179
    else {
1180
        croak "selected row must be one " . _subname;
1181
    }
cleanup
Yuki Kimoto authored on 2011-10-21
1182
}
1183

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

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

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

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

            
1251
        # Create query
cleanup
Yuki Kimoto authored on 2011-11-18
1252
        my $tag_parse = exists $ENV{DBIX_CUSTOM_TAG_PARSE}
1253
          ? $ENV{DBIX_CUSTOM_TAG_PARSE} : $self->{tag_parse};
1254

            
micro optimization
Yuki Kimoto authored on 2011-11-18
1255
        my $sql = " " . $source || '';
cleanup
Yuki Kimoto authored on 2011-11-18
1256
        if ($tag_parse && ($sql =~ /\s\{/ || $sql =~ /^\{/)) {
1257
            $query = $self->query_builder->build_query($sql);
1258
        }
1259
        else {
1260
            my @columns;
cleanup
Yuki Kimoto authored on 2011-11-18
1261
            my $c = $self->{safety_character};
cleanup
Yuki Kimoto authored on 2011-11-16
1262
            my %duplicate;
1263
            my $duplicate;
1264
            # Parameter regex
cleanup
Yuki Kimoto authored on 2011-11-18
1265
            $sql =~ s/([0-9]):/$1\\:/g;
micro optimization
Yuki Kimoto authored on 2011-11-18
1266
            my $new_sql = '';
1267
            while ($sql =~ /(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s) {
cleanup
Yuki Kimoto authored on 2011-11-18
1268
                push @columns, $2;
1269
                $duplicate = 1 if ++$duplicate{$columns[-1]} > 1;
micro optimization
Yuki Kimoto authored on 2011-11-18
1270
                ($new_sql, $sql) = defined $3 ?
1271
                  ($new_sql . "$1$2 $3 ?", " $4") : ($new_sql . "$1?", " $4");
cleanup
Yuki Kimoto authored on 2011-11-16
1272
            }
micro optimization
Yuki Kimoto authored on 2011-11-18
1273
            $new_sql .= $sql;
1274
            $new_sql =~ s/\\:/:/g if index($new_sql, "\\:") != -1;
cleanup
Yuki Kimoto authored on 2011-11-16
1275

            
1276
            # Create query
micro optimization
Yuki Kimoto authored on 2011-11-18
1277
            $query = {sql => $new_sql, columns => \@columns, duplicate => $duplicate};
cleanup
Yuki Kimoto authored on 2011-11-16
1278
        }
cleanup
Yuki Kimoto authored on 2011-11-16
1279
        
updated pod
Yuki Kimoto authored on 2011-06-21
1280
        # Save query to cache
1281
        $self->cache_method->(
1282
            $self, $source,
1283
            {
micro optimization
Yuki Kimoto authored on 2011-11-16
1284
                sql     => $query->{sql}, 
1285
                columns => $query->{columns},
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1286
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1287
            }
1288
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1289
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1290

            
1291
    # Filter SQL
micro optimization
Yuki Kimoto authored on 2011-11-16
1292
    $query->{sql} = $after_build_sql->($query->{sql}) if $after_build_sql;
1293
    
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1294
    # Save sql
micro optimization
Yuki Kimoto authored on 2011-11-16
1295
    $self->{last_sql} = $query->{sql};
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1296
    
updated pod
Yuki Kimoto authored on 2011-06-21
1297
    # Prepare statement handle
1298
    my $sth;
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1299
    eval { $sth = $self->dbh->prepare($query->{sql}) };
updated pod
Yuki Kimoto authored on 2011-06-21
1300
    
1301
    if ($@) {
1302
        $self->_croak($@, qq{. Following SQL is executed.\n}
1303
                        . qq{$query->{sql}\n} . _subname);
1304
    }
1305
    
1306
    # Set statement handle
micro optimization
Yuki Kimoto authored on 2011-11-16
1307
    $query->{sth} = $sth;
updated pod
Yuki Kimoto authored on 2011-06-21
1308
    
1309
    # Set filters
cleanup
Yuki Kimoto authored on 2011-11-16
1310
    $query->{filters} = $self->{filters} || $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1311
    
1312
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1313
}
1314

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1426
sub _croak {
1427
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1428
    
1429
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1430
    $append ||= "";
1431
    
1432
    # Verbose
1433
    if ($Carp::Verbose) { croak $error }
1434
    
1435
    # Not verbose
1436
    else {
1437
        
1438
        # Remove line and module infromation
1439
        my $at_pos = rindex($error, ' at ');
1440
        $error = substr($error, 0, $at_pos);
1441
        $error =~ s/\s+$//;
1442
        croak "$error$append";
1443
    }
1444
}
1445

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1448
sub _need_tables {
1449
    my ($self, $tree, $need_tables, $tables) = @_;
1450
    
cleanup
Yuki Kimoto authored on 2011-04-02
1451
    # Get needed tables
cleanup
Yuki Kimoto authored on 2011-10-21
1452
    for my $table (@$tables) {
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1453
        if ($tree->{$table}) {
1454
            $need_tables->{$table} = 1;
1455
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1456
        }
1457
    }
1458
}
1459

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1460
sub _option {
1461
    my $self = shift;
1462
    my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1463
    warn "dbi_options is DEPRECATED! use option instead\n"
1464
      if keys %{$self->dbi_options};
1465
    warn "dbi_option is DEPRECATED! use option instead\n"
1466
      if keys %{$self->dbi_option};
1467
    return $option;
1468
}
1469

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1470
sub _push_join {
1471
    my ($self, $sql, $join, $join_tables) = @_;
1472
    
cleanup
Yuki Kimoto authored on 2011-10-21
1473
    $join = [$join] unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-10-21
1474
    
cleanup
Yuki Kimoto authored on 2011-04-02
1475
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1476
    return unless @$join;
1477
    
cleanup
Yuki Kimoto authored on 2011-04-02
1478
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1479
    my $tree = {};
1480
    for (my $i = 0; $i < @$join; $i++) {
1481
        
cleanup
Yuki Kimoto authored on 2011-07-28
1482
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1483
        my $join_clause;;
1484
        my $option;
1485
        if (ref $join->[$i] eq 'HASH') {
1486
            $join_clause = $join->[$i]->{clause};
1487
            $option = {table => $join->[$i]->{table}};
1488
        }
1489
        else {
1490
            $join_clause = $join->[$i];
1491
            $option = {};
1492
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1493

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1541
sub _quote {
1542
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-22
1543
    return $self->{reserved_word_quote} || $self->quote || '';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1544
}
1545

            
cleanup
Yuki Kimoto authored on 2011-04-02
1546
sub _remove_duplicate_table {
1547
    my ($self, $tables, $main_table) = @_;
1548
    
1549
    # Remove duplicate table
1550
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1551
    delete $tables{$main_table} if $main_table;
1552
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1553
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1554
    if (my $q = $self->_quote) {
1555
        $q = quotemeta($q);
1556
        $_ =~ s/[$q]//g for @$new_tables;
1557
    }
1558

            
1559
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1560
}
1561

            
cleanup
Yuki Kimoto authored on 2011-04-02
1562
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1563
    my ($self, $source) = @_;
1564
    
cleanup
Yuki Kimoto authored on 2011-04-02
1565
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1566
    my $tables = [];
cleanup
Yuki Kimoto authored on 2011-11-18
1567
    my $safety_character = $self->{safety_character};
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1568
    my $q = $self->_quote;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1569
    my $quoted_safety_character_re = $self->q("?([$safety_character]+)", 1);
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1570
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1571
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1572
    while ($source =~ /$table_re/g) {
1573
        push @$tables, $1;
1574
    }
1575
    
1576
    return $tables;
1577
}
1578

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-25
1588
    my $obj;
1589
    
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1590
    if (ref $where) {
cleanup
Yuki Kimoto authored on 2011-10-25
1591
        if (ref $where eq 'HASH') {
1592
            my $clause = ['and'];
cleanup
Yuki Kimoto authored on 2011-11-01
1593
            my $column_join = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1594
            for my $column (keys %$where) {
cleanup
Yuki Kimoto authored on 2011-11-01
1595
                $column_join .= $column;
cleanup
Yuki Kimoto authored on 2011-10-25
1596
                my $table;
1597
                my $c;
1598
                if ($column =~ /(?:(.*?)\.)?(.*)/) {
1599
                    $table = $1;
1600
                    $c = $2;
1601
                }
1602
                
1603
                my $table_quote;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1604
                $table_quote = $self->q($table) if defined $table;
1605
                my $column_quote = $self->q($c);
cleanup
Yuki Kimoto authored on 2011-10-25
1606
                $column_quote = $table_quote . '.' . $column_quote
1607
                  if defined $table_quote;
cleanup
Yuki Kimoto authored on 2011-11-01
1608
                push @$clause, "$column_quote = :$column";
cleanup
Yuki Kimoto authored on 2011-10-25
1609
            }
cleanup
Yuki Kimoto authored on 2011-11-01
1610

            
1611
            # Check unsafety column
cleanup
Yuki Kimoto authored on 2011-11-18
1612
            my $safety = $self->{safety_character};
cleanup
Yuki Kimoto authored on 2011-11-01
1613
            unless ($column_join =~ /^[$safety\.]+$/) {
1614
                for my $column (keys %$where) {
1615
                    croak qq{"$column" is not safety column name } . _subname
1616
                      unless $column =~ /^[$safety\.]+$/;
1617
                }
1618
            }
1619
            
cleanup
Yuki Kimoto authored on 2011-10-25
1620
            $obj = $self->where(clause => $clause, param => $where);
1621
        }
cleanup
Yuki Kimoto authored on 2011-11-01
1622
        elsif (ref $where eq 'DBIx::Custom::Where') { $obj = $where }
cleanup
Yuki Kimoto authored on 2011-10-25
1623
        elsif (ref $where eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-11-01
1624
            $obj = $self->where(clause => $where->[0], param => $where->[1]);
cleanup
Yuki Kimoto authored on 2011-10-25
1625
        }
1626
        
1627
        # Check where argument
1628
        croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1629
            . qq{or array reference, which contains where clause and parameter}
1630
            . _subname
1631
          unless ref $obj eq 'DBIx::Custom::Where';
1632

            
1633
        $w->{param} = keys %$where_param
1634
                    ? $self->merge_param($where_param, $obj->param)
1635
                    : $obj->param;
1636
        $w->{clause} = $obj->to_string;
cleanup
Yuki Kimoto authored on 2011-10-21
1637
    }
1638
    elsif ($where) {
1639
        $w->{clause} = "where $where";
cleanup
Yuki Kimoto authored on 2011-10-25
1640
        $w->{param} = $where_param;
cleanup
Yuki Kimoto authored on 2011-10-21
1641
    }
1642
    
1643
    return $w;
1644
}
1645

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1716
# DEPRECATED!
1717
has 'data_source';
1718
has dbi_options => sub { {} };
1719
has filter_check  => 1;
1720
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1721
has dbi_option => sub { {} };
1722
has default_dbi_option => sub {
1723
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1724
    return shift->default_option;
1725
};
1726

            
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
1727
# DEPRECATED
1728
sub tag_parse {
1729
   my $self = shift;
1730
   warn "tag_parse is DEPRECATED! use \$ENV{DBIX_CUSTOM_TAG_PARSE} " .
1731
         "environment variable";
1732
    if (@_) {
1733
        $self->{tag_parse} = $_[0];
1734
        return $self;
1735
    }
1736
    return $self->{tag_parse};
1737
}
1738

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

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

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

            
1762
    return $tag;
1763
}
1764

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-08
1817
# DEPRECATED!
1818
sub update_at {
1819
    my $self = shift;
1820

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-01-25
1908
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1909
sub default_fetch_filter {
1910
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1911

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

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1991
=head1 NAME
1992

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

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

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2066
Named place holder support
2067

            
2068
=item *
2069

            
cleanup
Yuki Kimoto authored on 2011-07-29
2070
Model support
2071

            
2072
=item *
2073

            
2074
Connection manager support
2075

            
2076
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2077

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

            
2082
=item *
2083

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

            
2086
=item *
2087

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

            
2090
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2091

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

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

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

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

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

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

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

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

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

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

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

            
2131
    my $dbi = DBIx::Custom->connect(
2132
      dsn => $dsn, user => $user, password => $password, connector => 1);
2133
    
2134
    my $connector = $dbi->connector; # DBIx::Connector
2135

            
2136
Note that L<DBIx::Connector> must be installed.
2137

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

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

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

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

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

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

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

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

            
2161
    my $exclude_table = $dbi->exclude_table;
2162
    $dbi = $dbi->exclude_table(qr/pg_/);
2163

            
2164
Excluded table regex.
2165
C<each_column>, C<each_table>, C<type_rule>,
2166
and C<setup_model> methods ignore matching tables.
2167

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

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

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

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

            
2177
    my $last_sql = $dbi->last_sql;
2178
    $dbi = $dbi->last_sql($last_sql);
2179

            
2180
Get last successed SQL executed by C<execute> method.
2181

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

            
2184
    my $now = $dbi->now;
2185
    $dbi = $dbi->now($now);
2186

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

            
2189
    sub {
2190
        my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2191
        $mon++;
2192
        $year += 1900;
2193
        return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2194
    }
2195

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2309
You can set the following data.
2310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2392
Get rows count.
2393

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

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

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

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

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

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

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

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

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

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

            
2422
Execute delete statement.
2423

            
2424
The following opitons are available.
2425

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

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

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

            
2433
=item C<id>
2434

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

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

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

            
2447
The above is same as the followin one.
2448

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

            
2451
=item C<prefix>
2452

            
2453
    prefix => 'some'
2454

            
2455
prefix before table name section.
2456

            
2457
    delete some from book
2458

            
2459
=item C<table>
2460

            
2461
    table => 'book'
2462

            
2463
Table name.
2464

            
2465
=item C<where>
2466

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

            
2469
=back
2470

            
2471
=head2 C<delete_all>
2472

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2573
=over 4
2574

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

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

            
2579
    after_build_sql => $code_ref
2580

            
2581
The following one is one example.
2582

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

            
2591
The following SQL is executed.
2592

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

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

            
2597
    append => 'order by name'
2598

            
2599
Append some statement after SQL.
2600

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

            
2603
Specify database bind data type.
2604

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

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

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

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

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

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

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

            
2637
    query => 1
2638

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

            
DBIx::Custom::Query is DEPRE...
Yuki Kimoto authored on 2011-11-15
2642
    my $sql = $query->{sql};
2643
    my $columns = $query->{columns};
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2644
    
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
2645
=item C<reuse>
2646
    
2647
    reuse => $hash_ref
2648

            
2649
Reuse query object if the hash reference variable is set.
2650
    
2651
    my $queries = {};
2652
    $dbi->execute($sql, $param, reuse => $queries);
2653

            
2654
This will improved performance when you want to execute same query repeatedly
2655
because generally creating query object is slow.
2656

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2659
    primary_key => 'id'
2660
    primary_key => ['id1', 'id2']
2661

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2664
=item C<table>
2665
    
2666
    table => 'author'
2667

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2675
    # Same
2676
    $dbi->execute(
2677
      "select * from book where title = :book.title and author = :book.author",
2678
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2679

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

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

            
2684
Table alias. Key is real table name, value is alias table name.
2685
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2686
on alias table name.
2687

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

            
2690
    type_rule_off => 1
2691

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

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

            
2696
    type_rule1_off => 1
2697

            
2698
Turn C<into1> type rule off.
2699

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

            
2702
    type_rule2_off => 1
2703

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

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

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

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

            
2712
get column infomation except for one which match C<exclude_table> pattern.
2713

            
2714
    [
2715
        {table => 'book', column => 'title', info => {...}},
2716
        {table => 'author', column => 'name' info => {...}}
2717
    ]
2718

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

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

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

            
2725
    [
2726
        {table => 'book', info => {...}},
2727
        {table => 'author', info => {...}}
2728
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2729

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

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

            
2734
    $dbi->helper(
2735
        find_or_create   => sub {
2736
            my $self = shift;
2737
            
2738
            # Process
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
2739
        },
2740
        ...
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2741
    );
2742

            
2743
Register helper. These helper is called directly from L<DBIx::Custom> object.
2744

            
2745
    $dbi->find_or_create;
2746

            
cleanup
yuki-kimoto authored on 2010-10-17
2747
=head2 C<insert>
2748

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

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

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

            
2757
    {date => \"NOW()"}
2758

            
cleanup
Yuki Kimoto authored on 2011-10-20
2759
B<options>
2760

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

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

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

            
2768
    created_at => 'created_datetime'
2769

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2776
    id => 4
2777
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2778

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2782
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2783
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
2784
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2785
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2786
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2787
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2788

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

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

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

            
2798
    prefix => 'or replace'
2799

            
2800
prefix before table name section
2801

            
2802
    insert or replace into book
2803

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

            
2806
    table => 'book'
2807

            
2808
Table name.
2809

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

            
2812
This option is same as C<update> method C<updated_at> option.
2813

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

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

            
2818
placeholder wrapped string.
2819

            
2820
If the following statement
2821

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

            
2825
is executed, the following SQL is executed.
2826

            
2827
    insert into book price values ( ? + 5 );
2828

            
update pod
Yuki Kimoto authored on 2011-03-13
2829
=back
2830

            
2831
=over 4
2832

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2840
    lib / MyModel.pm
2841
        / MyModel / book.pm
2842
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2843

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

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

            
2848
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2849
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2850
    
2851
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2852

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2857
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2858
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2859
    
2860
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2861

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2864
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2865
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2866
    
2867
    1;
2868
    
updated pod
Yuki Kimoto authored on 2011-06-21
2869
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2870

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

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

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

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

            
2880
    my $like_value = $dbi->like_value
2881

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

            
2884
    sub { "%$_[0]%" }
2885

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

            
2888
    my $mapper = $dbi->mapper(param => $param);
2889

            
2890
Create a new L<DBIx::Custom::Mapper> object.
2891

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

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

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

            
2898
    {key1 => [1, 1], key2 => 2}
2899

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

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

            
2904
    my $model = $dbi->model('book');
2905

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

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

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

            
2913
Create column clause for myself. The follwoing column clause is created.
2914

            
2915
    book.author as author,
2916
    book.title as title
2917

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

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

            
2927
Create a new L<DBIx::Custom> object.
2928

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

            
2931
    my $not_exists = $dbi->not_exists;
2932

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

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

            
2938
    my $order = $dbi->order;
2939

            
2940
Create a new L<DBIx::Custom::Order> object.
2941

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

            
2944
    my $quooted = $dbi->q("title");
2945

            
2946
Quote string by value of C<quote>.
2947

            
cleanup
yuki-kimoto authored on 2010-10-17
2948
=head2 C<register_filter>
2949

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

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2967
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2968
        column => ['author', 'title'],
- select method can receive ...
Yuki Kimoto authored on 2011-11-18
2969
        table  => 'book',
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2970
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2971
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2972
    
updated document
Yuki Kimoto authored on 2011-06-09
2973
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2974

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

            
2978
    my $result = $dbi->select(['author', 'title'], table => 'book');
2979

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2987
=item C<column>
2988
    
updated document
Yuki Kimoto authored on 2011-06-09
2989
    column => 'author'
2990
    column => ['author', 'title']
2991

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3000
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
3001
        {book => [qw/author title/]},
3002
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
3003
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
3004

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

            
3007
    book.author as "book.author",
3008
    book.title as "book.title",
3009
    person.name as "person.name",
3010
    person.age as "person.age"
3011

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

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

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

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

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

            
3025
    id => 4
3026
    id => [4, 5]
3027

            
3028
ID corresponding to C<primary_key>.
3029
You can select rows by C<id> and C<primary_key>.
3030

            
3031
    $dbi->select(
fixed pod
Yuki Kimoto authored on 2011-10-20
3032
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3033
        id => [4, 5],
3034
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3035
    );
3036

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3039
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3040
        where => {id1 => 4, id2 => 5},
3041
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3042
    );
3043
    
cleanup
Yuki Kimoto authored on 2011-10-20
3044
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3045

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

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

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

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

            
3058
    prefix => 'SQL_CALC_FOUND_ROWS'
3059

            
3060
Prefix of column cluase
3061

            
3062
    select SQL_CALC_FOUND_ROWS title, author from book;
3063

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

            
3066
    join => [
3067
        'left outer join company on book.company_id = company_id',
3068
        'left outer join location on company.location_id = location.id'
3069
    ]
3070
        
3071
Join clause. If column cluase or where clause contain table name like "company.name",
3072
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3073

            
3074
    $dbi->select(
3075
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3076
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3077
        where => {'company.name' => 'Orange'},
3078
        join => [
3079
            'left outer join company on book.company_id = company.id',
3080
            'left outer join location on company.location_id = location.id'
3081
        ]
3082
    );
3083

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3087
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3088
    from book
3089
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3090
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3091

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3092
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
3093
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3094

            
3095
    $dbi->select(
3096
        table => 'book',
3097
        column => ['company.location_id as location_id'],
3098
        where => {'company.name' => 'Orange'},
3099
        join => [
3100
            {
3101
                clause => 'left outer join location on company.location_id = location.id',
3102
                table => ['company', 'location']
3103
            }
3104
        ]
3105
    );
3106

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3111
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3112

            
updated document
Yuki Kimoto authored on 2011-06-09
3113
=item C<where>
3114
    
3115
    # Hash refrence
3116
    where => {author => 'Ken', 'title' => 'Perl'}
3117
    
3118
    # DBIx::Custom::Where object
3119
    where => $dbi->where(
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3120
        clause => ['and', ':author{=}', ':title{like}'],
updated document
Yuki Kimoto authored on 2011-06-09
3121
        param  => {author => 'Ken', title => '%Perl%'}
3122
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3123
    
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3124
    # Array reference, this is same as above
updated pod
Yuki Kimoto authored on 2011-06-21
3125
    where => [
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3126
        ['and', ':author{=}', ':title{like}'],
updated pod
Yuki Kimoto authored on 2011-06-21
3127
        {author => 'Ken', title => '%Perl%'}
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3128
    ];
updated pod
Yuki Kimoto authored on 2011-06-21
3129
    
3130
    # String
3131
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3132

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

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

            
3139
    $dbi->setup_model;
3140

            
3141
Setup all model objects.
3142
C<columns> of model object is automatically set, parsing database information.
3143

            
3144
=head2 C<type_rule>
3145

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

            
3169
Filtering rule when data is send into and get from database.
3170
This has a little complex problem.
3171

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

            
3176
Note that type name and data type don't contain upper case.
3177
If these contain upper case charactor, you convert it to lower case.
3178

            
3179
C<into2> is executed after C<into1>.
3180

            
3181
Type rule of C<into1> and C<into2> is enabled on the following
3182
column name.
3183

            
3184
=over 4
3185

            
3186
=item 1. column name
3187

            
3188
    issue_date
3189
    issue_datetime
3190

            
3191
This need C<table> option in each method.
3192

            
3193
=item 2. table name and column name, separator is dot
3194

            
3195
    book.issue_date
3196
    book.issue_datetime
3197

            
3198
=back
3199

            
3200
You get all type name used in database by C<available_typename>.
3201

            
3202
    print $dbi->available_typename;
3203

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

            
3208
    print $dbi->available_datatype;
3209

            
3210
You can also specify multiple types at once.
3211

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

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

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

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

            
3224
If you want to set constant value to row data, use scalar reference
3225
as parameter value.
3226

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3238
    id => 4
3239
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3240

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

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

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

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

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

            
3261
    prefix => 'or replace'
3262

            
3263
prefix before table name section
3264

            
3265
    update or replace book
3266

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

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

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

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

            
3275
Same as C<select> method's C<where> option.
3276

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

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

            
3281
placeholder wrapped string.
3282

            
3283
If the following statement
3284

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

            
3288
is executed, the following SQL is executed.
3289

            
3290
    update book set price =  ? + 5;
3291

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

            
3294
    updated_at => 'updated_datetime'
3295

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3300
=back
update pod
Yuki Kimoto authored on 2011-03-13
3301

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

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

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

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3309
=head2 C<update_or_insert>
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3310
    
3311
    # ID
3312
    $dbi->update_or_insert(
3313
        {title => 'Perl'},
3314
        table => 'book',
3315
        id => 1,
3316
        primary_key => 'id',
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3317
        option => {
3318
            select => {
3319
                 append => 'for update'
3320
            }
3321
        }
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3322
    );
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3323

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3324
Update or insert.
3325

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

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3330
C<OPTIONS>
3331

            
3332
C<update_or_insert> method use all common option
3333
in C<select>, C<update>, C<delete>, and has the following new ones.
3334

            
3335
=over 4
3336

            
3337
=item C<option>
3338

            
3339
    option => {
3340
        select => {
3341
            append => '...'
3342
        },
3343
        insert => {
3344
            prefix => '...'
3345
        },
3346
        update => {
3347
            filter => {}
3348
        }
3349
    }
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3350

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

            
3354
=over 4
3355

            
3356
=item C<select_option>
3357

            
3358
    select_option => {append => 'for update'}
3359

            
3360
select method option,
3361
select method is used to check the row is already exists.
3362

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

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

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

            
3369
    book
3370
    title: 5
3371
    issue_date: 91
3372

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

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

            
3377
    $dbi->show_tables;
3378

            
3379
Show tables.
3380

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

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

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

            
3387
    book
3388
    title: varchar
3389
    issue_date: date
3390

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

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

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

            
3397
Create values clause.
3398

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

            
3401
You can use this in insert statement.
3402

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

            
3405
=head2 C<where>
3406

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

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

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

            
3416
=head2 C<DBIX_CUSTOM_DEBUG>
3417

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

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

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

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

            
3427
If you set DBIX_CUSTOM_TAG_PARSE to 0, tag parsing is off.
3428

            
3429
=head2 C<DBIX_CUSTOM_DISABLE_MODEL_EXECUTE>
3430

            
3431
If you set DBIX_CUSTOM_DISABLE_MODEL_EXECUTE to 1,
3432
L<DBIx::Custom::Model> execute method call L<DBIx::Custom> execute.
3433

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

            
3436
L<DBIx::Custom>
3437

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

            
3492
L<DBIx::Custom::Model>
3493

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

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

            
3503
This module is DEPRECATED! # 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
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3506
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3507
    table # will be removed at 2017/1/1
3508
    filters # will be removed at 2017/1/1
3509
    
3510
    # Methods
3511
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3512

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

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

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

            
3542
L<DBIx::Custom::Tag>
3543

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

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

            
3548
    # Other
3549
    prepend method array reference receiving
3550
      $order->prepend(['book', 'desc']); # will be removed 2017/1/1
3551

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

            
3554
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3555
except for attribute method.
3556
You can check all DEPRECATED functionalities by document.
3557
DEPRECATED functionality is removed after five years,
3558
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
3559
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3560

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

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

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

            
3567
C<< <kimoto.yuki at gmail.com> >>
3568

            
3569
L<http://github.com/yuki-kimoto/DBIx-Custom>
3570

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3571
=head1 AUTHOR
3572

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

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

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

            
3579
This program is free software; you can redistribute it and/or modify it
3580
under the same terms as Perl itself.
3581

            
3582
=cut