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

            
cleanup test
Yuki Kimoto authored on 2011-08-06
4
our $VERSION = '0.1711';
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/;
improved debug message
Yuki Kimoto authored on 2011-05-23
17
use Encode qw/encode encode_utf8 decode_utf8/;
packaging one directory
yuki-kimoto authored on 2009-11-16
18

            
added environment variable D...
Yuki Kimoto authored on 2011-04-02
19
use constant DEBUG => $ENV{DBIX_CUSTOM_DEBUG} || 0;
improved debug message
Yuki Kimoto authored on 2011-05-23
20
use constant DEBUG_ENCODING => $ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8';
added environment variable D...
Yuki Kimoto authored on 2011-04-02
21

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
22
has [qw/connector dsn password quote user/],
removed from cache() and cac...
Yuki Kimoto authored on 2011-03-29
23
    cache => 0,
many changed
Yuki Kimoto authored on 2011-01-23
24
    cache_method => sub {
25
        sub {
26
            my $self = shift;
27
            
28
            $self->{_cached} ||= {};
29
            
30
            if (@_ > 1) {
update pod
Yuki Kimoto authored on 2011-03-13
31
                $self->{_cached}{$_[0]} = $_[1];
many changed
Yuki Kimoto authored on 2011-01-23
32
            }
33
            else {
update pod
Yuki Kimoto authored on 2011-03-13
34
                return $self->{_cached}{$_[0]};
many changed
Yuki Kimoto authored on 2011-01-23
35
            }
36
        }
update pod
Yuki Kimoto authored on 2011-03-13
37
    },
38
    dbi_option => sub { {} },
39
    default_dbi_option => sub {
40
        {
41
            RaiseError => 1,
42
            PrintError => 0,
43
            AutoCommit => 1
44
        }
45
    },
fix tests
Yuki Kimoto authored on 2011-01-13
46
    filters => sub {
47
        {
48
            encode_utf8 => sub { encode_utf8($_[0]) },
49
            decode_utf8 => sub { decode_utf8($_[0]) }
50
        }
update pod
Yuki Kimoto authored on 2011-03-13
51
    },
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
52
    last_sql => '',
update pod
Yuki Kimoto authored on 2011-03-13
53
    models => sub { {} },
54
    result_class  => 'DBIx::Custom::Result',
55
    safety_character => '\w',
cleanup test
Yuki Kimoto authored on 2011-08-10
56
    separator => '.',
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
57
    stash => sub { {} },
58
    tag_parse => 1;
cleanup
yuki-kimoto authored on 2010-10-17
59

            
test cleanup
Yuki Kimoto authored on 2011-08-10
60
sub query_builder {
61
    my $self = shift;
62
    my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
63
    
64
    # DEPRECATED
65
    $builder->register_tag(
66
        '?'     => \&DBIx::Custom::Tag::placeholder,
67
        '='     => \&DBIx::Custom::Tag::equal,
68
        '<>'    => \&DBIx::Custom::Tag::not_equal,
69
        '>'     => \&DBIx::Custom::Tag::greater_than,
70
        '<'     => \&DBIx::Custom::Tag::lower_than,
71
        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
72
        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
73
        'like'  => \&DBIx::Custom::Tag::like,
74
        'in'    => \&DBIx::Custom::Tag::in,
75
        'insert_param' => \&DBIx::Custom::Tag::insert_param,
76
        'update_param' => \&DBIx::Custom::Tag::update_param
77
    );
78
    $builder->register_tag($self->{_tags} || {});
79
    return $builder;
80
}
81

            
added helper method
yuki-kimoto authored on 2010-10-17
82
our $AUTOLOAD;
83
sub AUTOLOAD {
84
    my $self = shift;
85

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
89
    # Call method
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
90
    $self->{_methods} ||= {};
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
91
    if (my $method = $self->{_methods}->{$mname}) {
92
        return $self->$method(@_)
93
    }
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
94
    elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
95
        $self->dbh->$dbh_method(@_);
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
96
    }
97
    else {
cleanup
Yuki Kimoto authored on 2011-04-25
98
        croak qq{Can't locate object method "$mname" via "$package" }
99
            . _subname;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
100
    }
added helper method
yuki-kimoto authored on 2010-10-17
101
}
102

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
103
sub assign_param {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
104
    my ($self, $param) = @_;
105
    
106
    # Create set tag
107
    my @params;
108
    my $safety = $self->safety_character;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
109
    foreach my $column (sort keys %$param) {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
110
        croak qq{"$column" is not safety column name } . _subname
111
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
112
        my $column_quote = $self->_q($column);
113
        $column_quote =~ s/\./$self->_q(".")/e;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
114
        push @params, ref $param->{$column} eq 'SCALAR'
115
          ? "$column_quote = " . ${$param->{$column}}
116
          : "$column_quote = :$column";
117

            
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
118
    }
119
    my $tag = join(', ', @params);
120
    
121
    return $tag;
122
}
123

            
cleanup
Yuki Kimoto authored on 2011-03-21
124
sub column {
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
125
    my $self = shift;
126
    my $option = pop if ref $_[-1] eq 'HASH';
127
    my $real_table = shift;
128
    my $columns = shift;
129
    my $table = $option->{alias} || $real_table;
130
    
131
    # Columns
132
    unless ($columns) {
133
        $columns ||= $self->model($real_table)->columns;
134
    }
added helper method
yuki-kimoto authored on 2010-10-17
135
    
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
136
    # Separator
137
    my $separator = $self->separator;
138
    
cleanup
Yuki Kimoto authored on 2011-04-02
139
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-21
140
    my @column;
cleanup
Yuki Kimoto authored on 2011-04-02
141
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
142
    push @column, $self->_q($table) . "." . $self->_q($_) .
143
      " as " . $self->_q("${table}${separator}$_")
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
144
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
145
    
146
    return join (', ', @column);
added helper method
yuki-kimoto authored on 2010-10-17
147
}
148

            
packaging one directory
yuki-kimoto authored on 2009-11-16
149
sub connect {
cleanup
Yuki Kimoto authored on 2011-01-25
150
    my $self = ref $_[0] ? shift : shift->new(@_);;
removed register_format()
yuki-kimoto authored on 2010-05-26
151
    
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
152
    # Connect
153
    $self->dbh;
update document
yuki-kimoto authored on 2010-01-30
154
    
packaging one directory
yuki-kimoto authored on 2009-11-16
155
    return $self;
156
}
157

            
update pod
Yuki Kimoto authored on 2011-03-13
158
sub dbh {
159
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-04-02
160
    
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
161
    # Set
162
    if (@_) {
163
        $self->{dbh} = $_[0];
164
        
165
        return $self;
166
    }
167
    
168
    # Get
169
    else {
170
        # From Connction manager
171
        if (my $connector = $self->connector) {
cleanup
Yuki Kimoto authored on 2011-04-25
172
            croak "connector must have dbh() method " . _subname
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
173
              unless ref $connector && $connector->can('dbh');
174
              
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
175
            $self->{dbh} = $connector->dbh;
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
176
        }
177
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
178
        # Connect
179
        $self->{dbh} ||= $self->_connect;
180
        
181
        # Quote
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
182
        if (!defined $self->reserved_word_quote && !defined $self->quote) {
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
183
            my $driver = $self->{dbh}->{Driver}->{Name};
184
            my $quote = $driver eq 'mysql' ? '`' : '"';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
185
            $self->quote($quote);
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
186
        }
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
187
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
188
        return $self->{dbh};
update pod
Yuki Kimoto authored on 2011-03-13
189
    }
190
}
191

            
cleanup
yuki-kimoto authored on 2010-10-17
192
sub delete {
select, insert, update, upda...
yuki-kimoto authored on 2010-06-14
193
    my ($self, %args) = @_;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
194

            
cleanup update and update_al...
yuki-kimoto authored on 2010-04-28
195
    # Arguments
cleanup
Yuki Kimoto authored on 2011-03-21
196
    my $table = $args{table} || '';
cleanup
Yuki Kimoto authored on 2011-04-25
197
    croak qq{"table" option must be specified. } . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
198
      unless $table;
cleanup
Yuki Kimoto authored on 2011-03-21
199
    my $where            = delete $args{where} || {};
200
    my $append           = delete $args{append};
201
    my $allow_delete_all = delete $args{allow_delete_all};
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
202
    my $where_param      = delete $args{where_param} || {};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
203
    my $id = delete $args{id};
204
    my $primary_key = delete $args{primary_key};
205
    croak "update method primary_key option " .
206
          "must be specified when id is specified " . _subname
207
      if defined $id && !defined $primary_key;
208
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
209
    my $prefix = delete $args{prefix};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
210
    
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
211
    # Where
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
212
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
213
    my $where_clause = '';
updated pod
Yuki Kimoto authored on 2011-06-21
214
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
215
        $where_clause = "where " . $where->[0];
216
        $where_param = $where->[1];
217
    }
218
    elsif (ref $where) {
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
219
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
220
        $where_param = keys %$where_param
221
                     ? $self->merge_param($where_param, $where->param)
222
                     : $where->param;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
223
        
224
        # String where
225
        $where_clause = $where->to_string;
226
    }
227
    elsif ($where) { $where_clause = "where $where" }
