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

            
- removed some EXPERIMENTAL ...
Yuki Kimoto authored on 2011-07-30
4
our $VERSION = '0.1707';
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
    query_builder => sub { DBIx::Custom::QueryBuilder->new },
55
    result_class  => 'DBIx::Custom::Result',
56
    safety_character => '\w',
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

            
added helper method
yuki-kimoto authored on 2010-10-17
60
our $AUTOLOAD;
61
sub AUTOLOAD {
62
    my $self = shift;
63

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
67
    # Call method
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
68
    $self->{_methods} ||= {};
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
69
    if (my $method = $self->{_methods}->{$mname}) {
70
        return $self->$method(@_)
71
    }
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
72
    elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
73
        $self->dbh->$dbh_method(@_);
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
74
    }
75
    else {
cleanup
Yuki Kimoto authored on 2011-04-25
76
        croak qq{Can't locate object method "$mname" via "$package" }
77
            . _subname;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
78
    }
added helper method
yuki-kimoto authored on 2010-10-17
79
}
80

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
81
sub assign_param {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
82
    my ($self, $param) = @_;
83
    
84
    # Create set tag
85
    my @params;
86
    my $safety = $self->safety_character;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
87
    foreach my $column (sort keys %$param) {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
88
        croak qq{"$column" is not safety column name } . _subname
89
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
90
        my $column_quote = $self->_q($column);
91
        $column_quote =~ s/\./$self->_q(".")/e;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
92
        push @params, ref $param->{$column} eq 'SCALAR'
93
          ? "$column_quote = " . ${$param->{$column}}
94
          : "$column_quote = :$column";
95

            
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
96
    }
97
    my $tag = join(', ', @params);
98
    
99
    return $tag;
100
}
101

            
cleanup
Yuki Kimoto authored on 2011-03-21
102
sub column {
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
103
    my $self = shift;
104
    my $option = pop if ref $_[-1] eq 'HASH';
105
    my $real_table = shift;
106
    my $columns = shift;
107
    my $table = $option->{alias} || $real_table;
108
    
109
    # Columns
110
    unless ($columns) {
111
        $columns ||= $self->model($real_table)->columns;
112
    }
added helper method
yuki-kimoto authored on 2010-10-17
113
    
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
114
    # Separator
115
    my $separator = $self->separator;
116
    
cleanup
Yuki Kimoto authored on 2011-04-02
117
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-21
118
    my @column;
cleanup
Yuki Kimoto authored on 2011-04-02
119
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
120
    push @column, $self->_q($table) . "." . $self->_q($_) .
121
      " as " . $self->_q("${table}${separator}$_")
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
122
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
123
    
124
    return join (', ', @column);
added helper method
yuki-kimoto authored on 2010-10-17
125
}
126

            
packaging one directory
yuki-kimoto authored on 2009-11-16
127
sub connect {
cleanup
Yuki Kimoto authored on 2011-01-25
128
    my $self = ref $_[0] ? shift : shift->new(@_);;
removed register_format()
yuki-kimoto authored on 2010-05-26
129
    
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
130
    # Connect
131
    $self->dbh;
update document
yuki-kimoto authored on 2010-01-30
132
    
packaging one directory
yuki-kimoto authored on 2009-11-16
133
    return $self;
134
}
135

            
update pod
Yuki Kimoto authored on 2011-03-13
136
sub dbh {
137
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-04-02
138
    
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
139
    # Set
140
    if (@_) {
141
        $self->{dbh} = $_[0];
142
        
143
        return $self;
144
    }
145
    
146
    # Get
147
    else {
148
        # From Connction manager
149
        if (my $connector = $self->connector) {
cleanup
Yuki Kimoto authored on 2011-04-25
150
            croak "connector must have dbh() method " . _subname
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
151
              unless ref $connector && $connector->can('dbh');
152
              
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
153
            $self->{dbh} = $connector->dbh;
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
154
        }
155
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
156
        # Connect
157
        $self->{dbh} ||= $self->_connect;
158
        
159
        # Quote
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
160
        if (!defined $self->reserved_word_quote && !defined $self->quote) {
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
161
            my $driver = $self->{dbh}->{Driver}->{Name};
162
            my $quote = $driver eq 'mysql' ? '`' : '"';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
163
            $self->quote($quote);
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
164
        }
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
165
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
166
        return $self->{dbh};
update pod
Yuki Kimoto authored on 2011-03-13
167
    }
168
}
169

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

            
cleanup update and update_al...
yuki-kimoto authored on 2010-04-28
173
    # Arguments
cleanup
Yuki Kimoto authored on 2011-03-21
174
    my $table = $args{table} || '';
cleanup
Yuki Kimoto authored on 2011-04-25
175
    croak qq{"table" option must be specified. } . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
176
      unless $table;
cleanup
Yuki Kimoto authored on 2011-03-21
177
    my $where            = delete $args{where} || {};
178
    my $append           = delete $args{append};
179
    my $allow_delete_all = delete $args{allow_delete_all};
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
180
    my $where_param      = delete $args{where_param} || {};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
181
    my $id = delete $args{id};
182
    my $primary_key = delete $args{primary_key};
183
    croak "update method primary_key option " .
184
          "must be specified when id is specified " . _subname
185
      if defined $id && !defined $primary_key;
186
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
187
    my $prefix = delete $args{prefix};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
188
    
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
189
    # Where
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
190
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
191
    my $where_clause = '';
updated pod
Yuki Kimoto authored on 2011-06-21
192
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
193
        $where_clause = "where " . $where->[0];
194
        $where_param = $where->[1];
195
    }
196
    elsif (ref $where) {
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
197
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
198
        $where_param = keys %$where_param
199
                     ? $self->merge_param($where_param, $where->param)
200
                     : $where->param;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
201
        
202
        # String where
203
        $where_clause = $where->to_string;
204
    }
205
    elsif ($where) { $where_clause = "where $where" }