cleanup
Yuki Kimoto authored on 2011-04-25
228
    croak qq{"where" must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
229
      if $where_clause eq '' && !$allow_delete_all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
230

            
cleanup
Yuki Kimoto authored on 2011-04-02
231
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-01-27
232
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
233
    push @sql, "delete";
234
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
235
    push @sql, "from " . $self->_q($table) . " $where_clause";
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
236
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
237
    my $sql = join(' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
238
    
239
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
240
    return $self->execute($sql, $where_param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
241
}
242

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

            
test cleanup
Yuki Kimoto authored on 2011-08-10
245
sub DESTROY {
246

            
247
}
added helper method
yuki-kimoto authored on 2010-10-17
248

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

            
282
sub each_column {
283
    my ($self, $cb) = @_;
284
    
285
    # Iterate all tables
286
    my $sth_tables = $self->dbh->table_info;
287
    while (my $table_info = $sth_tables->fetchrow_hashref) {
288
        
289
        # Table
290
        my $table = $table_info->{TABLE_NAME};
291
        
292
        # Iterate all columns
293
        my $sth_columns = $self->dbh->column_info(undef, undef, $table, '%');
294
        while (my $column_info = $sth_columns->fetchrow_hashref) {
295
            my $column = $column_info->{COLUMN_NAME};
296
            $self->$cb($table, $column, $column_info);
297
        }
298
    }
299
}
300

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
301
sub each_table {
302
    my ($self, $cb) = @_;
303
    
304
    # Iterate all tables
305
    my $sth_tables = $self->dbh->table_info;
306
    while (my $table_info = $sth_tables->fetchrow_hashref) {
307
        
308
        # Table
309
        my $table = $table_info->{TABLE_NAME};
310
        $self->$cb($table, $table_info);
311
    }
312
}
313

            
simplified arguments check
Yuki Kimoto authored on 2011-07-11
314
our %VALID_ARGS = map { $_ => 1 } qw/append allow_delete_all
315
  allow_update_all bind_type column filter id join param prefix primary_key
316
  query relation table table_alias type type_rule_off type_rule1_off
317
  type_rule2_off wrap/;
cleanup
Yuki Kimoto authored on 2011-04-02
318

            
319
sub execute {
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
320
    my $self = shift;
321
    my $query = shift;
322
    my $param;
323
    $param = shift if @_ % 2;
324
    my %args = @_;
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
325
    
cleanup
Yuki Kimoto authored on 2011-04-02
326
    # Arguments
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
327
    my $p = delete $args{param} || {};
328
    $param ||= $p;
cleanup
Yuki Kimoto authored on 2011-04-02
329
    my $tables = delete $args{table} || [];
330
    $tables = [$tables] unless ref $tables eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-04-02
331
    my $filter = delete $args{filter};
cleanup
Yuki Kimoto authored on 2011-04-25
332
    $filter = _array_to_hash($filter);
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
333
    my $bind_type = delete $args{bind_type} || delete $args{type};
334
    $bind_type = _array_to_hash($bind_type);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
335
    my $type_rule_off = delete $args{type_rule_off};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
336
    my $type_rule_off_parts = {
337
        1 => delete $args{type_rule1_off},
338
        2 => delete $args{type_rule2_off}
339
    };
cleanup
Yuki Kimoto authored on 2011-06-09
340
    my $query_return = delete $args{query};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
341
    my $table_alias = delete $args{table_alias} || {};
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
342
    
cleanup
Yuki Kimoto authored on 2011-03-09
343
    # Check argument names
select, insert, update, upda...
yuki-kimoto authored on 2010-06-14
344
    foreach my $name (keys %args) {
cleanup
Yuki Kimoto authored on 2011-04-25
345
        croak qq{"$name" is wrong option } . _subname
simplified arguments check
Yuki Kimoto authored on 2011-07-11
346
          unless $VALID_ARGS{$name};
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
347
    }
348
    
cleanup
Yuki Kimoto authored on 2011-04-02
349
    # Create query
updated pod
Yuki Kimoto authored on 2011-06-21
350
    $query = $self->_create_query($query) unless ref $query;
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
351
    
352
    # Save query
353
    $self->last_sql($query->sql);
354

            
cleanup
Yuki Kimoto authored on 2011-06-09
355
    return $query if $query_return;
micro optimization
Yuki Kimoto authored on 2011-07-30
356
    
357
    # DEPRECATED! Merge query filter
DBIx::Custom::Query filter m...
Yuki Kimoto authored on 2011-07-30
358
    $filter ||= $query->{filter} || {};
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
359
    
cleanup
Yuki Kimoto authored on 2011-04-02
360
    # Tables
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
361
    unshift @$tables, @{$query->{tables} || []};
micro optimization
Yuki Kimoto authored on 2011-07-30
362
    my $main_table = @{$tables}[-1];
micro optimization
Yuki Kimoto authored on 2011-07-30
363
    
micro optimization
Yuki Kimoto authored on 2011-07-30
364
    # DEPRECATED! Cleanup tables
micro optimization
Yuki Kimoto authored on 2011-07-30
365
    $tables = $self->_remove_duplicate_table($tables, $main_table)
366
      if @$tables > 1;
cleanup
Yuki Kimoto authored on 2011-04-02
367
    
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
368
    # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
369
    my $type_filters = {};
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
370
    unless ($type_rule_off) {
micro optimization
Yuki Kimoto authored on 2011-07-30
371
        foreach my $i (1, 2) {
372
            unless ($type_rule_off_parts->{$i}) {
373
                $type_filters->{$i} = {};
374
                foreach my $alias (keys %$table_alias) {
375
                    my $table = $table_alias->{$alias};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
376
                    
micro optimization
Yuki Kimoto authored on 2011-07-30
377
                    foreach my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
378
                        $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
379
                    }
380
                }
micro optimization
Yuki Kimoto authored on 2011-07-30
381
                $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
382
                  if $main_table;
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
383
            }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
384
        }
385
    }
cleanup
Yuki Kimoto authored on 2011-04-02
386
    
micro optimization
Yuki Kimoto authored on 2011-07-30
387
    # DEPRECATED! Applied filter
micro optimization
Yuki Kimoto authored on 2011-07-30
388
    if ($self->{filter}{on}) {
389
        my $applied_filter = {};
390
        foreach my $table (@$tables) {
391
            $applied_filter = {
392
                %$applied_filter,
393
                %{$self->{filter}{out}->{$table} || {}}
394
            }
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
395
        }
micro optimization
Yuki Kimoto authored on 2011-07-30
396
        $filter = {%$applied_filter, %$filter};
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
397
    }
398
    
cleanup
Yuki Kimoto authored on 2011-04-02
399
    # Replace filter name to code
400
    foreach my $column (keys %$filter) {
401
        my $name = $filter->{$column};
402
        if (!defined $name) {
403
            $filter->{$column} = undef;
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
404
        }
cleanup
Yuki Kimoto authored on 2011-04-02
405
        elsif (ref $name ne 'CODE') {
cleanup
Yuki Kimoto authored on 2011-04-25
406
          croak qq{Filter "$name" is not registered" } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
407
            unless exists $self->filters->{$name};
408
          $filter->{$column} = $self->filters->{$name};
cleanup
Yuki Kimoto authored on 2010-12-21
409
        }
410
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
411
    
cleanup
Yuki Kimoto authored on 2011-04-02
412
    # Create bind values
413
    my $bind = $self->_create_bind_values(
414
        $param,
415
        $query->columns,
416
        $filter,
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
417
        $type_filters,
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
418
        $bind_type
cleanup
Yuki Kimoto authored on 2011-04-02
419
    );
cleanup
yuki-kimoto authored on 2010-10-17
420
    
421
    # Execute
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
422
    my $sth = $query->sth;
cleanup
yuki-kimoto authored on 2010-10-17
423
    my $affected;
cleanup
Yuki Kimoto authored on 2011-03-21
424
    eval {
425
        for (my $i = 0; $i < @$bind; $i++) {
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
426
            my $bind_type = $bind->[$i]->{bind_type};
427
            $sth->bind_param(
428
                $i + 1,
429
                $bind->[$i]->{value},
430
                $bind_type ? $bind_type : ()
431
            );
cleanup
Yuki Kimoto authored on 2011-03-21
432
        }
433
        $affected = $sth->execute;
434
    };
improved error messages
Yuki Kimoto authored on 2011-04-18
435
    
micro optimization
Yuki Kimoto authored on 2011-07-30
436
    $self->_croak($@, qq{. Following SQL is executed.\n}
437
      . qq{$query->{sql}\n} . _subname) if $@;
cleanup
yuki-kimoto authored on 2010-10-17
438
    
improved debug message
Yuki Kimoto authored on 2011-05-23
439
    # DEBUG message
440
    if (DEBUG) {
441
        print STDERR "SQL:\n" . $query->sql . "\n";
442
        my @output;
443
        foreach my $b (@$bind) {
444
            my $value = $b->{value};
445
            $value = 'undef' unless defined $value;
446
            $value = encode(DEBUG_ENCODING(), $value)
447
              if utf8::is_utf8($value);
448
            push @output, $value;
449
        }
450
        print STDERR "Bind values: " . join(', ', @output) . "\n\n";
451
    }
added environment variable D...
Yuki Kimoto authored on 2011-04-02
452
    
cleanup
Yuki Kimoto authored on 2011-04-02
453
    # Select statement
cleanup
yuki-kimoto authored on 2010-10-17
454
    if ($sth->{NUM_OF_FIELDS}) {
455
        
micro optimization
Yuki Kimoto authored on 2011-07-30
456
        # DEPRECATED! Filter
cleanup
Yuki Kimoto authored on 2011-04-02
457
        my $filter = {};
micro optimization
Yuki Kimoto authored on 2011-07-30
458
        if ($self->{filter}{on}) {
459
            $filter->{in}  = {};
460
            $filter->{end} = {};
461
            push @$tables, $main_table if $main_table;
462
            foreach my $table (@$tables) {
463
                foreach my $way (qw/in end/) {
464
                    $filter->{$way} = {
465
                        %{$filter->{$way}},
466
                        %{$self->{filter}{$way}{$table} || {}}
467
                    };
468
                }
cleanup
Yuki Kimoto authored on 2011-04-02
469
            }
cleanup
Yuki Kimoto authored on 2011-01-12
470
        }
471
        
472
        # Result
473
        my $result = $self->result_class->new(
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
474
            sth => $sth,
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
475
            dbi => $self,
cleanup
Yuki Kimoto authored on 2011-01-12
476
            default_filter => $self->{default_in_filter},
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
477
            filter => $filter->{in} || {},
478
            end_filter => $filter->{end} || {},
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
479
            type_rule => {
480
                from1 => $self->type_rule->{from1},
481
                from2 => $self->type_rule->{from2}
482
            },
cleanup
yuki-kimoto authored on 2010-10-17
483
        );
484

            
485
        return $result;
486
    }
cleanup
Yuki Kimoto authored on 2011-04-02
487
    
488
    # Not select statement
489
    else { return $affected }
cleanup
yuki-kimoto authored on 2010-10-17
490
}
491

            
492
sub insert {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
493
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
494
    
cleanup
yuki-kimoto authored on 2010-10-17
495
    # Arguments
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
496
    my $param;
497
    $param = shift if @_ % 2;
498
    my %args = @_;
cleanup
Yuki Kimoto authored on 2011-03-21
499
    my $table  = delete $args{table};
cleanup
Yuki Kimoto authored on 2011-04-25
500
    croak qq{"table" option must be specified } . _subname
simplified arguments check
Yuki Kimoto authored on 2011-07-11
501
      unless defined $table;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
502
    my $p = delete $args{param} || {};
503
    $param  ||= $p;
cleanup
Yuki Kimoto authored on 2011-03-21
504
    my $append = delete $args{append} || '';
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
505
    my $id = delete $args{id};
506
    my $primary_key = delete $args{primary_key};
cleanup
Yuki Kimoto authored on 2011-06-08
507
    croak "insert method primary_key option " .
added tests
Yuki Kimoto authored on 2011-06-08
508
          "must be specified when id is specified " . _subname
509
      if defined $id && !defined $primary_key;
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
510
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
511
    my $prefix = delete $args{prefix};
cleanup
Yuki Kimoto authored on 2011-04-02
512

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
513
    # Merge parameter
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
514
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
515
        my $id_param = $self->_create_param_from_id($id, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
516
        $param = $self->merge_param($id_param, $param);
517
    }
518

            
cleanup
Yuki Kimoto authored on 2011-04-02
519
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-01-27
520
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
521
    push @sql, "insert";
522
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
523
    push @sql, "into " . $self->_q($table) . " " . $self->insert_param($param);
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
524
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
525
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
526
    
527
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
528
    return $self->execute($sql, $param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
529
}
530

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
531
sub insert_param {
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
532
    my ($self, $param) = @_;
533
    
cleanup
Yuki Kimoto authored on 2011-04-02
534
    # Create insert parameter tag
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
535
    my $safety = $self->safety_character;
cleanup
Yuki Kimoto authored on 2011-04-02
536
    my @columns;
537
    my @placeholders;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
538
    foreach my $column (sort keys %$param) {
cleanup
Yuki Kimoto authored on 2011-04-25
539
        croak qq{"$column" is not safety column name } . _subname
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
540
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
541
        my $column_quote = $self->_q($column);
542
        $column_quote =~ s/\./$self->_q(".")/e;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
543
        push @columns, $column_quote;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
544
        push @placeholders, ref $param->{$column} eq 'SCALAR'
545
          ? ${$param->{$column}} : ":$column";
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
546
    }
547
    
cleanup
Yuki Kimoto authored on 2011-04-02
548
    return '(' . join(', ', @columns) . ') ' . 'values ' .
549
           '(' . join(', ', @placeholders) . ')'
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
550
}
551

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
552
sub include_model {
553
    my ($self, $name_space, $model_infos) = @_;
554
    
cleanup
Yuki Kimoto authored on 2011-04-02
555
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
556
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
557
    
558
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
559
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
560

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
561
        # Load name space module
cleanup
Yuki Kimoto authored on 2011-04-25
562
        croak qq{"$name_space" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
563
          if $name_space =~ /[^\w:]/;
564
        eval "use $name_space";
cleanup
Yuki Kimoto authored on 2011-04-25
565
        croak qq{Name space module "$name_space.pm" is needed. $@ }
566
            . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
567
          if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
568
        
569
        # Search model modules
570
        my $path = $INC{"$name_space.pm"};
571
        $path =~ s/\.pm$//;
572
        opendir my $dh, $path
cleanup
Yuki Kimoto authored on 2011-04-25
573
          or croak qq{Can't open directory "$path": $! } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
574
        $model_infos = [];
575
        while (my $module = readdir $dh) {
576
            push @$model_infos, $module
577
              if $module =~ s/\.pm$//;
578
        }
579
        close $dh;
580
    }
581
    
cleanup
Yuki Kimoto authored on 2011-04-02
582
    # Include models
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
583
    foreach my $model_info (@$model_infos) {
584
        
cleanup
Yuki Kimoto authored on 2011-04-02
585
        # Load model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
586
        my $model_class;
587
        my $model_name;
588
        my $model_table;
589
        if (ref $model_info eq 'HASH') {
590
            $model_class = $model_info->{class};
591
            $model_name  = $model_info->{name};
592
            $model_table = $model_info->{table};
593
            
594
            $model_name  ||= $model_class;
595
            $model_table ||= $model_name;
596
        }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
597
        else { $model_class = $model_name = $model_table = $model_info }
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
598
        my $mclass = "${name_space}::$model_class";
cleanup
Yuki Kimoto authored on 2011-04-25
599
        croak qq{"$mclass" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
600
          if $mclass =~ /[^\w:]/;
601
        unless ($mclass->can('isa')) {
602
            eval "use $mclass";
cleanup
Yuki Kimoto authored on 2011-04-25
603
            croak "$@ " . _subname if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
604
        }
605
        
cleanup
Yuki Kimoto authored on 2011-04-02
606
        # Create model
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
607
        my $args = {};
608
        $args->{model_class} = $mclass if $mclass;
609
        $args->{name}        = $model_name if $model_name;
610
        $args->{table}       = $model_table if $model_table;
611
        $self->create_model($args);
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
612
    }
613
    
614
    return $self;
615
}
616

            
added EXPERIMENTAL map_param...
Yuki Kimoto authored on 2011-06-24
617
sub map_param {
618
    my $self = shift;
619
    my $param = shift;
620
    my %map = @_;
621
    
622
    # Mapping
623
    my $map_param = {};
624
    foreach my $key (keys %map) {
625
        my $value_cb;
626
        my $condition;
627
        my $map_key;
628
        
629
        # Get mapping information
630
        if (ref $map{$key} eq 'ARRAY') {
631
            foreach my $some (@{$map{$key}}) {
632
                $map_key = $some unless ref $some;
633
                $condition = $some->{if} if ref $some eq 'HASH';
634
                $value_cb = $some if ref $some eq 'CODE';
635
            }
636
        }
637
        else {
638
            $map_key = $map{$key};
639
        }
640
        $value_cb ||= sub { $_[0] };
641
        $condition ||= sub { defined $_[0] && length $_[0] };
642

            
643
        # Map parameter
644
        my $value;
645
        if (ref $condition eq 'CODE') {
646
            $map_param->{$map_key} = $value_cb->($param->{$key})
647
              if $condition->($param->{$key});
648
        }
649
        elsif ($condition eq 'exists') {
650
            $map_param->{$map_key} = $value_cb->($param->{$key})
651
              if exists $param->{$key};
652
        }
653
        else { croak qq/Condition must be code reference or "exists" / . _subname }
654
    }
655
    
656
    return $map_param;
657
}
658

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
659
sub merge_param {
660
    my ($self, @params) = @_;
661
    
cleanup
Yuki Kimoto authored on 2011-04-02
662
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
663
    my $merge = {};
664
    foreach my $param (@params) {
665
        foreach my $column (keys %$param) {
666
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
667
            
668
            if (exists $merge->{$column}) {
669
                $merge->{$column} = [$merge->{$column}]
670
                  unless ref $merge->{$column} eq 'ARRAY';
671
                push @{$merge->{$column}},
672
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
673
            }
674
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
675
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
676
            }
677
        }
678
    }
679
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
680
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
681
}
682

            
cleanup
Yuki Kimoto authored on 2011-03-21
683
sub method {
684
    my $self = shift;
685
    
cleanup
Yuki Kimoto authored on 2011-04-02
686
    # Register method
cleanup
Yuki Kimoto authored on 2011-03-21
687
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
688
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
689
    
690
    return $self;
691
}
692

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
693
sub model {
694
    my ($self, $name, $model) = @_;
695
    
cleanup
Yuki Kimoto authored on 2011-04-02
696
    # Set model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
697
    if ($model) {
698
        $self->models->{$name} = $model;
699
        return $self;
700
    }
701
    
702
    # Check model existance
cleanup
Yuki Kimoto authored on 2011-04-25
703
    croak qq{Model "$name" is not included } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
704
      unless $self->models->{$name};
705
    
cleanup
Yuki Kimoto authored on 2011-04-02
706
    # Get model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
707
    return $self->models->{$name};
708
}
709

            
cleanup
Yuki Kimoto authored on 2011-03-21
710
sub mycolumn {
711
    my ($self, $table, $columns) = @_;
712
    
cleanup
Yuki Kimoto authored on 2011-04-02
713
    # Create column clause
714
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
715
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
716
    push @column, $self->_q($table) . "." . $self->_q($_) .
717
      " as " . $self->_q($_)
718
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
719
    
720
    return join (', ', @column);
721
}
722

            
added dbi_options attribute
kimoto authored on 2010-12-20
723
sub new {
724
    my $self = shift->SUPER::new(@_);
725
    
cleanup
Yuki Kimoto authored on 2011-04-02
726
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
727
    my @attrs = keys %$self;
728
    foreach my $attr (@attrs) {
cleanup
Yuki Kimoto authored on 2011-04-25
729
        croak qq{"$attr" is wrong name } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
730
          unless $self->can($attr);
731
    }
cleanup
Yuki Kimoto authored on 2011-04-02
732
    
added dbi_options attribute
kimoto authored on 2010-12-20
733
    return $self;
734
}
735

            
fixed if is not converted to...
Yuki Kimoto authored on 2011-08-09
736
my $not_exists = bless {}, 'DBIx::Custom::NotExists';
737
sub not_exists { $not_exists }
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
738

            
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
739
sub order {
740
    my $self = shift;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
741
    return DBIx::Custom::Order->new(dbi => $self, @_);
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
742
}
743

            
cleanup
yuki-kimoto authored on 2010-10-17
744
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
745
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
746
    
747
    # Register filter
748
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
749
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
750
    
cleanup
Yuki Kimoto authored on 2011-04-02
751
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
752
}
packaging one directory
yuki-kimoto authored on 2009-11-16
753

            
754
sub select {
select, insert, update, upda...
yuki-kimoto authored on 2010-06-14
755
    my ($self, %args) = @_;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
756

            
refactoring select
yuki-kimoto authored on 2010-04-28
757
    # Arguments
cleanup
Yuki Kimoto authored on 2011-03-21
758
    my $table = delete $args{table};
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
759
    my $tables = ref $table eq 'ARRAY' ? $table
760
               : defined $table ? [$table]
761
               : [];
cleanup
Yuki Kimoto authored on 2011-03-21
762
    my $columns   = delete $args{column};
763
    my $where     = delete $args{where} || {};
764
    my $append    = delete $args{append};
765
    my $join      = delete $args{join} || [];
cleanup
Yuki Kimoto authored on 2011-04-25
766
    croak qq{"join" must be array reference } . _subname
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
767
      unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-03-21
768
    my $relation = delete $args{relation};
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
769
    warn "select() relation option is DEPRECATED!"
added warnings
Yuki Kimoto authored on 2011-06-07
770
      if $relation;
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
771
    my $param = delete $args{param} || {}; # DEPRECATED!
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
772
    warn "select() param option is DEPRECATED!"
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
773
      if keys %$param;
774
    my $where_param = delete $args{where_param} || $param || {};
added EXPERIMENTAL select() ...
Yuki Kimoto authored on 2011-04-19
775
    my $wrap = delete $args{wrap};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
776
    my $id = delete $args{id};
777
    my $primary_key = delete $args{primary_key};
778
    croak "update method primary_key option " .
779
          "must be specified when id is specified " . _subname
780
      if defined $id && !defined $primary_key;
781
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
782
    my $prefix = delete $args{prefix};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
783
    
cleanup
Yuki Kimoto authored on 2011-03-09
784
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-03-21
785
    $self->_add_relation_table($tables, $relation);
packaging one directory
yuki-kimoto authored on 2009-11-16
786
    
cleanup
Yuki Kimoto authored on 2011-04-02
787
    # Select statement
cleanup
Yuki Kimoto authored on 2011-01-27
788
    my @sql;
789
    push @sql, 'select';
packaging one directory
yuki-kimoto authored on 2009-11-16
790
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
791
    # Prefix
792
    push @sql, $prefix if defined $prefix;
793
    
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
794
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-30
795
    if ($columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-07
796
        $columns = [$columns] unless ref $columns eq 'ARRAY';
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
797
        foreach my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
798
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
799
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
800
            }
801
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
802
                if (@$column == 3 && $column->[1] eq 'as') {
803
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
804
                    splice @$column, 1, 1;
805
                }
806
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
807
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
808
            }
cleanup
Yuki Kimoto authored on 2011-04-02
809
            unshift @$tables, @{$self->_search_tables($column)};
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
810
            push @sql, ($column, ',');
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
811
        }
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
812
        pop @sql if $sql[-1] eq ',';
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
813
    }
814
    else { push @sql, '*' }
815
    
816
    # Table
cleanup
Yuki Kimoto authored on 2011-03-30
817
    push @sql, 'from';
818
    if ($relation) {
819
        my $found = {};
820
        foreach my $table (@$tables) {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
821
            push @sql, ($self->_q($table), ',') unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
822
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
823
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
824
    }
cleanup
Yuki Kimoto authored on 2011-03-30
825
    else {
826
        my $main_table = $tables->[-1] || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
827
        push @sql, $self->_q($main_table);
cleanup
Yuki Kimoto authored on 2011-03-30
828
    }
829
    pop @sql if ($sql[-1] || '') eq ',';
cleanup
Yuki Kimoto authored on 2011-04-25
830
    croak "Not found table name " . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
831
      unless $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
832

            
cleanup
Yuki Kimoto authored on 2011-04-02
833
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
834
    unshift @$tables,
835
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
836
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
837
    # Where
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
838
    my $where_clause = '';
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
839
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
updated pod
Yuki Kimoto authored on 2011-06-21
840
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
841
        $where_clause = "where " . $where->[0];
842
        $where_param = $where->[1];
843
    }
844
    elsif (ref $where) {
cleanup
Yuki Kimoto authored on 2011-04-25
845
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
846
        $where_param = keys %$where_param
847
                     ? $self->merge_param($where_param, $where->param)
848
                     : $where->param;
cleanup
Yuki Kimoto authored on 2011-04-25
849
        
850
        # String where
851
        $where_clause = $where->to_string;
852
    }
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
853
    elsif ($where) { $where_clause = "where $where" }
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
854
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
855
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-04-02
856
    unshift @$tables, @{$self->_search_tables($where_clause)};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
857
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
858
    # Push join
859
    $self->_push_join(\@sql, $join, $tables);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
860
    
cleanup
Yuki Kimoto authored on 2011-03-09
861
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-04-02
862
    push @sql, $where_clause;
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
863
    
cleanup
Yuki Kimoto authored on 2011-03-08
864
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-04-02
865
    $self->_push_relation(\@sql, $tables, $relation, $where_clause eq '' ? 1 : 0);
cleanup
Yuki Kimoto authored on 2011-03-08
866
    
cleanup
Yuki Kimoto authored on 2011-04-02
867
    # Append
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
868
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
869
    
added EXPERIMENTAL select() ...
Yuki Kimoto authored on 2011-04-19
870
    # Wrap
871
    if ($wrap) {
cleanup
Yuki Kimoto authored on 2011-04-25
872
        croak "wrap option must be array refrence " . _subname
added EXPERIMENTAL select() ...
Yuki Kimoto authored on 2011-04-19
873
          unless ref $wrap eq 'ARRAY';
874
        unshift @sql, $wrap->[0];
875
        push @sql, $wrap->[1];
876
    }
877
    
cleanup
Yuki Kimoto authored on 2011-01-27
878
    # SQL
879
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
880
    
881
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
882
    my $result = $self->execute($sql, $where_param, table => $tables, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
883
    
884
    return $result;
885
}
886

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
887
sub setup_model {
888
    my $self = shift;
889
    
cleanup
Yuki Kimoto authored on 2011-04-02
890
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
891
    $self->each_column(
892
        sub {
893
            my ($self, $table, $column, $column_info) = @_;
894
            if (my $model = $self->models->{$table}) {
895
                push @{$model->columns}, $column;
896
            }
897
        }
898
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
899
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
900
}
901

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
902
sub available_datatype {
simplify type_rule
Yuki Kimoto authored on 2011-06-10
903
    my $self = shift;
904
    
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
905
    my $data_types = '';
simplify type_rule
Yuki Kimoto authored on 2011-06-10
906
    foreach my $i (-1000 .. 1000) {
907
         my $type_info = $self->dbh->type_info($i);
908
         my $data_type = $type_info->{DATA_TYPE};
909
         my $type_name = $type_info->{TYPE_NAME};
910
         $data_types .= "$data_type ($type_name)\n"
911
           if defined $data_type;
912
    }
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
913
    return "Data Type maybe equal to Type Name" unless $data_types;
914
    $data_types = "Data Type (Type name)\n" . $data_types;
simplify type_rule
Yuki Kimoto authored on 2011-06-10
915
    return $data_types;
916
}
917

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
918
sub available_typename {
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
919
    my $self = shift;
920
    
921
    # Type Names
922
    my $type_names = {};
923
    $self->each_column(sub {
924
        my ($self, $table, $column, $column_info) = @_;
925
        $type_names->{$column_info->{TYPE_NAME}} = 1
926
          if $column_info->{TYPE_NAME};
927
    });
928
    my @output = sort keys %$type_names;
929
    unshift @output, "Type Name";
930
    return join "\n", @output;
931
}
932

            
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
933
sub type_rule {
934
    my $self = shift;
935
    
936
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
937
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
938
        
939
        # Into
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
940
        foreach my $i (1 .. 2) {
941
            my $into = "into$i";
942
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
943
            $self->{type_rule} = $type_rule;
944
            $self->{"_$into"} = {};
945
            foreach my $type_name (keys %{$type_rule->{$into} || {}}) {
946
                croak qq{type name of $into section must be lower case}
947
                  if $type_name =~ /[A-Z]/;
948
            }
949
            $self->each_column(sub {
950
                my ($dbi, $table, $column, $column_info) = @_;
951
                
952
                my $type_name = lc $column_info->{TYPE_NAME};
953
                if ($type_rule->{$into} &&
954
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
955
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
956
                    return unless exists $type_rule->{$into}->{$type_name};
957
                    if  (defined $filter && ref $filter ne 'CODE') 
958
                    {
959
                        my $fname = $filter;
960
                        croak qq{Filter "$fname" is not registered" } . _subname
961
                          unless exists $self->filters->{$fname};
962
                        
963
                        $filter = $self->filters->{$fname};
964
                    }
965

            
micro optimization
Yuki Kimoto authored on 2011-07-30
966
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
967
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
968
                }
969
            });
970
        }
971

            
972
        # From
973
        foreach my $i (1 .. 2) {
974
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
975
            foreach my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
976
                croak qq{data type of from$i section must be lower case or number}
977
                  if $data_type =~ /[A-Z]/;
978
                my $fname = $type_rule->{"from$i"}{$data_type};
979
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
980
                    croak qq{Filter "$fname" is not registered" } . _subname
981
                      unless exists $self->filters->{$fname};
982
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
983
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
984
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
985
            }
986
        }
987
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
988
        return $self;
989
    }
990
    
991
    return $self->{type_rule} || {};
992
}
993

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

            
cleanup
yuki-kimoto authored on 2010-10-17
997
    # Arguments
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
998
    my $param;
999
    $param = shift if @_ % 2;
1000
    my %args = @_;
cleanup
Yuki Kimoto authored on 2011-03-21
1001
    my $table = delete $args{table} || '';
cleanup
Yuki Kimoto authored on 2011-04-25
1002
    croak qq{"table" option must be specified } . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
1003
      unless $table;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1004
    my $p = delete $args{param} || {};
1005
    $param  ||= $p;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1006
    my $where = delete $args{where} || {};
1007
    my $where_param = delete $args{where_param} || {};
1008
    my $append = delete $args{append} || '';
cleanup
Yuki Kimoto authored on 2011-03-21
1009
    my $allow_update_all = delete $args{allow_update_all};
cleanup
Yuki Kimoto authored on 2011-06-08
1010
    my $id = delete $args{id};
1011
    my $primary_key = delete $args{primary_key};
1012
    croak "update method primary_key option " .
1013
          "must be specified when id is specified " . _subname
1014
      if defined $id && !defined $primary_key;
1015
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1016
    my $prefix = delete $args{prefix};
update_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1017

            
cleanup
yuki-kimoto authored on 2010-10-17
1018
    # Update clause
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1019
    my $update_clause = $self->update_param($param);
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1020

            
1021
    # Where
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1022
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1023
    my $where_clause = '';
updated pod
Yuki Kimoto authored on 2011-06-21
1024
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1025
        $where_clause = "where " . $where->[0];
1026
        $where_param = $where->[1];
1027
    }
1028
    elsif (ref $where) {
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1029
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1030
        $where_param = keys %$where_param
1031
                     ? $self->merge_param($where_param, $where->param)
1032
                     : $where->param;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1033
        
1034
        # String where
1035
        $where_clause = $where->to_string;
1036
    }
1037
    elsif ($where) { $where_clause = "where $where" }
cleanup
Yuki Kimoto authored on 2011-04-25
1038
    croak qq{"where" must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
1039
      if "$where_clause" eq '' && !$allow_update_all;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1040
    
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1041
    # Merge param
1042
    $param = $self->merge_param($param, $where_param) if keys %$where_param;
1043
    
cleanup
Yuki Kimoto authored on 2011-04-02
1044
    # Update statement
cleanup
Yuki Kimoto authored on 2011-01-27
1045
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1046
    push @sql, "update";
1047
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1048
    push @sql, $self->_q($table) . " $update_clause $where_clause";
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1049
    push @sql, $append if defined $append;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1050
    
cleanup
Yuki Kimoto authored on 2011-01-27
1051
    # SQL
1052
    my $sql = join(' ', @sql);
1053
    
cleanup
yuki-kimoto authored on 2010-10-17
1054
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
1055
    return $self->execute($sql, $param, table => $table, %args);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1056
}
1057

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1060
sub update_param {
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1061
    my ($self, $param, $opt) = @_;
1062
    
cleanup
Yuki Kimoto authored on 2011-04-02
1063
    # Create update parameter tag
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1064
    my $tag = $self->assign_param($param);
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1065
    $tag = "set $tag" unless $opt->{no_set};
1066

            
cleanup
Yuki Kimoto authored on 2011-04-02
1067
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1068
}
1069

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1072
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1073
    
updated pod
Yuki Kimoto authored on 2011-06-21
1074
    my ($self, $source) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1075
    
updated pod
Yuki Kimoto authored on 2011-06-21
1076
    # Cache
1077
    my $cache = $self->cache;
1078
    
1079
    # Query
1080
    my $query;
1081
    
1082
    # Get cached query
1083
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1084
        
updated pod
Yuki Kimoto authored on 2011-06-21
1085
        # Get query
1086
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1087
        
updated pod
Yuki Kimoto authored on 2011-06-21
1088
        # Create query
1089
        if ($q) {
1090
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1091
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1092
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1093
    }
1094
    
1095
    # Create query
1096
    unless ($query) {
1097

            
1098
        # Create query
1099
        my $builder = $self->query_builder;
1100
        $query = $builder->build_query($source);
1101

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

            
1108
        # Save query to cache
1109
        $self->cache_method->(
1110
            $self, $source,
1111
            {
1112
                sql     => $query->sql, 
1113
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1114
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1115
            }
1116
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1117
    }
1118
    
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1119
    # Save sql
1120
    $self->last_sql($query->sql);
1121
    
updated pod
Yuki Kimoto authored on 2011-06-21
1122
    # Prepare statement handle
1123
    my $sth;
1124
    eval { $sth = $self->dbh->prepare($query->{sql})};
1125
    
1126
    if ($@) {
1127
        $self->_croak($@, qq{. Following SQL is executed.\n}
1128
                        . qq{$query->{sql}\n} . _subname);
1129
    }
1130
    
1131
    # Set statement handle
1132
    $query->sth($sth);
1133
    
1134
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1135
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1136
    
1137
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1138
}
1139

            
cleanup
Yuki Kimoto authored on 2011-04-02
1140
sub _create_bind_values {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1141
    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1142
    
cleanup
Yuki Kimoto authored on 2011-04-02
1143
    # Create bind values
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1144
    my $bind = [];
removed reconnect method
yuki-kimoto authored on 2010-05-28
1145
    my $count = {};
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1146
    my $not_exists = {};
cleanup
Yuki Kimoto authored on 2011-01-12
1147
    foreach my $column (@$columns) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
1148
        
1149
        # Value
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1150
        my $value;
1151
        if(ref $params->{$column} eq 'ARRAY') {
1152
            my $i = $count->{$column} || 0;
1153
            $i += $not_exists->{$column} || 0;
1154
            my $found;
1155
            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1156
                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
1157
                    $not_exists->{$column}++;
1158
                }
1159
                else  {
1160
                    $value = $params->{$column}->[$k];
1161
                    $found = 1;
1162
                    last
1163
                }
1164
            }
1165
            next unless $found;
1166
        }
1167
        else { $value = $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1168
        
cleanup
Yuki Kimoto authored on 2011-01-12
1169
        # Filter
1170
        my $f = $filter->{$column} || $self->{default_out_filter} || '';
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1171
        $value = $f->($value) if $f;
1172
        
1173
        # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1174
        foreach my $i (1 .. 2) {
1175
            my $type_filter = $type_filters->{$i};
micro optimization
Yuki Kimoto authored on 2011-07-30
1176
            my $tf = $self->{"_into$i"}->{dot}->{$column} || $type_filter->{$column};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1177
            $value = $tf->($value) if $tf;
1178
        }
cleanup
kimoto.yuki@gmail.com authored on 2010-12-21
1179
        
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1180
        # Bind values
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
1181
        push @$bind, {value => $value, bind_type => $bind_type->{$column}};
removed reconnect method
yuki-kimoto authored on 2010-05-28
1182
        
1183
        # Count up 
1184
        $count->{$column}++;
1185
    }
1186
    
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1187
    return $bind;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1188
}
1189

            
cleanup
Yuki Kimoto authored on 2011-06-08
1190
sub _create_param_from_id {
1191
    my ($self, $id, $primary_keys) = @_;
improved error messages
Yuki Kimoto authored on 2011-04-18
1192
    
cleanup
Yuki Kimoto authored on 2011-06-08
1193
    # Create parameter
1194
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1195
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1196
        $id = [$id] unless ref $id;
1197
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1198
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1199
          unless !ref $id || ref $id eq 'ARRAY';
1200
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1201
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1202
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1203
        for(my $i = 0; $i < @$primary_keys; $i ++) {
cleanup
Yuki Kimoto authored on 2011-06-08
1204
           $param->{$primary_keys->[$i]} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1205
        }
1206
    }
1207
    
cleanup
Yuki Kimoto authored on 2011-06-08
1208
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1209
}
1210

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1211
sub _connect {
1212
    my $self = shift;
1213
    
1214
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1215
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1216
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1217
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1218
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1219
    croak qq{"dsn" must be specified } . _subname
1220
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1221
    my $user        = $self->user;
1222
    my $password    = $self->password;
1223
    my $dbi_option = {%{$self->dbi_options}, %{$self->dbi_option}};
added warnings
Yuki Kimoto authored on 2011-06-07
1224
    warn "dbi_options is DEPRECATED! use dbi_option instead\n"
1225
      if keys %{$self->dbi_options};
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1226
    
1227
    # Connect
1228
    my $dbh = eval {DBI->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1229
        $dsn,
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1230
        $user,
1231
        $password,
1232
        {
1233
            %{$self->default_dbi_option},
1234
            %$dbi_option
1235
        }
1236
    )};
1237
    
1238
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1239
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1240
    
1241
    return $dbh;
1242
}
1243

            
cleanup
yuki-kimoto authored on 2010-10-17
1244
sub _croak {
1245
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1246
    
1247
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1248
    $append ||= "";
1249
    
1250
    # Verbose
1251
    if ($Carp::Verbose) { croak $error }
1252
    
1253
    # Not verbose
1254
    else {
1255
        
1256
        # Remove line and module infromation
1257
        my $at_pos = rindex($error, ' at ');
1258
        $error = substr($error, 0, $at_pos);
1259
        $error =~ s/\s+$//;
1260
        croak "$error$append";
1261
    }
1262
}
1263

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1264
sub _need_tables {
1265
    my ($self, $tree, $need_tables, $tables) = @_;
1266
    
cleanup
Yuki Kimoto authored on 2011-04-02
1267
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1268
    foreach my $table (@$tables) {
1269
        if ($tree->{$table}) {
1270
            $need_tables->{$table} = 1;
1271
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1272
        }
1273
    }
1274
}
1275

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1276
sub _push_join {
1277
    my ($self, $sql, $join, $join_tables) = @_;
1278
    
cleanup
Yuki Kimoto authored on 2011-04-02
1279
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1280
    return unless @$join;
1281
    
cleanup
Yuki Kimoto authored on 2011-04-02
1282
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1283
    my $tree = {};
1284
    for (my $i = 0; $i < @$join; $i++) {
1285
        
cleanup
Yuki Kimoto authored on 2011-07-28
1286
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1287
        my $join_clause;;
1288
        my $option;
1289
        if (ref $join->[$i] eq 'HASH') {
1290
            $join_clause = $join->[$i]->{clause};
1291
            $option = {table => $join->[$i]->{table}};
1292
        }
1293
        else {
1294
            $join_clause = $join->[$i];
1295
            $option = {};
1296
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1297

            
1298
        # Find tables in join clause
added join new syntax
Yuki Kimoto authored on 2011-07-28
1299
        my $table1;
1300
        my $table2;
1301
        if (my $table = $option->{table}) {
1302
            $table1 = $table->[0];
1303
            $table2 = $table->[1];
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1304
        }
cleanup
Yuki Kimoto authored on 2011-07-28
1305
        else {
1306
            my $q = $self->_quote;
1307
            my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1308
            $j_clause =~ s/'.+?'//g;
1309
            my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1310
            $j_clause =~ s/[$q_re]//g;
cleanup
Yuki Kimoto authored on 2011-07-28
1311
            my $c = $self->safety_character;
1312
            my $join_re = qr/(?:^|\s)($c+)\.$c+\s+=\s+($c+)\.$c+/;
1313
            if ($j_clause =~ $join_re) {
1314
                $table1 = $1;
1315
                $table2 = $2;
1316
            }
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1317
        }
added join new syntax
Yuki Kimoto authored on 2011-07-28
1318
        croak qq{join clause must have two table name after "on" keyword. } .
1319
              qq{"$join_clause" is passed }  . _subname
1320
          unless defined $table1 && defined $table2;
1321
        croak qq{right side table of "$join_clause" must be unique }
1322
            . _subname
1323
          if exists $tree->{$table2};
1324
        croak qq{Same table "$table1" is specified} . _subname
1325
          if $table1 eq $table2;
1326
        $tree->{$table2}
1327
          = {position => $i, parent => $table1, join => $join_clause};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1328
    }
1329
    
cleanup
Yuki Kimoto authored on 2011-04-02
1330
    # Search need tables
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1331
    my $need_tables = {};
1332
    $self->_need_tables($tree, $need_tables, $join_tables);
1333
    my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} } keys %$need_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1334
    