cleanup
Yuki Kimoto authored on 2011-04-25
206
    croak qq{"where" must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
207
      if $where_clause eq '' && !$allow_delete_all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
208

            
cleanup
Yuki Kimoto authored on 2011-04-02
209
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-01-27
210
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
211
    push @sql, "delete";
212
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
213
    push @sql, "from " . $self->_q($table) . " $where_clause";
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
214
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
215
    my $sql = join(' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
216
    
217
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
218
    return $self->execute($sql, $where_param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
219
}
220

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

            
added helper method
yuki-kimoto authored on 2010-10-17
223
sub DESTROY { }
224

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
225
sub create_model {
226
    my $self = shift;
227
    
cleanup
Yuki Kimoto authored on 2011-04-02
228
    # Arguments
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
229
    my $args = ref $_[0] eq 'HASH' ? $_[0] : {@_};
230
    $args->{dbi} = $self;
231
    my $model_class = delete $args->{model_class} || 'DBIx::Custom::Model';
232
    my $model_name  = delete $args->{name};
233
    my $model_table = delete $args->{table};
234
    $model_name ||= $model_table;
235
    
cleanup
Yuki Kimoto authored on 2011-04-02
236
    # Create model
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
237
    my $model = $model_class->new($args);
238
    $model->name($model_name) unless $model->name;
239
    $model->table($model_table) unless $model->table;
240
    
micro optimization
Yuki Kimoto authored on 2011-07-30
241
    # Apply filter(DEPRECATED logic)
242
    if ($model->{filter}) {
243
        my $filter = ref $model->filter eq 'HASH'
244
                   ? [%{$model->filter}]
245
                   : $model->filter;
246
        $filter ||= [];
247
        warn "DBIx::Custom::Model filter method is DEPRECATED!"
248
          if @$filter;
249
        $self->_apply_filter($model->table, @$filter);
250
    }
251
    
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
252
    # Set model
253
    $self->model($model->name, $model);
254
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
255
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
256
}
257

            
258
sub each_column {
259
    my ($self, $cb) = @_;
260
    
261
    # Iterate all tables
262
    my $sth_tables = $self->dbh->table_info;
263
    while (my $table_info = $sth_tables->fetchrow_hashref) {
264
        
265
        # Table
266
        my $table = $table_info->{TABLE_NAME};
267
        
268
        # Iterate all columns
269
        my $sth_columns = $self->dbh->column_info(undef, undef, $table, '%');
270
        while (my $column_info = $sth_columns->fetchrow_hashref) {
271
            my $column = $column_info->{COLUMN_NAME};
272
            $self->$cb($table, $column, $column_info);
273
        }
274
    }
275
}
276

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
277
sub each_table {
278
    my ($self, $cb) = @_;
279
    
280
    # Iterate all tables
281
    my $sth_tables = $self->dbh->table_info;
282
    while (my $table_info = $sth_tables->fetchrow_hashref) {
283
        
284
        # Table
285
        my $table = $table_info->{TABLE_NAME};
286
        $self->$cb($table, $table_info);
287
    }
288
}
289

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

            
295
sub execute {
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
296
    my $self = shift;
297
    my $query = shift;
298
    my $param;
299
    $param = shift if @_ % 2;
300
    my %args = @_;
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
301
    
cleanup
Yuki Kimoto authored on 2011-04-02
302
    # Arguments
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
303
    my $p = delete $args{param} || {};
304
    $param ||= $p;
cleanup
Yuki Kimoto authored on 2011-04-02
305
    my $tables = delete $args{table} || [];
306
    $tables = [$tables] unless ref $tables eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-04-02
307
    my $filter = delete $args{filter};
cleanup
Yuki Kimoto authored on 2011-04-25
308
    $filter = _array_to_hash($filter);
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
309
    my $bind_type = delete $args{bind_type} || delete $args{type};
310
    $bind_type = _array_to_hash($bind_type);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
311
    my $type_rule_off = delete $args{type_rule_off};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
312
    my $type_rule_off_parts = {
313
        1 => delete $args{type_rule1_off},
314
        2 => delete $args{type_rule2_off}
315
    };
cleanup
Yuki Kimoto authored on 2011-06-09
316
    my $query_return = delete $args{query};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
317
    my $table_alias = delete $args{table_alias} || {};
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
318
    
cleanup
Yuki Kimoto authored on 2011-03-09
319
    # Check argument names
select, insert, update, upda...
yuki-kimoto authored on 2010-06-14
320
    foreach my $name (keys %args) {
cleanup
Yuki Kimoto authored on 2011-04-25
321
        croak qq{"$name" is wrong option } . _subname
simplified arguments check
Yuki Kimoto authored on 2011-07-11
322
          unless $VALID_ARGS{$name};
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
323
    }
324
    
cleanup
Yuki Kimoto authored on 2011-04-02
325
    # Create query
updated pod
Yuki Kimoto authored on 2011-06-21
326
    $query = $self->_create_query($query) unless ref $query;
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
327
    
328
    # Save query
329
    $self->last_sql($query->sql);
330

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

            
459
        return $result;
460
    }
cleanup
Yuki Kimoto authored on 2011-04-02
461
    
462
    # Not select statement
463
    else { return $affected }
cleanup
yuki-kimoto authored on 2010-10-17
464
}
465

            
466
sub insert {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
467
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
468
    
cleanup
yuki-kimoto authored on 2010-10-17
469
    # Arguments
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
470
    my $param;
471
    $param = shift if @_ % 2;
472
    my %args = @_;
cleanup
Yuki Kimoto authored on 2011-03-21
473
    my $table  = delete $args{table};
cleanup
Yuki Kimoto authored on 2011-04-25
474
    croak qq{"table" option must be specified } . _subname
simplified arguments check
Yuki Kimoto authored on 2011-07-11
475
      unless defined $table;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
476
    my $p = delete $args{param} || {};
477
    $param  ||= $p;
cleanup
Yuki Kimoto authored on 2011-03-21
478
    my $append = delete $args{append} || '';
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
479
    my $id = delete $args{id};
480
    my $primary_key = delete $args{primary_key};
cleanup
Yuki Kimoto authored on 2011-06-08
481
    croak "insert method primary_key option " .
added tests
Yuki Kimoto authored on 2011-06-08
482
          "must be specified when id is specified " . _subname
483
      if defined $id && !defined $primary_key;
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
484
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
485
    my $prefix = delete $args{prefix};
cleanup
Yuki Kimoto authored on 2011-04-02
486

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
487
    # Merge parameter
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
488
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
489
        my $id_param = $self->_create_param_from_id($id, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
490
        $param = $self->merge_param($id_param, $param);
491
    }
492

            
cleanup
Yuki Kimoto authored on 2011-04-02
493
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-01-27
494
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
495
    push @sql, "insert";
496
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
497
    push @sql, "into " . $self->_q($table) . " " . $self->insert_param($param);
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
498
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
499
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
500
    
501
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
502
    return $self->execute($sql, $param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
503
}
504

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
505
sub insert_param {
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
506
    my ($self, $param) = @_;
507
    
cleanup
Yuki Kimoto authored on 2011-04-02
508
    # Create insert parameter tag
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
509
    my $safety = $self->safety_character;
cleanup
Yuki Kimoto authored on 2011-04-02
510
    my @columns;
511
    my @placeholders;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
512
    foreach my $column (sort keys %$param) {
cleanup
Yuki Kimoto authored on 2011-04-25
513
        croak qq{"$column" is not safety column name } . _subname
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
514
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
515
        my $column_quote = $self->_q($column);
516
        $column_quote =~ s/\./$self->_q(".")/e;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
517
        push @columns, $column_quote;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
518
        push @placeholders, ref $param->{$column} eq 'SCALAR'
519
          ? ${$param->{$column}} : ":$column";
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
520
    }
521
    
cleanup
Yuki Kimoto authored on 2011-04-02
522
    return '(' . join(', ', @columns) . ') ' . 'values ' .
523
           '(' . join(', ', @placeholders) . ')'
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
524
}
525

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
526
sub include_model {
527
    my ($self, $name_space, $model_infos) = @_;
528
    
cleanup
Yuki Kimoto authored on 2011-04-02
529
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
530
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
531
    
532
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
533
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
534

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
535
        # Load name space module
cleanup
Yuki Kimoto authored on 2011-04-25
536
        croak qq{"$name_space" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
537
          if $name_space =~ /[^\w:]/;
538
        eval "use $name_space";
cleanup
Yuki Kimoto authored on 2011-04-25
539
        croak qq{Name space module "$name_space.pm" is needed. $@ }
540
            . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
541
          if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
542
        
543
        # Search model modules
544
        my $path = $INC{"$name_space.pm"};
545
        $path =~ s/\.pm$//;
546
        opendir my $dh, $path
cleanup
Yuki Kimoto authored on 2011-04-25
547
          or croak qq{Can't open directory "$path": $! } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
548
        $model_infos = [];
549
        while (my $module = readdir $dh) {
550
            push @$model_infos, $module
551
              if $module =~ s/\.pm$//;
552
        }
553
        close $dh;
554
    }
555
    
cleanup
Yuki Kimoto authored on 2011-04-02
556
    # Include models
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
557
    foreach my $model_info (@$model_infos) {
558
        
cleanup
Yuki Kimoto authored on 2011-04-02
559
        # Load model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
560
        my $model_class;
561
        my $model_name;
562
        my $model_table;
563
        if (ref $model_info eq 'HASH') {
564
            $model_class = $model_info->{class};
565
            $model_name  = $model_info->{name};
566
            $model_table = $model_info->{table};
567
            
568
            $model_name  ||= $model_class;
569
            $model_table ||= $model_name;
570
        }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
571
        else { $model_class = $model_name = $model_table = $model_info }
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
572
        my $mclass = "${name_space}::$model_class";
cleanup
Yuki Kimoto authored on 2011-04-25
573
        croak qq{"$mclass" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
574
          if $mclass =~ /[^\w:]/;
575
        unless ($mclass->can('isa')) {
576
            eval "use $mclass";
cleanup
Yuki Kimoto authored on 2011-04-25
577
            croak "$@ " . _subname if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
578
        }
579
        
cleanup
Yuki Kimoto authored on 2011-04-02
580
        # Create model
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
581
        my $args = {};
582
        $args->{model_class} = $mclass if $mclass;
583
        $args->{name}        = $model_name if $model_name;
584
        $args->{table}       = $model_table if $model_table;
585
        $self->create_model($args);
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
586
    }
587
    
588
    return $self;
589
}
590

            
added EXPERIMENTAL map_param...
Yuki Kimoto authored on 2011-06-24
591
sub map_param {
592
    my $self = shift;
593
    my $param = shift;
594
    my %map = @_;
595
    
596
    # Mapping
597
    my $map_param = {};
598
    foreach my $key (keys %map) {
599
        my $value_cb;
600
        my $condition;
601
        my $map_key;
602
        
603
        # Get mapping information
604
        if (ref $map{$key} eq 'ARRAY') {
605
            foreach my $some (@{$map{$key}}) {
606
                $map_key = $some unless ref $some;
607
                $condition = $some->{if} if ref $some eq 'HASH';
608
                $value_cb = $some if ref $some eq 'CODE';
609
            }
610
        }
611
        else {
612
            $map_key = $map{$key};
613
        }
614
        $value_cb ||= sub { $_[0] };
615
        $condition ||= sub { defined $_[0] && length $_[0] };
616

            
617
        # Map parameter
618
        my $value;
619
        if (ref $condition eq 'CODE') {
620
            $map_param->{$map_key} = $value_cb->($param->{$key})
621
              if $condition->($param->{$key});
622
        }
623
        elsif ($condition eq 'exists') {
624
            $map_param->{$map_key} = $value_cb->($param->{$key})
625
              if exists $param->{$key};
626
        }
627
        else { croak qq/Condition must be code reference or "exists" / . _subname }
628
    }
629
    
630
    return $map_param;
631
}
632

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
633
sub merge_param {
634
    my ($self, @params) = @_;
635
    
cleanup
Yuki Kimoto authored on 2011-04-02
636
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
637
    my $merge = {};
638
    foreach my $param (@params) {
639
        foreach my $column (keys %$param) {
640
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
641
            
642
            if (exists $merge->{$column}) {
643
                $merge->{$column} = [$merge->{$column}]
644
                  unless ref $merge->{$column} eq 'ARRAY';
645
                push @{$merge->{$column}},
646
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
647
            }
648
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
649
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
650
            }
651
        }
652
    }
653
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
654
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
655
}
656

            
cleanup
Yuki Kimoto authored on 2011-03-21
657
sub method {
658
    my $self = shift;
659
    
cleanup
Yuki Kimoto authored on 2011-04-02
660
    # Register method
cleanup
Yuki Kimoto authored on 2011-03-21
661
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
662
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
663
    
664
    return $self;
665
}
666

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
667
sub model {
668
    my ($self, $name, $model) = @_;
669
    
cleanup
Yuki Kimoto authored on 2011-04-02
670
    # Set model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
671
    if ($model) {
672
        $self->models->{$name} = $model;
673
        return $self;
674
    }
675
    
676
    # Check model existance
cleanup
Yuki Kimoto authored on 2011-04-25
677
    croak qq{Model "$name" is not included } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
678
      unless $self->models->{$name};
679
    
cleanup
Yuki Kimoto authored on 2011-04-02
680
    # Get model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
681
    return $self->models->{$name};
682
}
683

            
cleanup
Yuki Kimoto authored on 2011-03-21
684
sub mycolumn {
685
    my ($self, $table, $columns) = @_;
686
    
cleanup
Yuki Kimoto authored on 2011-04-02
687
    # Create column clause
688
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
689
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
690
    push @column, $self->_q($table) . "." . $self->_q($_) .
691
      " as " . $self->_q($_)
692
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
693
    
694
    return join (', ', @column);
695
}
696

            
added dbi_options attribute
kimoto authored on 2010-12-20
697
sub new {
698
    my $self = shift->SUPER::new(@_);
699
    
cleanup
Yuki Kimoto authored on 2011-04-02
700
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
701
    my @attrs = keys %$self;
702
    foreach my $attr (@attrs) {
cleanup
Yuki Kimoto authored on 2011-04-25
703
        croak qq{"$attr" is wrong name } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
704
          unless $self->can($attr);
705
    }
cleanup
Yuki Kimoto authored on 2011-04-02
706
    
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
707
    # DEPRECATED!
fixed DEPRECATED messages
Yuki Kimoto authored on 2011-06-08
708
    $self->query_builder->{tags} = {
cleanup
Yuki Kimoto authored on 2011-01-25
709
        '?'     => \&DBIx::Custom::Tag::placeholder,
710
        '='     => \&DBIx::Custom::Tag::equal,
711
        '<>'    => \&DBIx::Custom::Tag::not_equal,
712
        '>'     => \&DBIx::Custom::Tag::greater_than,
713
        '<'     => \&DBIx::Custom::Tag::lower_than,
714
        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
715
        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
716
        'like'  => \&DBIx::Custom::Tag::like,
717
        'in'    => \&DBIx::Custom::Tag::in,
718
        'insert_param' => \&DBIx::Custom::Tag::insert_param,
719
        'update_param' => \&DBIx::Custom::Tag::update_param
fixed DEPRECATED messages
Yuki Kimoto authored on 2011-06-08
720
    };
added dbi_options attribute
kimoto authored on 2010-12-20
721
    
722
    return $self;
723
}
724

            
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
725
sub not_exists { bless {}, 'DBIx::Custom::NotExists' }
726

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

            
cleanup
yuki-kimoto authored on 2010-10-17
732
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
733
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
734
    
735
    # Register filter
736
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
737
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
738
    
cleanup
Yuki Kimoto authored on 2011-04-02
739
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
740
}
packaging one directory
yuki-kimoto authored on 2009-11-16
741

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

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

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

            
added EXPERIMETNAL separator...
Yuki Kimoto authored on 2011-06-13
875
sub separator {
876
    my $self = shift;
877
    
878
    if (@_) {
879
        my $separator = $_[0] || '';
880
        croak qq{Separator must be "." or "__" or "-" } . _subname
881
          unless $separator eq '.' || $separator eq '__'
882
              || $separator eq '-';
883
        
884
        $self->{separator} = $separator;
885
    
886
        return $self;
887
    }
888
    return $self->{separator} ||= '.';
889
}
890

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

            
simplify type_rule
Yuki Kimoto authored on 2011-06-10
906
sub available_data_type {
907
    my $self = shift;
908
    
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
909
    my $data_types = '';
simplify type_rule
Yuki Kimoto authored on 2011-06-10
910
    foreach my $i (-1000 .. 1000) {
911
         my $type_info = $self->dbh->type_info($i);
912
         my $data_type = $type_info->{DATA_TYPE};
913
         my $type_name = $type_info->{TYPE_NAME};
914
         $data_types .= "$data_type ($type_name)\n"
915
           if defined $data_type;
916
    }
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
917
    return "Data Type maybe equal to Type Name" unless $data_types;
918
    $data_types = "Data Type (Type name)\n" . $data_types;
simplify type_rule
Yuki Kimoto authored on 2011-06-10
919
    return $data_types;
920
}
921

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
1071
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1072
}
1073

            
cleanup
Yuki Kimoto authored on 2011-01-25
1074
sub where {
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
1075
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-04-02
1076
    
1077
    # Create where
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
1078
    return DBIx::Custom::Where->new(
1079
        query_builder => $self->query_builder,
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1080
        safety_character => $self->safety_character,
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1081
        quote => $self->_quote,
cleanup
Yuki Kimoto authored on 2011-03-09
1082
        @_
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
1083
    );
cleanup
Yuki Kimoto authored on 2011-01-25
1084
}
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1085

            
updated pod
Yuki Kimoto authored on 2011-06-21
1086
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1087
    
updated pod
Yuki Kimoto authored on 2011-06-21
1088
    my ($self, $source) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1089
    
updated pod
Yuki Kimoto authored on 2011-06-21
1090
    # Cache
1091
    my $cache = $self->cache;
1092
    
1093
    # Query
1094
    my $query;
1095
    
1096
    # Get cached query
1097
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1098
        
updated pod
Yuki Kimoto authored on 2011-06-21
1099
        # Get query
1100
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1101
        
updated pod
Yuki Kimoto authored on 2011-06-21
1102
        # Create query
1103
        if ($q) {
1104
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1105
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1106
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1107
    }
1108
    
1109
    # Create query
1110
    unless ($query) {
1111

            
1112
        # Create query
1113
        my $builder = $self->query_builder;
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
1114
        $builder->{_tag_parse} = $self->tag_parse;
cleanup
Yuki Kimoto authored on 2011-07-29
1115
        $builder->safety_character($self->safety_character);
updated pod
Yuki Kimoto authored on 2011-06-21
1116
        $query = $builder->build_query($source);
1117

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

            
1124
        # Save query to cache
1125
        $self->cache_method->(
1126
            $self, $source,
1127
            {
1128
                sql     => $query->sql, 
1129
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1130
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1131
            }
1132
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1133
    }
1134
    
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1135
    # Save sql
1136
    $self->last_sql($query->sql);
1137
    
updated pod
Yuki Kimoto authored on 2011-06-21
1138
    # Prepare statement handle
1139
    my $sth;
1140
    eval { $sth = $self->dbh->prepare($query->{sql})};
1141
    
1142
    if ($@) {
1143
        $self->_croak($@, qq{. Following SQL is executed.\n}
1144
                        . qq{$query->{sql}\n} . _subname);
1145
    }
1146
    
1147
    # Set statement handle
1148
    $query->sth($sth);
1149
    
1150
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1151
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1152
    
1153
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1154
}
1155

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

            
cleanup
Yuki Kimoto authored on 2011-06-08
1206
sub _create_param_from_id {
1207
    my ($self, $id, $primary_keys) = @_;
improved error messages
Yuki Kimoto authored on 2011-04-18
1208
    
cleanup
Yuki Kimoto authored on 2011-06-08
1209
    # Create parameter
1210
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1211
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1212
        $id = [$id] unless ref $id;
1213
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1214
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1215
          unless !ref $id || ref $id eq 'ARRAY';
1216
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1217
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1218
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1219
        for(my $i = 0; $i < @$primary_keys; $i ++) {
cleanup
Yuki Kimoto authored on 2011-06-08
1220
           $param->{$primary_keys->[$i]} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1221
        }
1222
    }
1223
    
cleanup
Yuki Kimoto authored on 2011-06-08
1224
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1225
}
1226

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1227
sub _connect {
1228
    my $self = shift;
1229
    
1230
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1231
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1232
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1233
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1234
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1235
    croak qq{"dsn" must be specified } . _subname
1236
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1237
    my $user        = $self->user;
1238
    my $password    = $self->password;
1239
    my $dbi_option = {%{$self->dbi_options}, %{$self->dbi_option}};
added warnings
Yuki Kimoto authored on 2011-06-07
1240
    warn "dbi_options is DEPRECATED! use dbi_option instead\n"
1241
      if keys %{$self->dbi_options};
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1242
    
1243
    # Connect
1244
    my $dbh = eval {DBI->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1245
        $dsn,
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1246
        $user,
1247
        $password,
1248
        {
1249
            %{$self->default_dbi_option},
1250
            %$dbi_option
1251
        }
1252
    )};
1253
    
1254
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1255
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1256
    
1257
    return $dbh;
1258
}
1259

            
cleanup
yuki-kimoto authored on 2010-10-17
1260
sub _croak {
1261
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1262
    
1263
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1264
    $append ||= "";
1265
    
1266
    # Verbose
1267
    if ($Carp::Verbose) { croak $error }
1268
    
1269
    # Not verbose
1270
    else {
1271
        
1272
        # Remove line and module infromation
1273
        my $at_pos = rindex($error, ' at ');
1274
        $error = substr($error, 0, $at_pos);
1275
        $error =~ s/\s+$//;
1276
        croak "$error$append";
1277
    }
1278
}
1279

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1280
sub _need_tables {
1281
    my ($self, $tree, $need_tables, $tables) = @_;
1282
    
cleanup
Yuki Kimoto authored on 2011-04-02
1283
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1284
    foreach my $table (@$tables) {
1285
        if ($tree->{$table}) {
1286
            $need_tables->{$table} = 1;
1287
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1288
        }
1289
    }
1290
}
1291

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1292
sub _push_join {
1293
    my ($self, $sql, $join, $join_tables) = @_;
1294
    
cleanup
Yuki Kimoto authored on 2011-04-02
1295
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1296
    return unless @$join;
1297
    
cleanup
Yuki Kimoto authored on 2011-04-02
1298
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1299
    my $tree = {};
1300
    for (my $i = 0; $i < @$join; $i++) {
1301
        
cleanup
Yuki Kimoto authored on 2011-07-28
1302
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1303
        my $join_clause;;
1304
        my $option;
1305
        if (ref $join->[$i] eq 'HASH') {
1306
            $join_clause = $join->[$i]->{clause};
1307
            $option = {table => $join->[$i]->{table}};
1308
        }
1309
        else {
1310
            $join_clause = $join->[$i];
1311
            $option = {};
1312
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1313

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1357
sub _quote {
1358
    my $self = shift;
1359
    
1360
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1361
         : defined $self->quote ? $self->quote
1362
         : '';
1363
}
1364

            
cleanup
Yuki Kimoto authored on 2011-07-29
1365
sub _q {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1366
    my ($self, $value) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1367
    
1368
    my $quote = $self->_quote;
1369
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1370
    my $p;
1371
    if (defined $quote && length $quote > 1) {
1372
        $p = substr($quote, 1, 1);
1373
    }
1374
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1375
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1376
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1377
}
1378

            
cleanup
Yuki Kimoto authored on 2011-04-02
1379
sub _remove_duplicate_table {
1380
    my ($self, $tables, $main_table) = @_;
1381
    
1382
    # Remove duplicate table
1383
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1384
    delete $tables{$main_table} if $main_table;
1385
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1386
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1387
    if (my $q = $self->_quote) {
1388
        $q = quotemeta($q);
1389
        $_ =~ s/[$q]//g for @$new_tables;
1390
    }
1391

            
1392
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1393
}
1394

            
cleanup
Yuki Kimoto authored on 2011-04-02
1395
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1396
    my ($self, $source) = @_;
1397
    
cleanup
Yuki Kimoto authored on 2011-04-02
1398
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1399
    my $tables = [];
1400
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1401
    my $q = $self->_quote;
cleanup
Yuki Kimoto authored on 2011-04-02
1402
    my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1403
    my $quoted_safety_character_re = $self->_q("?([$safety_character]+)");
1404
    my $table_re = $q ? qr/(?:^|[^$safety_character])$quoted_safety_character_re?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1405
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1406
    while ($source =~ /$table_re/g) {
1407
        push @$tables, $1;
1408
    }
1409
    
1410
    return $tables;
1411
}
1412

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

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

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

            
1522
# DEPRECATED!
1523
sub create_query {
1524
    warn "create_query is DEPRECATED! use query option of each method";
1525
    shift->_create_query(@_);
1526
}
1527

            
cleanup
Yuki Kimoto authored on 2011-06-13
1528
# DEPRECATED!
1529
sub apply_filter {
1530
    my $self = shift;
1531
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1532
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1533
    return $self->_apply_filter(@_);
1534
}
1535

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

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

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1543
    # Arguments
1544
    my $primary_keys = delete $args{primary_key};
1545
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1546
    my $where = delete $args{where};
1547
    my $param = delete $args{param};
1548
    
1549
    # Check arguments
1550
    foreach my $name (keys %args) {
1551
        croak qq{"$name" is wrong option } . _subname
1552
          unless $SELECT_AT_ARGS{$name};
1553
    }
1554
    
1555
    # Table
1556
    croak qq{"table" option must be specified } . _subname
1557
      unless $args{table};
1558
    my $table = ref $args{table} ? $args{table}->[-1] : $args{table};
1559
    
1560
    # Create where parameter
1561
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1562
    
1563
    return $self->select(where => $where_param, %args);
1564
}
1565

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

            
1571
    warn "delete_at is DEPRECATED! use update and id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1572
    
1573
    # Arguments
1574
    my $primary_keys = delete $args{primary_key};
1575
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1576
    my $where = delete $args{where};
1577
    
1578
    # Check arguments
1579
    foreach my $name (keys %args) {
1580
        croak qq{"$name" is wrong option } . _subname
1581
          unless $DELETE_AT_ARGS{$name};
1582
    }
1583
    
1584
    # Create where parameter
1585
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1586
    
1587
    return $self->delete(where => $where_param, %args);
1588
}
1589

            
cleanup
Yuki Kimoto authored on 2011-06-08
1590
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1591
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1592
sub update_at {
1593
    my $self = shift;
1594

            
1595
    warn "update_at is DEPRECATED! use update and id option instead";
1596
    
1597
    # Arguments
1598
    my $param;
1599
    $param = shift if @_ % 2;
1600
    my %args = @_;
1601
    my $primary_keys = delete $args{primary_key};
1602
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1603
    my $where = delete $args{where};
1604
    my $p = delete $args{param} || {};
1605
    $param  ||= $p;
1606
    
1607
    # Check arguments
1608
    foreach my $name (keys %args) {
1609
        croak qq{"$name" is wrong option } . _subname
1610
          unless $UPDATE_AT_ARGS{$name};
1611
    }
1612
    
1613
    # Create where parameter
1614
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1615
    
1616
    return $self->update(where => $where_param, param => $param, %args);
1617
}
1618

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1619
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1620
our %INSERT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1621
sub insert_at {
1622
    my $self = shift;
1623
    
1624
    warn "insert_at is DEPRECATED! use insert and id option instead";
1625
    
1626
    # Arguments
1627
    my $param;
1628
    $param = shift if @_ % 2;
1629
    my %args = @_;
1630
    my $primary_key = delete $args{primary_key};
1631
    $primary_key = [$primary_key] unless ref $primary_key;
1632
    my $where = delete $args{where};
1633
    my $p = delete $args{param} || {};
1634
    $param  ||= $p;
1635
    
1636
    # Check arguments
1637
    foreach my $name (keys %args) {
1638
        croak qq{"$name" is wrong option } . _subname
1639
          unless $INSERT_AT_ARGS{$name};
1640
    }
1641
    
1642
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-06-08
1643
    my $where_param = $self->_create_param_from_id($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1644
    $param = $self->merge_param($where_param, $param);
1645
    
1646
    return $self->insert(param => $param, %args);
1647
}
1648

            
added warnings
Yuki Kimoto authored on 2011-06-07
1649
# DEPRECATED!
1650
sub register_tag {
1651
    warn "register_tag is DEPRECATED!";
1652
    shift->query_builder->register_tag(@_)
1653
}
1654

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-01-25
1717
# DEPRECATED!
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1718
sub register_tag_processor {
added warnings
Yuki Kimoto authored on 2011-06-07
1719
    warn "register_tag_processor is DEPRECATED!";
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1720
    return shift->query_builder->register_tag_processor(@_);
1721
}
1722

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1767
=head1 NAME
1768

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

            
1771
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1772

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1842
Named place holder support
1843

            
1844
=item *
1845

            
cleanup
Yuki Kimoto authored on 2011-07-29
1846
Model support
1847

            
1848
=item *
1849

            
1850
Connection manager support
1851

            
1852
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1853

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

            
1858
=item *
1859

            
1860
Filtering by data type or column name(EXPERIMENTAL)
1861

            
1862
=item *
1863

            
1864
Create C<order by> clause flexibly(EXPERIMENTAL)
1865

            
1866
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1867

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1875
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
1876
L<DBIx::Custom::Result>,
1877
L<DBIx::Custom::Query>,
1878
L<DBIx::Custom::Where>,
1879
L<DBIx::Custom::Model>,
1880
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
1881

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

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

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

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

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

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

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

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

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

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

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

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

            
1919
=head2 C<default_dbi_option>
1920

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1927
    {
1928
        RaiseError => 1,
1929
        PrintError => 0,
1930
        AutoCommit => 1,
1931
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
1932

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

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

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

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

            
1942
    my $last_sql = $dbi->last_sql;
1943
    $dbi = $dbi->last_sql($last_sql);
1944

            
1945
Get last successed SQL executed by C<execute> method.
1946

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1954
=head2 C<password>
1955

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

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

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

            
renamed update tag to update...
yuki-kimoto authored on 2010-08-09
1963
    my $sql_class = $dbi->query_builder;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1964
    $dbi = $dbi->query_builder(DBIx::Custom::QueryBuilder->new);
added commit method
yuki-kimoto authored on 2010-05-27
1965

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1966
Query builder, default to L<DBIx::Custom::QueryBuilder> object.
cleanup
yuki-kimoto authored on 2010-08-05
1967

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1977
You can set quote pair.
1978

            
1979
    $dbi->quote('[]');
1980

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

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

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

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

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

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

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

            
1998
    my $tag_parse = $dbi->tag_parse(0);
1999
    $dbi = $dbi->tag_parse;
2000

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

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

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

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

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

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

            
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2017
=head2 C<available_data_type> EXPERIMENTAL
2018

            
2019
    print $dbi->available_data_type;
2020

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

            
2024
=head2 C<available_type_name> EXPERIMENTAL
2025

            
2026
    print $dbi->available_type_name;
2027

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

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

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2037
    title = :title, author = :author
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
This is equal to C<update_param> exept that set is not added.
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2040

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

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

            
2045
Create column clause. The follwoing column clause is created.
2046

            
2047
    book.author as "book.author",
2048
    book.title as "book.title"
2049

            
cleanup
Yuki Kimoto authored on 2011-06-13
2050
You can change separator by C<separator> method.
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2051

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

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

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

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

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

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

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

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

            
2092
   $dbi->model('book')->select(...);
2093

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

            
2096
    my $dbh = $dbi->dbh;
2097

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

            
2101
=head2 C<each_column>
2102

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2172
=over 4
2173

            
2174
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2175
    
2176
    filter => {
2177
        title  => sub { uc $_[0] }
2178
        author => sub { uc $_[0] }
2179
    }
update pod
Yuki Kimoto authored on 2011-03-13
2180

            
updated pod
Yuki Kimoto authored on 2011-06-09
2181
    # Filter name
2182
    filter => {
2183
        title  => 'upper_case',
2184
        author => 'upper_case'
2185
    }
2186
        
2187
    # At once
2188
    filter => [
2189
        [qw/title author/]  => sub { uc $_[0] }
2190
    ]
2191

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

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

            
2199
    query => 1
2200

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

            
2204
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2205
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2206
    my $columns = $query->columns;
2207
    
2208
If you want to execute SQL fast, you can do the following way.
2209

            
2210
    my $query;
2211
    foreach my $row (@$rows) {
2212
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2213
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2214
    }
2215

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

            
2219
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
2220
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2221
    
2222
    my $query;
2223
    my $sth;
2224
    foreach my $row (@$rows) {
2225
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2226
      $sth ||= $query->sth;
2227
      $sth->execute(map { $row->{$_} } sort keys %$row);
2228
    }
2229

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2234
=item C<table>
2235
    
2236
    table => 'author'
2237

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2245
    # Same
2246
    $dbi->execute(
2247
      "select * from book where title = :book.title and author = :book.author",
2248
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2249

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

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

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

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

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

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

            
2263
    table_alias => {user => 'hiker'}
2264

            
2265
Table alias. Key is real table name, value is alias table name.
2266
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2267
on alias table name.
2268

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

            
2271
    type_rule_off => 1
2272

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

            
2275
=item C<type_rule1_off> EXPERIMENTAL
2276

            
2277
    type_rule1_off => 1
2278

            
2279
Turn C<into1> type rule off.
2280

            
2281
=item C<type_rule2_off> EXPERIMENTAL
2282

            
2283
    type_rule2_off => 1
2284

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2297
=over 4
2298

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

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

            
2303
=item C<filter>
2304

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2309
    id => 4
2310
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2311

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2315
    $dbi->delete(
2316
        parimary_key => ['id1', 'id2'],
2317
        id => [4, 5],
2318
        table => 'book',
2319
    );
update pod
Yuki Kimoto authored on 2011-03-13
2320

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

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

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

            
2327
    prefix => 'some'
2328

            
2329
prefix before table name section.
2330

            
2331
    delete some from book
2332

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2341
Table name.
2342

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

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

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

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

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

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

            
2355
=item C<type_rule_off> EXPERIMENTAL
2356

            
2357
Same as C<execute> method's C<type_rule_off> option.
2358

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

            
2361
    type_rule1_off => 1
2362

            
2363
Same as C<execute> method's C<type_rule1_off> option.
2364

            
2365
=item C<type_rule2_off> EXPERIMENTAL
2366

            
2367
    type_rule2_off => 1
2368

            
2369
Same as C<execute> method's C<type_rule2_off> option.
2370

            
updated pod
Yuki Kimoto authored on 2011-06-08
2371
=back
update pod
Yuki Kimoto authored on 2011-03-13
2372

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2380
=head2 C<insert>
2381

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

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

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

            
2390
    {date => \"NOW()"}
2391

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

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

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

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

            
2400
=item C<filter>
2401

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

            
2404
=item C<id>
2405

            
updated document
Yuki Kimoto authored on 2011-06-09
2406
    id => 4
2407
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2408

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2412
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2413
        {title => 'Perl', author => 'Ken'}
2414
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2415
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2416
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2417
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2418

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

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

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

            
2428
    prefix => 'or replace'
2429

            
2430
prefix before table name section
2431

            
2432
    insert or replace into book
2433

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

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

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

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

            
2443
Same as C<execute> method's C<query> option.
2444

            
2445
=item C<table>
2446

            
2447
    table => 'book'
2448

            
2449
Table name.
2450

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

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

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

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

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

            
2461
    type_rule1_off => 1
2462

            
2463
Same as C<execute> method's C<type_rule1_off> option.
2464

            
2465
=item C<type_rule2_off> EXPERIMENTAL
2466

            
2467
    type_rule2_off => 1
2468

            
2469
Same as C<execute> method's C<type_rule2_off> option.
2470

            
update pod
Yuki Kimoto authored on 2011-03-13
2471
=back
2472

            
2473
=over 4
2474

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2490
    lib / MyModel.pm
2491
        / MyModel / book.pm
2492
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2493

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

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

            
2498
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2499
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2500
    
2501
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2502

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2507
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2508
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2509
    
2510
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2511

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2514
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2515
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2516
    
2517
    1;
2518
    
updated pod
Yuki Kimoto authored on 2011-06-21
2519
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2520

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

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

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

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

            
2530
    my $map_param = $dbi->map_param(
2531
        {id => 1, authro => 'Ken', price => 1900},
2532
        'id' => 'book.id',
2533
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2534
        'price' => [
2535
            'book.price', {if => sub { length $_[0] }}
2536
        ]
2537
    );
2538

            
2539
Map paramters to other key and value. First argument is original
2540
parameter. this is hash reference. Rest argument is mapping.
2541
By default, Mapping is done if the value length is not zero.
2542

            
2543
=over 4
2544

            
2545
=item Key mapping
2546

            
2547
    'id' => 'book.id'
2548

            
2549
This is only key mapping. Value is same as original one.
2550

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

            
2553
=item Key and value mapping
2554

            
2555
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2556

            
2557
This is key and value mapping. Frist element of array reference
2558
is mapped key name, second element is code reference to map the value.
2559

            
2560
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2561
      if value length is not zero.
2562

            
2563
=item Condition
2564

            
2565
    'price' => ['book.price', {if => 'exists'}]
2566
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2567
    'price' => ['book.price', {if => sub { defined shift }}]
2568

            
2569
If you need condition, you can sepecify it. this is code reference
2570
or 'exists'. By default, condition is the following one.
2571

            
2572
    sub { defined $_[0] && length $_[0] }
2573

            
2574
=back
2575

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

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

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

            
2582
    {key1 => [1, 1], key2 => 2}
2583

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

            
2586
    $dbi->method(
2587
        update_or_insert => sub {
2588
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2589
            
2590
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2591
        },
2592
        find_or_create   => sub {
2593
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2594
            
2595
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2596
        }
2597
    );
2598

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

            
2601
    $dbi->update_or_insert;
2602
    $dbi->find_or_create;
2603

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

            
2606
    my $model = $dbi->model('book');
2607

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

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

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

            
2614
Create column clause for myself. The follwoing column clause is created.
2615

            
2616
    book.author as author,
2617
    book.title as title
2618

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2621
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2622
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2623
        user => 'ken',
2624
        password => '!LFKD%$&',
2625
        dbi_option => {mysql_enable_utf8 => 1}
2626
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2627

            
2628
Create a new L<DBIx::Custom> object.
2629

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

            
2632
    my $not_exists = $dbi->not_exists;
2633

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

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

            
2639
    my $order = $dbi->order;
2640

            
2641
Create a new L<DBIx::Custom::Order> object.
2642

            
cleanup
yuki-kimoto authored on 2010-10-17
2643
=head2 C<register_filter>
2644

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2700
=over 4
2701

            
2702
=item 1. column name
2703

            
2704
    issue_date
2705
    issue_datetime
2706

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

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

            
2711
    book.issue_date
2712
    book.issue_datetime
2713

            
2714
=back
2715

            
update pod
Yuki Kimoto authored on 2011-06-15
2716
You get all type name used in database by C<available_type_name>.
2717

            
2718
    print $dbi->available_type_name;
2719

            
updated pod
Yuki Kimoto authored on 2011-06-21
2720
In C<from1> and C<from2> you specify data type, not type name.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2721
C<from2> is executed after C<from1>.
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2722
You get all data type by C<available_data_type>.
2723

            
2724
    print $dbi->available_data_type;
2725

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

            
2728
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2729
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2730
            [qw/DATE DATETIME/] => sub { ... },
2731
        ],
2732
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2733

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2736
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2737
        table  => 'book',
2738
        column => ['author', 'title'],
2739
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2740
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2741
    
updated document
Yuki Kimoto authored on 2011-06-09
2742
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2743

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

            
2746
=over 4
2747

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2752
Append statement to last of SQL.
2753
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2754
=item C<column>
2755
    
updated document
Yuki Kimoto authored on 2011-06-09
2756
    column => 'author'
2757
    column => ['author', 'title']
2758

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2767
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2768
        {book => [qw/author title/]},
2769
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2770
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2771

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

            
2774
    book.author as "book.author",
2775
    book.title as "book.title",
2776
    person.name as "person.name",
2777
    person.age as "person.age"
2778

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

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

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

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

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

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

            
2794
=item C<id>
2795

            
2796
    id => 4
2797
    id => [4, 5]
2798

            
2799
ID corresponding to C<primary_key>.
2800
You can select rows by C<id> and C<primary_key>.
2801

            
2802
    $dbi->select(
2803
        parimary_key => ['id1', 'id2'],
2804
        id => [4, 5],
2805
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2806
    );
2807

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
2810
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
2811
        where => {id1 => 4, id2 => 5},
2812
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2813
    );
2814
    
updated document
Yuki Kimoto authored on 2011-06-09
2815
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2816

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

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

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

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

            
2829
    prefix => 'SQL_CALC_FOUND_ROWS'
2830

            
2831
Prefix of column cluase
2832

            
2833
    select SQL_CALC_FOUND_ROWS title, author from book;
2834

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

            
2837
    join => [
2838
        'left outer join company on book.company_id = company_id',
2839
        'left outer join location on company.location_id = location.id'
2840
    ]
2841
        
2842
Join clause. If column cluase or where clause contain table name like "company.name",
2843
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
2844

            
2845
    $dbi->select(
2846
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2847
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2848
        where => {'company.name' => 'Orange'},
2849
        join => [
2850
            'left outer join company on book.company_id = company.id',
2851
            'left outer join location on company.location_id = location.id'
2852
        ]
2853
    );
2854

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2858
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2859
    from book
2860
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2861
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2862

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

            
2866
    $dbi->select(
2867
        table => 'book',
2868
        column => ['company.location_id as location_id'],
2869
        where => {'company.name' => 'Orange'},
2870
        join => [
2871
            {
2872
                clause => 'left outer join location on company.location_id = location.id',
2873
                table => ['company', 'location']
2874
            }
2875
        ]
2876
    );
2877

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2897
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2898

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

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

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

            
2905
    type_rule1_off => 1
2906

            
2907
Same as C<execute> method's C<type_rule1_off> option.
2908

            
2909
=item C<type_rule2_off> EXPERIMENTAL
2910

            
2911
    type_rule2_off => 1
2912

            
2913
Same as C<execute> method's C<type_rule2_off> option.
2914

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2941
Where clause.
2942
    
improved pod
Yuki Kimoto authored on 2011-04-19
2943
=item C<wrap> EXPERIMENTAL
2944

            
2945
Wrap statement. This is array reference.
2946

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

            
2949
This option is for Oracle and SQL Server paging process.
2950

            
update pod
Yuki Kimoto authored on 2011-03-12
2951
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2952

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

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

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

            
2959
If you want to set constant value to row data, use scalar reference
2960
as parameter value.
2961

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2966
=over 4
2967

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2978
    id => 4
2979
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2980

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2984
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
2985
        {title => 'Perl', author => 'Ken'}
2986
        parimary_key => ['id1', 'id2'],
2987
        id => [4, 5],
2988
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2989
    );