1335
    # Add join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1336
    foreach my $need_table (@need_tables) {
1337
        push @$sql, $tree->{$need_table}{join};
1338
    }
1339
}
cleanup
Yuki Kimoto authored on 2011-03-08
1340

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1341
sub _quote {
1342
    my $self = shift;
1343
    
1344
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1345
         : defined $self->quote ? $self->quote
1346
         : '';
1347
}
1348

            
cleanup
Yuki Kimoto authored on 2011-07-29
1349
sub _q {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1350
    my ($self, $value) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1351
    
1352
    my $quote = $self->_quote;
1353
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1354
    my $p;
1355
    if (defined $quote && length $quote > 1) {
1356
        $p = substr($quote, 1, 1);
1357
    }
1358
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1359
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1360
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1361
}
1362

            
cleanup
Yuki Kimoto authored on 2011-04-02
1363
sub _remove_duplicate_table {
1364
    my ($self, $tables, $main_table) = @_;
1365
    
1366
    # Remove duplicate table
1367
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1368
    delete $tables{$main_table} if $main_table;
1369
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1370
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1371
    if (my $q = $self->_quote) {
1372
        $q = quotemeta($q);
1373
        $_ =~ s/[$q]//g for @$new_tables;
1374
    }
1375

            
1376
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1377
}
1378

            
cleanup
Yuki Kimoto authored on 2011-04-02
1379
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1380
    my ($self, $source) = @_;
1381
    
cleanup
Yuki Kimoto authored on 2011-04-02
1382
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1383
    my $tables = [];
1384
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1385
    my $q = $self->_quote;
cleanup
Yuki Kimoto authored on 2011-04-02
1386
    my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1387
    my $quoted_safety_character_re = $self->_q("?([$safety_character]+)");
1388
    my $table_re = $q ? qr/(?:^|[^$safety_character])$quoted_safety_character_re?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1389
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1390
    while ($source =~ /$table_re/g) {
1391
        push @$tables, $1;
1392
    }
1393
    
1394
    return $tables;
1395
}
1396

            
cleanup
Yuki Kimoto authored on 2011-04-02
1397
sub _where_to_obj {
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1398
    my ($self, $where) = @_;
1399
    
cleanup
Yuki Kimoto authored on 2011-04-02
1400
    my $obj;
1401
    
1402
    # Hash
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1403
    if (ref $where eq 'HASH') {
1404
        my $clause = ['and'];
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1405
        my $q = $self->_quote;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1406
        foreach my $column (keys %$where) {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1407
            my $column_quote = $self->_q($column);
1408
            $column_quote =~ s/\./$self->_q(".")/e;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1409
            push @$clause, "$column_quote = :$column" for keys %$where;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1410
        }
cleanup
Yuki Kimoto authored on 2011-04-02
1411
        $obj = $self->where(clause => $clause, param => $where);
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1412
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1413
    
1414
    # DBIx::Custom::Where object
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1415
    elsif (ref $where eq 'DBIx::Custom::Where') {
cleanup
Yuki Kimoto authored on 2011-04-02
1416
        $obj = $where;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1417
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1418
    
updated pod
Yuki Kimoto authored on 2011-06-21
1419
    # Array
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1420
    elsif (ref $where eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-04-02
1421
        $obj = $self->where(
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1422
            clause => $where->[0],
1423
            param  => $where->[1]
1424
        );
1425
    }
1426
    
cleanup
Yuki Kimoto authored on 2011-04-02
1427
    # Check where argument
improved error messages
Yuki Kimoto authored on 2011-04-18
1428
    croak qq{"where" must be hash reference or DBIx::Custom::Where object}
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
1429
        . qq{or array reference, which contains where clause and parameter}
cleanup
Yuki Kimoto authored on 2011-04-25
1430
        . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
1431
      unless ref $obj eq 'DBIx::Custom::Where';
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1432
    
cleanup
Yuki Kimoto authored on 2011-04-02
1433
    return $obj;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1434
}
1435

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

            
1439
    # Initialize filters
1440
    $self->{filter} ||= {};
micro optimization
Yuki Kimoto authored on 2011-07-30
1441
    $self->{filter}{on} = 1;
updated pod
Yuki Kimoto authored on 2011-06-21
1442
    $self->{filter}{out} ||= {};
1443
    $self->{filter}{in} ||= {};
1444
    $self->{filter}{end} ||= {};
1445
    
1446
    # Usage
1447
    my $usage = "Usage: \$dbi->apply_filter(" .
1448
                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1449
                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1450
    
1451
    # Apply filter
1452
    for (my $i = 0; $i < @cinfos; $i += 2) {
1453
        
1454
        # Column
1455
        my $column = $cinfos[$i];
1456
        if (ref $column eq 'ARRAY') {
1457
            foreach my $c (@$column) {
1458
                push @cinfos, $c, $cinfos[$i + 1];
1459
            }
1460
            next;
1461
        }
1462
        
1463
        # Filter infomation
1464
        my $finfo = $cinfos[$i + 1] || {};
1465
        croak "$usage (table: $table) " . _subname
1466
          unless  ref $finfo eq 'HASH';
1467
        foreach my $ftype (keys %$finfo) {
1468
            croak "$usage (table: $table) " . _subname
1469
              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1470
        }
1471
        
1472
        # Set filters
1473
        foreach my $way (qw/in out end/) {
1474
        
1475
            # Filter
1476
            my $filter = $finfo->{$way};
1477
            
1478
            # Filter state
1479
            my $state = !exists $finfo->{$way} ? 'not_exists'
1480
                      : !defined $filter        ? 'not_defined'
1481
                      : ref $filter eq 'CODE'   ? 'code'
1482
                      : 'name';
1483
            
1484
            # Filter is not exists
1485
            next if $state eq 'not_exists';
1486
            
1487
            # Check filter name
1488
            croak qq{Filter "$filter" is not registered } . _subname
1489
              if  $state eq 'name'
1490
               && ! exists $self->filters->{$filter};
1491
            
1492
            # Set filter
1493
            my $f = $state eq 'not_defined' ? undef
1494
                  : $state eq 'code'        ? $filter
1495
                  : $self->filters->{$filter};
1496
            $self->{filter}{$way}{$table}{$column} = $f;
1497
            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1498
            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1499
            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1500
        }
1501
    }
1502
    
1503
    return $self;
1504
}
1505

            
1506
# DEPRECATED!
1507
sub create_query {
1508
    warn "create_query is DEPRECATED! use query option of each method";
1509
    shift->_create_query(@_);
1510
}
1511

            
cleanup
Yuki Kimoto authored on 2011-06-13
1512
# DEPRECATED!
1513
sub apply_filter {
1514
    my $self = shift;
1515
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1516
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1517
    return $self->_apply_filter(@_);
1518
}
1519

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1520
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1521
our %SELECT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1522
sub select_at {
1523
    my ($self, %args) = @_;
1524

            
updated pod
Yuki Kimoto authored on 2011-06-08
1525
    warn "select_at is DEPRECATED! use update and id option instead";
1526

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1527
    # Arguments
1528
    my $primary_keys = delete $args{primary_key};
1529
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1530
    my $where = delete $args{where};
1531
    my $param = delete $args{param};
1532
    
1533
    # Check arguments
1534
    foreach my $name (keys %args) {
1535
        croak qq{"$name" is wrong option } . _subname
1536
          unless $SELECT_AT_ARGS{$name};
1537
    }
1538
    
1539
    # Table
1540
    croak qq{"table" option must be specified } . _subname
1541
      unless $args{table};
1542
    my $table = ref $args{table} ? $args{table}->[-1] : $args{table};
1543
    
1544
    # Create where parameter
1545
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1546
    
1547
    return $self->select(where => $where_param, %args);
1548
}
1549

            
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1550
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1551
our %DELETE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1552
sub delete_at {
1553
    my ($self, %args) = @_;
updated pod
Yuki Kimoto authored on 2011-06-08
1554

            
1555
    warn "delete_at is DEPRECATED! use update and id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1556
    
1557
    # Arguments
1558
    my $primary_keys = delete $args{primary_key};
1559
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1560
    my $where = delete $args{where};
1561
    
1562
    # Check arguments
1563
    foreach my $name (keys %args) {
1564
        croak qq{"$name" is wrong option } . _subname
1565
          unless $DELETE_AT_ARGS{$name};
1566
    }
1567
    
1568
    # Create where parameter
1569
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1570
    
1571
    return $self->delete(where => $where_param, %args);
1572
}
1573

            
cleanup
Yuki Kimoto authored on 2011-06-08
1574
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1575
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1576
sub update_at {
1577
    my $self = shift;
1578

            
1579
    warn "update_at is DEPRECATED! use update and id option instead";
1580
    
1581
    # Arguments
1582
    my $param;
1583
    $param = shift if @_ % 2;
1584
    my %args = @_;
1585
    my $primary_keys = delete $args{primary_key};
1586
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1587
    my $where = delete $args{where};
1588
    my $p = delete $args{param} || {};
1589
    $param  ||= $p;
1590
    
1591
    # Check arguments
1592
    foreach my $name (keys %args) {
1593
        croak qq{"$name" is wrong option } . _subname
1594
          unless $UPDATE_AT_ARGS{$name};
1595
    }
1596
    
1597
    # Create where parameter
1598
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1599
    
1600
    return $self->update(where => $where_param, param => $param, %args);
1601
}
1602

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1603
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1604
our %INSERT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1605
sub insert_at {
1606
    my $self = shift;
1607
    
1608
    warn "insert_at is DEPRECATED! use insert and id option instead";
1609
    
1610
    # Arguments
1611
    my $param;
1612
    $param = shift if @_ % 2;
1613
    my %args = @_;
1614
    my $primary_key = delete $args{primary_key};
1615
    $primary_key = [$primary_key] unless ref $primary_key;
1616
    my $where = delete $args{where};
1617
    my $p = delete $args{param} || {};
1618
    $param  ||= $p;
1619
    
1620
    # Check arguments
1621
    foreach my $name (keys %args) {
1622
        croak qq{"$name" is wrong option } . _subname
1623
          unless $INSERT_AT_ARGS{$name};
1624
    }
1625
    
1626
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-06-08
1627
    my $where_param = $self->_create_param_from_id($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1628
    $param = $self->merge_param($where_param, $param);
1629
    
1630
    return $self->insert(param => $param, %args);
1631
}
1632

            
added warnings
Yuki Kimoto authored on 2011-06-07
1633
# DEPRECATED!
1634
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1635
    my $self = shift;
1636
    
added warnings
Yuki Kimoto authored on 2011-06-07
1637
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1638
    
1639
    # Merge tag
1640
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1641
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1642
    
1643
    return $self;
1644
}
1645

            
1646
# DEPRECATED!
1647
sub register_tag_processor {
1648
    my $self = shift;
1649
    warn "register_tag_processor is DEPRECATED!";
1650
    # Merge tag
1651
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1652
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1653
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1654
}
1655

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1656
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
1657
has 'data_source';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1658
has dbi_options => sub { {} };
1659
has filter_check  => 1;
1660
has 'reserved_word_quote';
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1661

            
cleanup
Yuki Kimoto authored on 2011-01-25
1662
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1663
sub default_bind_filter {
1664
    my $self = shift;
1665
    
cleanup
Yuki Kimoto authored on 2011-06-13
1666
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1667
    
cleanup
Yuki Kimoto authored on 2011-01-12
1668
    if (@_) {
1669
        my $fname = $_[0];
1670
        
1671
        if (@_ && !$fname) {
1672
            $self->{default_out_filter} = undef;
1673
        }
1674
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1675
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1676
              unless exists $self->filters->{$fname};
1677
        
1678
            $self->{default_out_filter} = $self->filters->{$fname};
1679
        }
1680
        return $self;
1681
    }
1682
    
1683
    return $self->{default_out_filter};
1684
}
1685

            
cleanup
Yuki Kimoto authored on 2011-01-25
1686
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1687
sub default_fetch_filter {
1688
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1689

            
cleanup
Yuki Kimoto authored on 2011-06-13
1690
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1691
    
1692
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1693
        my $fname = $_[0];
1694

            
cleanup
Yuki Kimoto authored on 2011-01-12
1695
        if (@_ && !$fname) {
1696
            $self->{default_in_filter} = undef;
1697
        }
1698
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1699
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1700
              unless exists $self->filters->{$fname};
1701
        
1702
            $self->{default_in_filter} = $self->filters->{$fname};
1703
        }
1704
        
1705
        return $self;
1706
    }
1707
    
many changed
Yuki Kimoto authored on 2011-01-23
1708
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1709
}
1710

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1711
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1712
sub insert_param_tag {
1713
    warn "insert_param_tag is DEPRECATED! " .
1714
         "use insert_param instead!";
1715
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1716
}
1717

            
1718
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1719
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1720
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1721
         "use update_param instead";
1722
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1723
}
cleanup
Yuki Kimoto authored on 2011-03-08
1724
# DEPRECATED!
1725
sub _push_relation {
1726
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1727
    
1728
    if (keys %{$relation || {}}) {
1729
        push @$sql, $need_where ? 'where' : 'and';
1730
        foreach my $rcolumn (keys %$relation) {
1731
            my $table1 = (split (/\./, $rcolumn))[0];
1732
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1733
            push @$tables, ($table1, $table2);
1734
            push @$sql, ("$rcolumn = " . $relation->{$rcolumn},  'and');
1735
        }
1736
    }
1737
    pop @$sql if $sql->[-1] eq 'and';    
1738
}
1739

            
1740
# DEPRECATED!
1741
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1742
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1743
    
1744
    if (keys %{$relation || {}}) {
1745
        foreach my $rcolumn (keys %$relation) {
1746
            my $table1 = (split (/\./, $rcolumn))[0];
1747
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1748
            my $table1_exists;
1749
            my $table2_exists;
1750
            foreach my $table (@$tables) {
1751
                $table1_exists = 1 if $table eq $table1;
1752
                $table2_exists = 1 if $table eq $table2;
1753
            }
1754
            unshift @$tables, $table1 unless $table1_exists;
1755
            unshift @$tables, $table2 unless $table2_exists;
1756
        }
1757
    }
1758
}
1759

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1762
=head1 NAME
1763

            
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1764
DBIx::Custom - Execute insert, update, delete, and select statement easily
removed reconnect method
yuki-kimoto authored on 2010-05-28
1765

            
1766
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1767

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1768
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1769
    
1770
    # Connect
1771
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1772
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1773
        user => 'ken',
1774
        password => '!LFKD%$&',