update pod
Yuki Kimoto authored on 2011-03-13
2990

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2993
    $dbi->update(
2994
        {title => 'Perl', author => 'Ken'}
2995
        where => {id1 => 4, id2 => 5},
2996
        table => 'book'
2997
    );
update pod
Yuki Kimoto authored on 2011-03-13
2998

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

            
3001
    prefix => 'or replace'
3002

            
3003
prefix before table name section
3004

            
3005
    update or replace book
3006

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

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

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

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

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

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

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

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

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

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

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

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

            
3032
=item C<type_rule_off> EXPERIMENTAL
3033

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

            
3036
=item C<type_rule1_off> EXPERIMENTAL
3037

            
3038
    type_rule1_off => 1
3039

            
3040
Same as C<execute> method's C<type_rule1_off> option.
3041

            
3042
=item C<type_rule2_off> EXPERIMENTAL
3043

            
3044
    type_rule2_off => 1
3045

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3048
=back
update pod
Yuki Kimoto authored on 2011-03-13
3049

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

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

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

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

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

            
3061
Create update parameter tag.
3062

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

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

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

            
3072
Create a new L<DBIx::Custom::Where> object.
3073

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

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

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

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

            
3083
=head2 C<DBIX_CUSTOM_DEBUG>
3084

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

            
3088
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3089

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

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

            
3094
L<DBIx::Custom>
3095

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

            
3129
L<DBIx::Custom::Model>
3130

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3131
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3132
    filter # will be removed at 2017/1/1