1775
        dbi_option => {mysql_enable_utf8 => 1}
1776
    );
cleanup
yuki-kimoto authored on 2010-08-05
1777

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1778
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1779
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1780
    
1781
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
1782
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
1783
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1784
    
1785
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
1786
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
1787

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1792
    # Select, more complex
1793
    my $result = $dbi->select(
1794
        table  => 'book',
1795
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
1796
            {book => [qw/title author/]},
1797
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1798
        ],
1799
        where  => {'book.author' => 'Ken'},
1800
        join => ['left outer join company on book.company_id = company.id'],
1801
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
1802
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1803
    
removed register_format()
yuki-kimoto authored on 2010-05-26
1804
    # Fetch
1805
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1806
        
removed register_format()
yuki-kimoto authored on 2010-05-26
1807
    }
1808
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1809
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
1810
    while (my $row = $result->fetch_hash) {
1811
        
1812
    }
1813
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1814
    # Execute SQL with parameter.
1815
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1816
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
1817
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1818
    );
1819
    
renamed update tag to update...
yuki-kimoto authored on 2010-08-09
1820
=head1 DESCRIPTIONS
removed reconnect method
yuki-kimoto authored on 2010-05-28
1821

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1837
Named place holder support
1838

            
1839
=item *
1840

            
cleanup
Yuki Kimoto authored on 2011-07-29
1841
Model support
1842

            
1843
=item *
1844

            
1845
Connection manager support
1846

            
1847
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1848

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

            
1853
=item *
1854

            
1855
Filtering by data type or column name(EXPERIMENTAL)
1856

            
1857
=item *
1858

            
1859
Create C<order by> clause flexibly(EXPERIMENTAL)
1860

            
1861
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1862

            
cleanup
Yuki Kimoto authored on 2011-07-29
1863
=head1 DOCUMENTATIONS
pod fix
Yuki Kimoto authored on 2011-01-21
1864

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1870
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
1871
L<DBIx::Custom::Result>,
1872
L<DBIx::Custom::Query>,
1873
L<DBIx::Custom::Where>,
1874
L<DBIx::Custom::Model>,
1875
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
1876

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

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

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

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

            
1887
This is L<DBIx::Connector> example. Please pass
updated pod
Yuki Kimoto authored on 2011-06-21
1888
C<default_dbi_option> to L<DBIx::Connector> C<new> method.
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
1889

            
1890
    my $connector = DBIx::Connector->new(
1891
        "dbi:mysql:database=$DATABASE",
1892
        $USER,
1893
        $PASSWORD,
1894
        DBIx::Custom->new->default_dbi_option
1895
    );
1896
    
updated pod
Yuki Kimoto authored on 2011-06-21
1897
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
1898

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

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

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

            
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1906
=head2 C<dbi_option>
added dbi_options attribute
kimoto authored on 2010-12-20
1907

            
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1908
    my $dbi_option = $dbi->dbi_option;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1909
    $dbi = $dbi->dbi_option($dbi_option);
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
1910

            
updated pod
Yuki Kimoto authored on 2011-06-21
1911
L<DBI> option, used when C<connect> method is executed.
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1912
Each value in option override the value of C<default_dbi_option>.
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
1913

            
1914
=head2 C<default_dbi_option>
1915

            
1916
    my $default_dbi_option = $dbi->default_dbi_option;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1917
    $dbi = $dbi->default_dbi_option($default_dbi_option);
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
1918

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1922
    {
1923
        RaiseError => 1,
1924
        PrintError => 0,
1925
        AutoCommit => 1,
1926
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
1927

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

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

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

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

            
1937
    my $last_sql = $dbi->last_sql;
1938
    $dbi = $dbi->last_sql($last_sql);
1939

            
1940
Get last successed SQL executed by C<execute> method.
1941

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1949
=head2 C<password>
1950

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1971
You can set quote pair.
1972

            
1973
    $dbi->quote('[]');
1974

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

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

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1984
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1985
    $dbi = $self->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
1986

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

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

            
1992
    my $separator = $self->separator;
1993
    $dbi = $self->separator($separator);
1994

            
1995
Separator whichi join table and column.
1996
This is used by C<column> and C<mycolumn> method.
1997

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

            
2000
    my $tag_parse = $dbi->tag_parse(0);
2001
    $dbi = $dbi->tag_parse;
2002

            
2003
Enable DEPRECATED tag parsing functionality, default to 1.
2004
If you want to disable tag parsing functionality, set to 0.
2005

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

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

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

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

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2019
=head2 C<available_datatype> EXPERIMENTAL
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2020

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

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2026
=head2 C<available_typename> EXPERIMENTAL
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2027

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2033
=head2 C<assign_param> EXPERIMENTAL
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2034

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2035
    my $assign_param = $dbi->assign_param({title => 'a', age => 2});
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2036

            
updated pod
Yuki Kimoto authored on 2011-06-09
2037
Create assign parameter.
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2038

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2041
This is equal to C<update_param> exept that set is not added.
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2042

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

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

            
2047
Create column clause. The follwoing column clause is created.
2048

            
2049
    book.author as "book.author",
2050
    book.title as "book.title"
2051

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2054
    # Separator is double underbar
2055
    $dbi->separator('__');
2056
    
2057
    book.author as "book__author",
2058
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2059

            
cleanup
Yuki Kimoto authored on 2011-06-13
2060
    # Separator is hyphen
2061
    $dbi->separator('-');
2062
    
2063
    book.author as "book-author",
2064
    book.title as "book-title"
2065
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2066
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2067

            
update pod
Yuki Kimoto authored on 2011-03-13
2068
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2069
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2070
        user => 'ken',
2071
        password => '!LFKD%$&',
2072
        dbi_option => {mysql_enable_utf8 => 1}
2073
    );
2074

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

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2081
=head2 create_model
2082

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2083
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2084
        table => 'book',
2085
        primary_key => 'id',
2086
        join => [
2087
            'inner join company on book.comparny_id = company.id'
2088
        ],
2089
    );
2090

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

            
2094
   $dbi->model('book')->select(...);
2095

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

            
2098
    my $dbh = $dbi->dbh;
2099

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

            
2103
=head2 C<each_column>
2104

            
2105
    $dbi->each_column(
2106
        sub {
2107
            my ($dbi, $table, $column, $column_info) = @_;
2108
            
2109
            my $type = $column_info->{TYPE_NAME};
2110
            
2111
            if ($type eq 'DATE') {
2112
                # ...
2113
            }
2114
        }
2115
    );
2116

            
2117
Iterate all column informations of all table from database.
2118
Argument is callback when one column is found.
2119
Callback receive four arguments, dbi object, table name,
2120
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2121

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

            
2124
    $dbi->each_table(
2125
        sub {
2126
            my ($dbi, $table, $table_info) = @_;
2127
            
2128
            my $table_name = $table_info->{TABLE_NAME};
2129
        }
2130
    );
2131

            
2132
Iterate all table informationsfrom database.
2133
Argument is callback when one table is found.
2134
Callback receive three arguments, dbi object, table name,
2135
table information.
2136

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

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

            
2144
    my $result = $dbi->execute(
2145
      "select * from book where title = :book.title and author like :book.author",
2146
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2147
    );
2148

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2155
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2156
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2157
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2158
    select * from book where title = :title and author like :author
2159
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2160
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2161
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2162

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2163
You can specify operator with named placeholder
2164
 by C<name{operator}> syntax.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2165

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2166
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2167
    select * from book where :title{=} and :author{like}
2168
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2169
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2170
    select * from where title = ? and author like ?;
2171

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

            
2176
    select * from where title = "aa\\:bb";
2177

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

            
2180
=over 4
2181

            
2182
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2183
    
2184
    filter => {
2185
        title  => sub { uc $_[0] }
2186
        author => sub { uc $_[0] }
2187
    }
update pod
Yuki Kimoto authored on 2011-03-13
2188

            
updated pod
Yuki Kimoto authored on 2011-06-09
2189
    # Filter name
2190
    filter => {
2191
        title  => 'upper_case',
2192
        author => 'upper_case'
2193
    }
2194
        
2195
    # At once
2196
    filter => [
2197
        [qw/title author/]  => sub { uc $_[0] }
2198
    ]
2199

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

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

            
2207
    query => 1
2208

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

            
2212
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2213
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2214
    my $columns = $query->columns;
2215
    
2216
If you want to execute SQL fast, you can do the following way.
2217

            
2218
    my $query;
2219
    foreach my $row (@$rows) {
2220
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2221
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2222
    }
2223

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

            
2227
If you want to execute SQL as possible as fast and don't need filtering.
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2228
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2229
    
2230
    my $query;
2231
    my $sth;
2232
    foreach my $row (@$rows) {
2233
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2234
      $sth ||= $query->sth;
2235
      $sth->execute(map { $row->{$_} } sort keys %$row);
2236
    }
2237

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2242
=item C<table>
2243
    
2244
    table => 'author'
2245

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2253
    # Same
2254
    $dbi->execute(
2255
      "select * from book where title = :book.title and author = :book.author",
2256
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2257

            
updated pod
Yuki Kimoto authored on 2011-06-21
2258
=item C<bind_type>
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2259

            
updated pod
Yuki Kimoto authored on 2011-06-21
2260
Specify database bind data type.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2261

            
updated pod
Yuki Kimoto authored on 2011-06-21
2262
    bind_type => [image => DBI::SQL_BLOB]
2263
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2264

            
updated pod
Yuki Kimoto authored on 2011-06-21
2265
This is used to bind parameter by C<bind_param> of statment handle.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2266

            
updated pod
Yuki Kimoto authored on 2011-06-21
2267
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2268

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
2269
=item C<table_alias> EXPERIMENTAL
2270

            
2271
    table_alias => {user => 'hiker'}
2272

            
2273
Table alias. Key is real table name, value is alias table name.
2274
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2275
on alias table name.
2276

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2277
=item C<type_rule_off> EXPERIMENTAL
2278

            
2279
    type_rule_off => 1
2280

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

            
2283
=item C<type_rule1_off> EXPERIMENTAL
2284

            
2285
    type_rule1_off => 1
2286

            
2287
Turn C<into1> type rule off.
2288

            
2289
=item C<type_rule2_off> EXPERIMENTAL
2290

            
2291
    type_rule2_off => 1
2292

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

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

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2297
=head2 C<delete>
packaging one directory
yuki-kimoto authored on 2009-11-16
2298

            
update pod
Yuki Kimoto authored on 2011-03-13
2299
    $dbi->delete(table => 'book', where => {title => 'Perl'});
2300

            
updated document
Yuki Kimoto authored on 2011-06-09
2301
Execute delete statement.
update pod
Yuki Kimoto authored on 2011-03-13
2302

            
updated document
Yuki Kimoto authored on 2011-06-09
2303
The following opitons are available.
update pod
Yuki Kimoto authored on 2011-03-13
2304

            
update pod
Yuki Kimoto authored on 2011-03-13
2305
=over 4
2306

            
update pod
Yuki Kimoto authored on 2011-03-13
2307
=item C<append>
2308

            
updated document
Yuki Kimoto authored on 2011-06-09
2309
Same as C<select> method's C<append> option.
update pod
Yuki Kimoto authored on 2011-03-13
2310

            
2311
=item C<filter>
2312

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2313
Same as C<execute> method's C<filter> option.
update pod
Yuki Kimoto authored on 2011-03-13
2314

            
updated document
Yuki Kimoto authored on 2011-06-09
2315
=item C<id>
update pod
Yuki Kimoto authored on 2011-03-13
2316

            
updated document
Yuki Kimoto authored on 2011-06-09
2317
    id => 4
2318
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2319

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2323
    $dbi->delete(
2324
        parimary_key => ['id1', 'id2'],
2325
        id => [4, 5],
2326
        table => 'book',
2327
    );
update pod
Yuki Kimoto authored on 2011-03-13
2328

            
updated document
Yuki Kimoto authored on 2011-06-09
2329
The above is same as the followin one.
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
2330

            
updated document
Yuki Kimoto authored on 2011-06-09
2331
    $dbi->delete(where => {id1 => 4, id2 => 5}, table => 'book');
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2332

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

            
2335
    prefix => 'some'
2336

            
2337
prefix before table name section.
2338

            
2339
    delete some from book
2340

            
updated document
Yuki Kimoto authored on 2011-06-09
2341
=item C<query>
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2342

            
updated document
Yuki Kimoto authored on 2011-06-09
2343
Same as C<execute> method's C<query> option.
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2344

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2349
Table name.
2350

            
updated document
Yuki Kimoto authored on 2011-06-09
2351
=item C<where>
update pod
Yuki Kimoto authored on 2011-03-13
2352

            
updated document
Yuki Kimoto authored on 2011-06-09
2353
Same as C<select> method's C<where> option.
update pod
Yuki Kimoto authored on 2011-03-13
2354

            
updated pod
Yuki Kimoto authored on 2011-06-08
2355
=item C<primary_key>
update pod
Yuki Kimoto authored on 2011-03-13
2356

            
updated pod
Yuki Kimoto authored on 2011-06-08
2357
See C<id> option.
update pod
Yuki Kimoto authored on 2011-03-13
2358

            
updated pod
Yuki Kimoto authored on 2011-06-21
2359
=item C<bind_type>
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2360

            
updated pod
Yuki Kimoto authored on 2011-06-21
2361
Same as C<execute> method's C<bind_type> option.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2362

            
2363
=item C<type_rule_off> EXPERIMENTAL
2364

            
2365
Same as C<execute> method's C<type_rule_off> option.
2366

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2367
=item C<type_rule1_off> EXPERIMENTAL
2368

            
2369
    type_rule1_off => 1
2370

            
2371
Same as C<execute> method's C<type_rule1_off> option.
2372

            
2373
=item C<type_rule2_off> EXPERIMENTAL
2374

            
2375
    type_rule2_off => 1
2376

            
2377
Same as C<execute> method's C<type_rule2_off> option.
2378

            
updated pod
Yuki Kimoto authored on 2011-06-08
2379
=back
update pod
Yuki Kimoto authored on 2011-03-13
2380

            
updated pod
Yuki Kimoto authored on 2011-06-08
2381
=head2 C<delete_all>
update pod
Yuki Kimoto authored on 2011-03-13
2382

            
updated pod
Yuki Kimoto authored on 2011-06-08
2383
    $dbi->delete_all(table => $table);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2384

            
updated document
Yuki Kimoto authored on 2011-06-09
2385
Execute delete statement for all rows.
updated pod
Yuki Kimoto authored on 2011-06-21
2386
Options is same as C<delete>.
update pod
Yuki Kimoto authored on 2011-03-13
2387

            
cleanup
yuki-kimoto authored on 2010-10-17
2388
=head2 C<insert>
2389

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

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

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

            
2398
    {date => \"NOW()"}
2399

            
cleanup
Yuki Kimoto authored on 2011-06-09
2400
The following opitons are available.
update pod
Yuki Kimoto authored on 2011-03-13
2401

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2404
=item C<append>
2405

            
cleanup
Yuki Kimoto authored on 2011-06-09
2406
Same as C<select> method's C<append> option.
update pod
Yuki Kimoto authored on 2011-03-13
2407

            
2408
=item C<filter>
2409

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2410
Same as C<execute> method's C<filter> option.
2411

            
2412
=item C<id>
2413

            
updated document
Yuki Kimoto authored on 2011-06-09
2414
    id => 4
2415
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2416

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2420
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2421
        {title => 'Perl', author => 'Ken'}
2422
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2423
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2424
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2425
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2426

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

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

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

            
2436
    prefix => 'or replace'
2437

            
2438
prefix before table name section
2439

            
2440
    insert or replace into book
2441

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2442
=item C<primary_key>
update pod
Yuki Kimoto authored on 2011-03-13
2443

            
updated document
Yuki Kimoto authored on 2011-06-09
2444
    primary_key => 'id'
2445
    primary_key => ['id1', 'id2']
update pod
Yuki Kimoto authored on 2011-03-13
2446

            
updated document
Yuki Kimoto authored on 2011-06-09
2447
Primary key. This is used by C<id> option.
cleanup
Yuki Kimoto authored on 2011-06-09
2448

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

            
2451
Same as C<execute> method's C<query> option.
2452

            
2453
=item C<table>
2454

            
2455
    table => 'book'
2456

            
2457
Table name.
2458

            
updated pod
Yuki Kimoto authored on 2011-06-21
2459
=item C<bind_type>
cleanup
yuki-kimoto authored on 2010-10-17
2460

            
updated pod
Yuki Kimoto authored on 2011-06-21
2461
Same as C<execute> method's C<bind_type> option.
cleanup
yuki-kimoto authored on 2010-10-17
2462

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2463
=item C<type_rule_off> EXPERIMENTAL
2464

            
updated document
Yuki Kimoto authored on 2011-06-09
2465
Same as C<execute> method's C<type_rule_off> option.
update pod
Yuki Kimoto authored on 2011-03-13
2466

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2467
=item C<type_rule1_off> EXPERIMENTAL
2468

            
2469
    type_rule1_off => 1
2470

            
2471
Same as C<execute> method's C<type_rule1_off> option.
2472

            
2473
=item C<type_rule2_off> EXPERIMENTAL
2474

            
2475
    type_rule2_off => 1
2476

            
2477
Same as C<execute> method's C<type_rule2_off> option.
2478

            
update pod
Yuki Kimoto authored on 2011-03-13
2479
=back
2480

            
2481
=over 4
2482

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2483
=head2 C<insert_param>
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2484

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2485
    my $insert_param = $dbi->insert_param({title => 'a', age => 2});
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2486

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2487
Create insert parameters.
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2488

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2489
    (title, author) values (title = :title, age = :age);
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2490

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2498
    lib / MyModel.pm
2499
        / MyModel / book.pm
2500
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2501

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

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

            
2506
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2507
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2508
    
2509
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2510

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2515
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2516
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2517
    
2518
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2519

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2522
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2523
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2524
    
2525
    1;
2526
    
updated pod
Yuki Kimoto authored on 2011-06-21
2527
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2528

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

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

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

            
added EXPERIMENTAL map_param...
Yuki Kimoto authored on 2011-06-24
2536
=head2 C<map_param> EXPERIMENTAL
2537

            
2538
    my $map_param = $dbi->map_param(
2539
        {id => 1, authro => 'Ken', price => 1900},
2540
        'id' => 'book.id',
2541
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2542
        'price' => [
2543
            'book.price', {if => sub { length $_[0] }}
2544
        ]
2545
    );
2546

            
2547
Map paramters to other key and value. First argument is original
2548
parameter. this is hash reference. Rest argument is mapping.
2549
By default, Mapping is done if the value length is not zero.
2550

            
2551
=over 4
2552

            
2553
=item Key mapping
2554

            
2555
    'id' => 'book.id'
2556

            
2557
This is only key mapping. Value is same as original one.
2558

            
2559
    (id => 1) is mapped to ('book.id' => 1) if value length is not zero.
2560

            
2561
=item Key and value mapping
2562

            
2563
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2564

            
2565
This is key and value mapping. Frist element of array reference
2566
is mapped key name, second element is code reference to map the value.
2567

            
2568
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2569
      if value length is not zero.
2570

            
2571
=item Condition
2572

            
2573
    'price' => ['book.price', {if => 'exists'}]
2574
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2575
    'price' => ['book.price', {if => sub { defined shift }}]
2576

            
2577
If you need condition, you can sepecify it. this is code reference
2578
or 'exists'. By default, condition is the following one.
2579

            
2580
    sub { defined $_[0] && length $_[0] }
2581

            
2582
=back
2583

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

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

            
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
2588
Merge parameters.
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2589

            
2590
    {key1 => [1, 1], key2 => 2}
2591

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2592
=head2 C<method>
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2593

            
2594
    $dbi->method(
2595
        update_or_insert => sub {
2596
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2597
            
2598
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2599
        },
2600
        find_or_create   => sub {
2601
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2602
            
2603
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2604
        }
2605
    );
2606

            
update pod
Yuki Kimoto authored on 2011-03-13
2607
Register method. These method is called directly from L<DBIx::Custom> object.
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2608

            
2609
    $dbi->update_or_insert;
2610
    $dbi->find_or_create;
2611

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

            
2614
    my $model = $dbi->model('book');
2615

            
updated pod
Yuki Kimoto authored on 2011-06-21
2616
Get a L<DBIx::Custom::Model> object,
update pod
Yuki Kimoto authored on 2011-03-13
2617

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

            
2620
    my $column = $self->mycolumn(book => ['author', 'title']);
2621

            
2622
Create column clause for myself. The follwoing column clause is created.
2623

            
2624
    book.author as author,
2625
    book.title as title
2626

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2629
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2630
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2631
        user => 'ken',
2632
        password => '!LFKD%$&',
2633
        dbi_option => {mysql_enable_utf8 => 1}
2634
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2635

            
2636
Create a new L<DBIx::Custom> object.
2637

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

            
2640
    my $not_exists = $dbi->not_exists;
2641

            
update pod
Yuki Kimoto authored on 2011-03-13
2642
DBIx::Custom::NotExists object, indicating the column is not exists.
2643
This is used by C<clause> of L<DBIx::Custom::Where> .
experimental extended select...
Yuki Kimoto authored on 2011-01-17
2644

            
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
2645
=head2 C<order> EXPERIMENTAL
2646

            
2647
    my $order = $dbi->order;
2648

            
2649
Create a new L<DBIx::Custom::Order> object.
2650

            
cleanup
yuki-kimoto authored on 2010-10-17
2651
=head2 C<register_filter>
2652

            
update pod
Yuki Kimoto authored on 2011-03-13
2653
    $dbi->register_filter(
2654
        # Time::Piece object to database DATE format
2655
        tp_to_date => sub {
2656
            my $tp = shift;
2657
            return $tp->strftime('%Y-%m-%d');
2658
        },
2659
        # database DATE format to Time::Piece object
2660
        date_to_tp => sub {
2661
           my $date = shift;
2662
           return Time::Piece->strptime($date, '%Y-%m-%d');
2663
        }
2664
    );
cleanup
yuki-kimoto authored on 2010-10-17
2665
    
update pod
Yuki Kimoto authored on 2011-03-13
2666
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2667

            
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2668
=head2 C<type_rule> EXPERIMENTAL
2669

            
2670
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2671
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2672
            date => sub { ... },
2673
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2674
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2675
        into2 => {
2676
            date => sub { ... },
2677
            datetime => sub { ... }
2678
        },
2679
        from1 => {
2680
            # DATE
2681
            9 => sub { ... },
2682
            # DATETIME or TIMESTAMP
2683
            11 => sub { ... },
2684
        }
2685
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2686
            # DATE
2687
            9 => sub { ... },
2688
            # DATETIME or TIMESTAMP
2689
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2690
        }
2691
    );
2692

            
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2693
Filtering rule when data is send into and get from database.
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2694
This has a little complex problem.
cleanup
Yuki Kimoto authored on 2011-06-13
2695

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2696
In C<into1> and C<into2> you can specify
2697
type name as same as type name defined
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2698
by create table, such as C<DATETIME> or C<DATE>.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2699

            
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2700
Note that type name and data type don't contain upper case.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2701
If these contain upper case charactor, you convert it to lower case.
2702

            
updated pod
Yuki Kimoto authored on 2011-06-21
2703
C<into2> is executed after C<into1>.
2704

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2705
Type rule of C<into1> and C<into2> is enabled on the following
2706
column name.
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2707

            
cleanup
Yuki Kimoto authored on 2011-06-13
2708
=over 4
2709

            
2710
=item 1. column name
2711

            
2712
    issue_date
2713
    issue_datetime
2714

            
updated pod
Yuki Kimoto authored on 2011-06-21
2715
This need C<table> option in each method.
2716

            
cleanup
Yuki Kimoto authored on 2011-06-13
2717
=item 2. table name and column name, separator is dot
2718

            
2719
    book.issue_date
2720
    book.issue_datetime
2721

            
2722
=back
2723

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2724
You get all type name used in database by C<available_typename>.
update pod
Yuki Kimoto authored on 2011-06-15
2725

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2726
    print $dbi->available_typename;
update pod
Yuki Kimoto authored on 2011-06-15
2727

            
updated pod
Yuki Kimoto authored on 2011-06-21
2728
In C<from1> and C<from2> you specify data type, not type name.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2729
C<from2> is executed after C<from1>.
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2730
You get all data type by C<available_datatype>.
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2731

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

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2734
You can also specify multiple types at once.
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2735

            
2736
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2737
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2738
            [qw/DATE DATETIME/] => sub { ... },
2739
        ],
2740
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2741

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2744
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2745
        table  => 'book',
2746
        column => ['author', 'title'],
2747
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2748
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2749
    
updated document
Yuki Kimoto authored on 2011-06-09
2750
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2751

            
updated document
Yuki Kimoto authored on 2011-06-09
2752
The following opitons are available.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2753

            
2754
=over 4
2755

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2758
    append => 'order by title'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2759

            
updated document
Yuki Kimoto authored on 2011-06-09
2760
Append statement to last of SQL.
2761
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2762
=item C<column>
2763
    
updated document
Yuki Kimoto authored on 2011-06-09
2764
    column => 'author'
2765
    column => ['author', 'title']
2766

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2775
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2776
        {book => [qw/author title/]},
2777
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2778
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2779

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

            
2782
    book.author as "book.author",
2783
    book.title as "book.title",
2784
    person.name as "person.name",
2785
    person.age as "person.age"
2786

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

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

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

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

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

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

            
2802
=item C<id>
2803

            
2804
    id => 4
2805
    id => [4, 5]
2806

            
2807
ID corresponding to C<primary_key>.
2808
You can select rows by C<id> and C<primary_key>.
2809

            
2810
    $dbi->select(
2811
        parimary_key => ['id1', 'id2'],
2812
        id => [4, 5],
2813
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2814
    );
2815

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
2818
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
2819
        where => {id1 => 4, id2 => 5},
2820
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2821
    );
2822
    
updated document
Yuki Kimoto authored on 2011-06-09
2823
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2824

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

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

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

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

            
2837
    prefix => 'SQL_CALC_FOUND_ROWS'
2838

            
2839
Prefix of column cluase
2840

            
2841
    select SQL_CALC_FOUND_ROWS title, author from book;
2842

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

            
2845
    join => [
2846
        'left outer join company on book.company_id = company_id',
2847
        'left outer join location on company.location_id = location.id'
2848
    ]