3133
    name # will be removed at 2017/1/1
3134
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3135

            
3136
L<DBIx::Custom::Query>
3137
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3138
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3139
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3140
    table # will be removed at 2017/1/1
3141
    filters # will be removed at 2017/1/1
3142
    
3143
    # Methods
3144
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3145

            
3146
L<DBIx::Custom::QueryBuilder>
3147
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3148
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3149
    tags # will be removed at 2017/1/1
3150
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3151
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3152
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3153
    register_tag # will be removed at 2017/1/1
3154
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3155
    
3156
    # Others
3157
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3158
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3159

            
3160
L<DBIx::Custom::Result>
3161
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3162
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3163
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3164
    
3165
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3166
    end_filter # will be removed at 2017/1/1
3167
    remove_end_filter # will be removed at 2017/1/1
3168
    remove_filter # will be removed at 2017/1/1
3169
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3170

            
3171
L<DBIx::Custom::Tag>
3172

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

            
3175
=head1 BACKWORD COMPATIBLE POLICY
3176

            
3177
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3178
except for attribute method.
3179
You can check all DEPRECATED functionalities by document.
3180
DEPRECATED functionality is removed after five years,
3181
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
3182
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3183

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

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

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

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

            
3192
C<< <kimoto.yuki at gmail.com> >>
3193

            
3194
L<http://github.com/yuki-kimoto/DBIx-Custom>
3195

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3196
=head1 AUTHOR
3197

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

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

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

            
3204
This program is free software; you can redistribute it and/or modify it
3205
under the same terms as Perl itself.
3206

            
3207
=cut