2849
        
2850
Join clause. If column cluase or where clause contain table name like "company.name",
2851
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
2852

            
2853
    $dbi->select(
2854
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2855
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2856
        where => {'company.name' => 'Orange'},
2857
        join => [
2858
            'left outer join company on book.company_id = company.id',
2859
            'left outer join location on company.location_id = location.id'
2860
        ]
2861
    );
2862

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2866
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2867
    from book
2868
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2869
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2870

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
2871
You can specify two table by yourself. This is useful when join parser can't parse
cleanup
Yuki Kimoto authored on 2011-07-28
2872
the join clause correctly. This is EXPERIMENTAL.
added join new syntax
Yuki Kimoto authored on 2011-07-28
2873

            
2874
    $dbi->select(
2875
        table => 'book',
2876
        column => ['company.location_id as location_id'],
2877
        where => {'company.name' => 'Orange'},
2878
        join => [
2879
            {
2880
                clause => 'left outer join location on company.location_id = location.id',
2881
                table => ['company', 'location']
2882
            }
2883
        ]
2884
    );
2885

            
updated document
Yuki Kimoto authored on 2011-06-09
2886
=item C<primary_key>
added EXPERIMENTAL replace()...
Yuki Kimoto authored on 2011-04-01
2887

            
updated document
Yuki Kimoto authored on 2011-06-09
2888
    primary_key => 'id'
2889
    primary_key => ['id1', 'id2']
added EXPERIMENTAL replace()...
Yuki Kimoto authored on 2011-04-01
2890

            
updated document
Yuki Kimoto authored on 2011-06-09
2891
Primary key. This is used by C<id> option.
added EXPERIMENTAL replace()...
Yuki Kimoto authored on 2011-04-01
2892

            
updated document
Yuki Kimoto authored on 2011-06-09
2893
=item C<query>
update pod
Yuki Kimoto authored on 2011-03-12
2894

            
updated document
Yuki Kimoto authored on 2011-06-09
2895
Same as C<execute> method's C<query> option.
update pod
Yuki Kimoto authored on 2011-03-12
2896

            
updated pod
Yuki Kimoto authored on 2011-06-21
2897
=item C<bind_type>
updated pod
Yuki Kimoto authored on 2011-06-08
2898

            
cleanup
Yuki Kimoto authored on 2011-07-28
2899
Same as C<execute> method's C<bind_type> option.
updated pod
Yuki Kimoto authored on 2011-06-08
2900

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2905
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2906

            
updated document
Yuki Kimoto authored on 2011-06-09
2907
=item C<type_rule_off> EXPERIMENTAL
updated pod
Yuki Kimoto authored on 2011-06-08
2908

            
updated document
Yuki Kimoto authored on 2011-06-09
2909
Same as C<execute> method's C<type_rule_off> option.
updated pod
Yuki Kimoto authored on 2011-06-08
2910

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2911
=item C<type_rule1_off> EXPERIMENTAL
2912

            
2913
    type_rule1_off => 1
2914

            
2915
Same as C<execute> method's C<type_rule1_off> option.
2916

            
2917
=item C<type_rule2_off> EXPERIMENTAL
2918

            
2919
    type_rule2_off => 1
2920

            
2921
Same as C<execute> method's C<type_rule2_off> option.
2922

            
updated document
Yuki Kimoto authored on 2011-06-09
2923
=item C<where>
2924
    
2925
    # Hash refrence
2926
    where => {author => 'Ken', 'title' => 'Perl'}
2927
    
2928
    # DBIx::Custom::Where object
2929
    where => $dbi->where(
2930
        clause => ['and', 'author = :author', 'title like :title'],
2931
        param  => {author => 'Ken', title => '%Perl%'}
2932
    );
updated pod
Yuki Kimoto authored on 2011-06-21
2933
    
2934
    # Array reference 1 (array reference, hash referenc). same as above
2935
    where => [
2936
        ['and', 'author = :author', 'title like :title'],
2937
        {author => 'Ken', title => '%Perl%'}
2938
    ];    
2939
    
2940
    # Array reference 2 (String, hash reference)
2941
    where => [
2942
        'title like :title',
2943
        {title => '%Perl%'}
2944
    ]
2945
    
2946
    # String
2947
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
2948

            
updated document
Yuki Kimoto authored on 2011-06-09
2949
Where clause.
2950
    
improved pod
Yuki Kimoto authored on 2011-04-19
2951
=item C<wrap> EXPERIMENTAL
2952

            
2953
Wrap statement. This is array reference.
2954

            
2955
    $dbi->select(wrap => ['select * from (', ') as t where ROWNUM < 10']);
2956

            
2957
This option is for Oracle and SQL Server paging process.
2958

            
update pod
Yuki Kimoto authored on 2011-03-12
2959
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2960

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

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

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

            
2967
If you want to set constant value to row data, use scalar reference
2968
as parameter value.
2969

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2972
The following opitons are available.
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2973

            
update pod
Yuki Kimoto authored on 2011-03-13
2974
=over 4
2975

            
updated document
Yuki Kimoto authored on 2011-06-09
2976
=item C<append>
update pod
Yuki Kimoto authored on 2011-03-13
2977

            
updated document
Yuki Kimoto authored on 2011-06-09
2978
Same as C<select> method's C<append> option.
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2979

            
updated document
Yuki Kimoto authored on 2011-06-09
2980
=item C<filter>
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2981

            
updated document
Yuki Kimoto authored on 2011-06-09
2982
Same as C<execute> method's C<filter> option.
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2983

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2986
    id => 4
2987
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2988

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2992
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
2993
        {title => 'Perl', author => 'Ken'}
2994
        parimary_key => ['id1', 'id2'],
2995
        id => [4, 5],
2996
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2997
    );
update pod
Yuki Kimoto authored on 2011-03-13
2998

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3001
    $dbi->update(
3002
        {title => 'Perl', author => 'Ken'}
3003
        where => {id1 => 4, id2 => 5},
3004
        table => 'book'
3005
    );
update pod
Yuki Kimoto authored on 2011-03-13
3006

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

            
3009
    prefix => 'or replace'
3010

            
3011
prefix before table name section
3012

            
3013
    update or replace book
3014

            
updated document
Yuki Kimoto authored on 2011-06-09
3015
=item C<primary_key>
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
3016

            
updated document
Yuki Kimoto authored on 2011-06-09
3017
    primary_key => 'id'
3018
    primary_key => ['id1', 'id2']
update pod
Yuki Kimoto authored on 2011-03-13
3019

            
updated document
Yuki Kimoto authored on 2011-06-09
3020
Primary key. This is used by C<id> option.
update pod
Yuki Kimoto authored on 2011-03-13
3021

            
updated document
Yuki Kimoto authored on 2011-06-09
3022
=item C<query>
update pod
Yuki Kimoto authored on 2011-03-13
3023

            
updated document
Yuki Kimoto authored on 2011-06-09
3024
Same as C<execute> method's C<query> option.
update pod
Yuki Kimoto authored on 2011-03-13
3025

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3032
=item C<where>
update pod
Yuki Kimoto authored on 2011-03-13
3033

            
updated document
Yuki Kimoto authored on 2011-06-09
3034
Same as C<select> method's C<where> option.
update pod
Yuki Kimoto authored on 2011-03-13
3035

            
updated pod
Yuki Kimoto authored on 2011-06-21
3036
=item C<bind_type>
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
3037

            
cleanup
Yuki Kimoto authored on 2011-07-28
3038
Same as C<execute> method's C<bind_type> option.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
3039

            
3040
=item C<type_rule_off> EXPERIMENTAL
3041

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3042
Same as C<execute> method's C<type_rule_off> option.
3043

            
3044
=item C<type_rule1_off> EXPERIMENTAL
3045

            
3046
    type_rule1_off => 1
3047

            
3048
Same as C<execute> method's C<type_rule1_off> option.
3049

            
3050
=item C<type_rule2_off> EXPERIMENTAL
3051

            
3052
    type_rule2_off => 1
3053

            
3054
Same as C<execute> method's C<type_rule2_off> option.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
3055

            
updated pod
Yuki Kimoto authored on 2011-06-08
3056
=back
update pod
Yuki Kimoto authored on 2011-03-13
3057

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

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3065
=head2 C<update_param>
update pod
Yuki Kimoto authored on 2011-03-13
3066

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3067
    my $update_param = $dbi->update_param({title => 'a', age => 2});
update pod
Yuki Kimoto authored on 2011-03-13
3068

            
3069
Create update parameter tag.
3070

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3071
    set title = :title, author = :author
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
3072

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
3073
=head2 C<where>
fix tests
Yuki Kimoto authored on 2011-01-18
3074

            
cleanup
Yuki Kimoto authored on 2011-03-09
3075
    my $where = $dbi->where(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3076
        clause => ['and', 'title = :title', 'author = :author'],
cleanup
Yuki Kimoto authored on 2011-03-09
3077
        param => {title => 'Perl', author => 'Ken'}
3078
    );
fix tests
Yuki Kimoto authored on 2011-01-18
3079

            
3080
Create a new L<DBIx::Custom::Where> object.
3081

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
3082
=head2 C<setup_model>
cleanup
Yuki Kimoto authored on 2011-01-12
3083

            
update pod
Yuki Kimoto authored on 2011-03-13
3084
    $dbi->setup_model;
cleanup
Yuki Kimoto authored on 2011-01-12
3085

            
update pod
Yuki Kimoto authored on 2011-03-13
3086
Setup all model objects.
update pod
Yuki Kimoto authored on 2011-03-13
3087
C<columns> of model object is automatically set, parsing database information.
cleanup
Yuki Kimoto authored on 2011-01-12
3088

            
added environment variable D...
Yuki Kimoto authored on 2011-04-02
3089
=head1 ENVIRONMENT VARIABLE
3090

            
3091
=head2 C<DBIX_CUSTOM_DEBUG>
3092

            
3093
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
improved debug message
Yuki Kimoto authored on 2011-05-23
3094
executed SQL and bind values are printed to STDERR.
3095

            
3096
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3097

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

            
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3100
=head1 DEPRECATED FUNCTIONALITIES
3101

            
3102
L<DBIx::Custom>
3103

            
3104
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3105
    data_source # will be removed at 2017/1/1
3106
    dbi_options # will be removed at 2017/1/1
3107
    filter_check # will be removed at 2017/1/1
3108
    reserved_word_quote # will be removed at 2017/1/1
3109
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3110
    
3111
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3112
    create_query # will be removed at 2017/1/1
3113
    apply_filter # will be removed at 2017/1/1
3114
    select_at # will be removed at 2017/1/1
3115
    delete_at # will be removed at 2017/1/1
3116
    update_at # will be removed at 2017/1/1
3117
    insert_at # will be removed at 2017/1/1
3118
    register_tag # will be removed at 2017/1/1
3119
    default_bind_filter # will be removed at 2017/1/1
3120
    default_fetch_filter # will be removed at 2017/1/1
3121
    insert_param_tag # will be removed at 2017/1/1
3122
    register_tag_processor # will be removed at 2017/1/1
3123
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3124
    
3125
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3126
    select method relation option # will be removed at 2017/1/1
3127
    select method param option # will be removed at 2017/1/1
3128
    select method column option [COLUMN, as => ALIAS] format
3129
      # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3130
    
3131
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3132
    execute("select * from {= title}"); # execute method's
3133
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3134
                                        # will be removed at 2017/1/1
3135
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3136

            
3137
L<DBIx::Custom::Model>
3138

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3139
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3140
    filter # will be removed at 2017/1/1
3141
    name # will be removed at 2017/1/1
3142
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3143

            
3144
L<DBIx::Custom::Query>
3145
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3146
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3147
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3148
    table # will be removed at 2017/1/1
3149
    filters # will be removed at 2017/1/1
3150
    
3151
    # Methods
3152
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3153

            
3154
L<DBIx::Custom::QueryBuilder>
3155
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3156
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3157
    tags # will be removed at 2017/1/1
3158
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3159
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3160
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3161
    register_tag # will be removed at 2017/1/1
3162
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3163
    
3164
    # Others
3165
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3166
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3167

            
3168
L<DBIx::Custom::Result>
3169
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3170
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3171
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3172
    
3173
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3174
    end_filter # will be removed at 2017/1/1
3175
    remove_end_filter # will be removed at 2017/1/1
3176
    remove_filter # will be removed at 2017/1/1
3177
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3178

            
3179
L<DBIx::Custom::Tag>
3180

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

            
3183
=head1 BACKWORD COMPATIBLE POLICY
3184

            
3185
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3186
except for attribute method.
3187
You can check all DEPRECATED functionalities by document.
3188
DEPRECATED functionality is removed after five years,
3189
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
3190
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3191

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

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3194
This policy was changed at 2011/6/28
DBIx::Custom is now stable
yuki-kimoto authored on 2010-09-07
3195

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

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

            
3200
C<< <kimoto.yuki at gmail.com> >>
3201

            
3202
L<http://github.com/yuki-kimoto/DBIx-Custom>
3203

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3204
=head1 AUTHOR
3205

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

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

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

            
3212
This program is free software; you can redistribute it and/or modify it
3213
under the same terms as Perl itself.
3214

            
3215
=cut