DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3197 lines | 83.128kb
cleanup
yuki-kimoto authored on 2009-12-22
1
package DBIx::Custom;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
2
use Object::Simple -base;
cleanup
yuki-kimoto authored on 2009-12-22
3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
879
sub setup_model {
880
    my $self = shift;
881
    
cleanup
Yuki Kimoto authored on 2011-04-02
882
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
883
    $self->each_column(
884
        sub {
885
            my ($self, $table, $column, $column_info) = @_;
886
            if (my $model = $self->models->{$table}) {
887
                push @{$model->columns}, $column;
888
            }
889
        }
890
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
891
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
892
}
893

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

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
910
sub available_typename {
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
911
    my $self = shift;
912
    
913
    # Type Names
914
    my $type_names = {};
915
    $self->each_column(sub {
916
        my ($self, $table, $column, $column_info) = @_;
917
        $type_names->{$column_info->{TYPE_NAME}} = 1
918
          if $column_info->{TYPE_NAME};
919
    });
920
    my @output = sort keys %$type_names;
921
    unshift @output, "Type Name";
922
    return join "\n", @output;
923
}
924

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
958
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
959
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
960
                }
961
            });
962
        }
963

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

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

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

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

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1052
sub update_param {
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1053
    my ($self, $param, $opt) = @_;
1054
    
cleanup
Yuki Kimoto authored on 2011-04-02
1055
    # Create update parameter tag
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1056
    my $tag = $self->assign_param($param);
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1057
    $tag = "set $tag" unless $opt->{no_set};
1058

            
cleanup
Yuki Kimoto authored on 2011-04-02
1059
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1060
}
1061

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

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

            
1090
        # Create query
1091
        my $builder = $self->query_builder;
1092
        $query = $builder->build_query($source);
1093

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

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

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

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1256
sub _need_tables {
1257
    my ($self, $tree, $need_tables, $tables) = @_;
1258
    
cleanup
Yuki Kimoto authored on 2011-04-02
1259
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1260
    foreach my $table (@$tables) {
1261
        if ($tree->{$table}) {
1262
            $need_tables->{$table} = 1;
1263
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1264
        }
1265
    }
1266
}
1267

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

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1333
sub _quote {
1334
    my $self = shift;
1335
    
1336
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1337
         : defined $self->quote ? $self->quote
1338
         : '';
1339
}
1340

            
cleanup
Yuki Kimoto authored on 2011-07-29
1341
sub _q {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1342
    my ($self, $value) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1343
    
1344
    my $quote = $self->_quote;
1345
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1346
    my $p;
1347
    if (defined $quote && length $quote > 1) {
1348
        $p = substr($quote, 1, 1);
1349
    }
1350
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1351
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1352
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1353
}
1354

            
cleanup
Yuki Kimoto authored on 2011-04-02
1355
sub _remove_duplicate_table {
1356
    my ($self, $tables, $main_table) = @_;
1357
    
1358
    # Remove duplicate table
1359
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1360
    delete $tables{$main_table} if $main_table;
1361
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1362
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1363
    if (my $q = $self->_quote) {
1364
        $q = quotemeta($q);
1365
        $_ =~ s/[$q]//g for @$new_tables;
1366
    }
1367

            
1368
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1369
}
1370

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

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

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

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

            
1498
# DEPRECATED!
1499
sub create_query {
1500
    warn "create_query is DEPRECATED! use query option of each method";
1501
    shift->_create_query(@_);
1502
}
1503

            
cleanup
Yuki Kimoto authored on 2011-06-13
1504
# DEPRECATED!
1505
sub apply_filter {
1506
    my $self = shift;
1507
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1508
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1509
    return $self->_apply_filter(@_);
1510
}
1511

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-08
1566
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1567
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1568
sub update_at {
1569
    my $self = shift;
1570

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

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

            
added warnings
Yuki Kimoto authored on 2011-06-07
1625
# DEPRECATED!
1626
sub register_tag {
1627
    warn "register_tag is DEPRECATED!";
1628
    shift->query_builder->register_tag(@_)
1629
}
1630

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1631
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
1632
has 'data_source';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1633
has dbi_options => sub { {} };
1634
has filter_check  => 1;
1635
has 'reserved_word_quote';
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1636

            
cleanup
Yuki Kimoto authored on 2011-01-25
1637
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1638
sub default_bind_filter {
1639
    my $self = shift;
1640
    
cleanup
Yuki Kimoto authored on 2011-06-13
1641
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1642
    
cleanup
Yuki Kimoto authored on 2011-01-12
1643
    if (@_) {
1644
        my $fname = $_[0];
1645
        
1646
        if (@_ && !$fname) {
1647
            $self->{default_out_filter} = undef;
1648
        }
1649
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1650
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1651
              unless exists $self->filters->{$fname};
1652
        
1653
            $self->{default_out_filter} = $self->filters->{$fname};
1654
        }
1655
        return $self;
1656
    }
1657
    
1658
    return $self->{default_out_filter};
1659
}
1660

            
cleanup
Yuki Kimoto authored on 2011-01-25
1661
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1662
sub default_fetch_filter {
1663
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1664

            
cleanup
Yuki Kimoto authored on 2011-06-13
1665
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1666
    
1667
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1668
        my $fname = $_[0];
1669

            
cleanup
Yuki Kimoto authored on 2011-01-12
1670
        if (@_ && !$fname) {
1671
            $self->{default_in_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_in_filter} = $self->filters->{$fname};
1678
        }
1679
        
1680
        return $self;
1681
    }
1682
    
many changed
Yuki Kimoto authored on 2011-01-23
1683
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1684
}
1685

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1686
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1687
sub insert_param_tag {
1688
    warn "insert_param_tag is DEPRECATED! " .
1689
         "use insert_param instead!";
1690
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1691
}
1692

            
cleanup
Yuki Kimoto authored on 2011-01-25
1693
# DEPRECATED!
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1694
sub register_tag_processor {
added warnings
Yuki Kimoto authored on 2011-06-07
1695
    warn "register_tag_processor is DEPRECATED!";
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1696
    return shift->query_builder->register_tag_processor(@_);
1697
}
1698

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1699
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1700
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1701
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1702
         "use update_param instead";
1703
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1704
}
cleanup
Yuki Kimoto authored on 2011-03-08
1705
# DEPRECATED!
1706
sub _push_relation {
1707
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1708
    
1709
    if (keys %{$relation || {}}) {
1710
        push @$sql, $need_where ? 'where' : 'and';
1711
        foreach my $rcolumn (keys %$relation) {
1712
            my $table1 = (split (/\./, $rcolumn))[0];
1713
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1714
            push @$tables, ($table1, $table2);
1715
            push @$sql, ("$rcolumn = " . $relation->{$rcolumn},  'and');
1716
        }
1717
    }
1718
    pop @$sql if $sql->[-1] eq 'and';    
1719
}
1720

            
1721
# DEPRECATED!
1722
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1723
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1724
    
1725
    if (keys %{$relation || {}}) {
1726
        foreach my $rcolumn (keys %$relation) {
1727
            my $table1 = (split (/\./, $rcolumn))[0];
1728
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1729
            my $table1_exists;
1730
            my $table2_exists;
1731
            foreach my $table (@$tables) {
1732
                $table1_exists = 1 if $table eq $table1;
1733
                $table2_exists = 1 if $table eq $table2;
1734
            }
1735
            unshift @$tables, $table1 unless $table1_exists;
1736
            unshift @$tables, $table2 unless $table2_exists;
1737
        }
1738
    }
1739
}
1740

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1743
=head1 NAME
1744

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

            
1747
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1748

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1749
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1750
    
1751
    # Connect
1752
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1753
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1754
        user => 'ken',
1755
        password => '!LFKD%$&',
1756
        dbi_option => {mysql_enable_utf8 => 1}
1757
    );
cleanup
yuki-kimoto authored on 2010-08-05
1758

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1759
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1760
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1761
    
1762
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
1763
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
1764
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1765
    
1766
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
1767
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
1768

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1773
    # Select, more complex
1774
    my $result = $dbi->select(
1775
        table  => 'book',
1776
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
1777
            {book => [qw/title author/]},
1778
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1779
        ],
1780
        where  => {'book.author' => 'Ken'},
1781
        join => ['left outer join company on book.company_id = company.id'],
1782
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
1783
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1784
    
removed register_format()
yuki-kimoto authored on 2010-05-26
1785
    # Fetch
1786
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1787
        
removed register_format()
yuki-kimoto authored on 2010-05-26
1788
    }
1789
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1790
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
1791
    while (my $row = $result->fetch_hash) {
1792
        
1793
    }
1794
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1795
    # Execute SQL with parameter.
1796
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1797
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
1798
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1799
    );
1800
    
renamed update tag to update...
yuki-kimoto authored on 2010-08-09
1801
=head1 DESCRIPTIONS
removed reconnect method
yuki-kimoto authored on 2010-05-28
1802

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1818
Named place holder support
1819

            
1820
=item *
1821

            
cleanup
Yuki Kimoto authored on 2011-07-29
1822
Model support
1823

            
1824
=item *
1825

            
1826
Connection manager support
1827

            
1828
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1829

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

            
1834
=item *
1835

            
1836
Filtering by data type or column name(EXPERIMENTAL)
1837

            
1838
=item *
1839

            
1840
Create C<order by> clause flexibly(EXPERIMENTAL)
1841

            
1842
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1843

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1851
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
1852
L<DBIx::Custom::Result>,
1853
L<DBIx::Custom::Query>,
1854
L<DBIx::Custom::Where>,
1855
L<DBIx::Custom::Model>,
1856
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
1857

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

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

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

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

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

            
1871
    my $connector = DBIx::Connector->new(
1872
        "dbi:mysql:database=$DATABASE",
1873
        $USER,
1874
        $PASSWORD,
1875
        DBIx::Custom->new->default_dbi_option
1876
    );
1877
    
updated pod
Yuki Kimoto authored on 2011-06-21
1878
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
1879

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

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

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

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

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

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

            
1895
=head2 C<default_dbi_option>
1896

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1903
    {
1904
        RaiseError => 1,
1905
        PrintError => 0,
1906
        AutoCommit => 1,
1907
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
1908

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

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

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

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

            
1918
    my $last_sql = $dbi->last_sql;
1919
    $dbi = $dbi->last_sql($last_sql);
1920

            
1921
Get last successed SQL executed by C<execute> method.
1922

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1930
=head2 C<password>
1931

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1953
You can set quote pair.
1954

            
1955
    $dbi->quote('[]');
1956

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

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

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

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

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

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

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

            
1974
    my $separator = $self->separator;
1975
    $dbi = $self->separator($separator);
1976

            
1977
Separator whichi join table and column.
1978
This is used by C<column> and C<mycolumn> method.
1979

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

            
1982
    my $tag_parse = $dbi->tag_parse(0);
1983
    $dbi = $dbi->tag_parse;
1984

            
1985
Enable DEPRECATED tag parsing functionality, default to 1.
1986
If you want to disable tag parsing functionality, set to 0.
1987

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2029
Create column clause. The follwoing column clause is created.
2030

            
2031
    book.author as "book.author",
2032
    book.title as "book.title"
2033

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2036
    # Separator is double underbar
2037
    $dbi->separator('__');
2038
    
2039
    book.author as "book__author",
2040
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2041

            
cleanup
Yuki Kimoto authored on 2011-06-13
2042
    # Separator is hyphen
2043
    $dbi->separator('-');
2044
    
2045
    book.author as "book-author",
2046
    book.title as "book-title"
2047
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2048
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2049

            
update pod
Yuki Kimoto authored on 2011-03-13
2050
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2051
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2052
        user => 'ken',
2053
        password => '!LFKD%$&',
2054
        dbi_option => {mysql_enable_utf8 => 1}
2055
    );
2056

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

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

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2065
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2066
        table => 'book',
2067
        primary_key => 'id',
2068
        join => [
2069
            'inner join company on book.comparny_id = company.id'
2070
        ],
2071
    );
2072

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

            
2076
   $dbi->model('book')->select(...);
2077

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

            
2080
    my $dbh = $dbi->dbh;
2081

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

            
2085
=head2 C<each_column>
2086

            
2087
    $dbi->each_column(
2088
        sub {
2089
            my ($dbi, $table, $column, $column_info) = @_;
2090
            
2091
            my $type = $column_info->{TYPE_NAME};
2092
            
2093
            if ($type eq 'DATE') {
2094
                # ...
2095
            }
2096
        }
2097
    );
2098

            
2099
Iterate all column informations of all table from database.
2100
Argument is callback when one column is found.
2101
Callback receive four arguments, dbi object, table name,
2102
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2103

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

            
2106
    $dbi->each_table(
2107
        sub {
2108
            my ($dbi, $table, $table_info) = @_;
2109
            
2110
            my $table_name = $table_info->{TABLE_NAME};
2111
        }
2112
    );
2113

            
2114
Iterate all table informationsfrom database.
2115
Argument is callback when one table is found.
2116
Callback receive three arguments, dbi object, table name,
2117
table information.
2118

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

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

            
2126
    my $result = $dbi->execute(
2127
      "select * from book where title = :book.title and author like :book.author",
2128
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2129
    );
2130

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2137
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2138
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2139
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2140
    select * from book where title = :title and author like :author
2141
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2142
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2143
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2144

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2148
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2149
    select * from book where :title{=} and :author{like}
2150
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2151
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2152
    select * from where title = ? and author like ?;
2153

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

            
2158
    select * from where title = "aa\\:bb";
2159

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

            
2162
=over 4
2163

            
2164
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2165
    
2166
    filter => {
2167
        title  => sub { uc $_[0] }
2168
        author => sub { uc $_[0] }
2169
    }
update pod
Yuki Kimoto authored on 2011-03-13
2170

            
updated pod
Yuki Kimoto authored on 2011-06-09
2171
    # Filter name
2172
    filter => {
2173
        title  => 'upper_case',
2174
        author => 'upper_case'
2175
    }
2176
        
2177
    # At once
2178
    filter => [
2179
        [qw/title author/]  => sub { uc $_[0] }
2180
    ]
2181

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

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

            
2189
    query => 1
2190

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

            
2194
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2195
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2196
    my $columns = $query->columns;
2197
    
2198
If you want to execute SQL fast, you can do the following way.
2199

            
2200
    my $query;
2201
    foreach my $row (@$rows) {
2202
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2203
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2204
    }
2205

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

            
2209
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
2210
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2211
    
2212
    my $query;
2213
    my $sth;
2214
    foreach my $row (@$rows) {
2215
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2216
      $sth ||= $query->sth;
2217
      $sth->execute(map { $row->{$_} } sort keys %$row);
2218
    }
2219

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2224
=item C<table>
2225
    
2226
    table => 'author'
2227

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2235
    # Same
2236
    $dbi->execute(
2237
      "select * from book where title = :book.title and author = :book.author",
2238
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2239

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

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

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

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

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

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

            
2253
    table_alias => {user => 'hiker'}
2254

            
2255
Table alias. Key is real table name, value is alias table name.
2256
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2257
on alias table name.
2258

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

            
2261
    type_rule_off => 1
2262

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

            
2265
=item C<type_rule1_off> EXPERIMENTAL
2266

            
2267
    type_rule1_off => 1
2268

            
2269
Turn C<into1> type rule off.
2270

            
2271
=item C<type_rule2_off> EXPERIMENTAL
2272

            
2273
    type_rule2_off => 1
2274

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2287
=over 4
2288

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

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

            
2293
=item C<filter>
2294

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2299
    id => 4
2300
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2301

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2305
    $dbi->delete(
2306
        parimary_key => ['id1', 'id2'],
2307
        id => [4, 5],
2308
        table => 'book',
2309
    );
update pod
Yuki Kimoto authored on 2011-03-13
2310

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

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

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

            
2317
    prefix => 'some'
2318

            
2319
prefix before table name section.
2320

            
2321
    delete some from book
2322

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2331
Table name.
2332

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

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

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

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

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

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

            
2345
=item C<type_rule_off> EXPERIMENTAL
2346

            
2347
Same as C<execute> method's C<type_rule_off> option.
2348

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

            
2351
    type_rule1_off => 1
2352

            
2353
Same as C<execute> method's C<type_rule1_off> option.
2354

            
2355
=item C<type_rule2_off> EXPERIMENTAL
2356

            
2357
    type_rule2_off => 1
2358

            
2359
Same as C<execute> method's C<type_rule2_off> option.
2360

            
updated pod
Yuki Kimoto authored on 2011-06-08
2361
=back
update pod
Yuki Kimoto authored on 2011-03-13
2362

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2370
=head2 C<insert>
2371

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

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

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

            
2380
    {date => \"NOW()"}
2381

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

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

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

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

            
2390
=item C<filter>
2391

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

            
2394
=item C<id>
2395

            
updated document
Yuki Kimoto authored on 2011-06-09
2396
    id => 4
2397
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2398

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2402
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2403
        {title => 'Perl', author => 'Ken'}
2404
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2405
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2406
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2407
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2408

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

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

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

            
2418
    prefix => 'or replace'
2419

            
2420
prefix before table name section
2421

            
2422
    insert or replace into book
2423

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

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

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

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

            
2433
Same as C<execute> method's C<query> option.
2434

            
2435
=item C<table>
2436

            
2437
    table => 'book'
2438

            
2439
Table name.
2440

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

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

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

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

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

            
2451
    type_rule1_off => 1
2452

            
2453
Same as C<execute> method's C<type_rule1_off> option.
2454

            
2455
=item C<type_rule2_off> EXPERIMENTAL
2456

            
2457
    type_rule2_off => 1
2458

            
2459
Same as C<execute> method's C<type_rule2_off> option.
2460

            
update pod
Yuki Kimoto authored on 2011-03-13
2461
=back
2462

            
2463
=over 4
2464

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2480
    lib / MyModel.pm
2481
        / MyModel / book.pm
2482
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2483

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

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

            
2488
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2489
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2490
    
2491
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2492

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2497
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2498
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2499
    
2500
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2501

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2504
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2505
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2506
    
2507
    1;
2508
    
updated pod
Yuki Kimoto authored on 2011-06-21
2509
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2510

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

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

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

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

            
2520
    my $map_param = $dbi->map_param(
2521
        {id => 1, authro => 'Ken', price => 1900},
2522
        'id' => 'book.id',
2523
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2524
        'price' => [
2525
            'book.price', {if => sub { length $_[0] }}
2526
        ]
2527
    );
2528

            
2529
Map paramters to other key and value. First argument is original
2530
parameter. this is hash reference. Rest argument is mapping.
2531
By default, Mapping is done if the value length is not zero.
2532

            
2533
=over 4
2534

            
2535
=item Key mapping
2536

            
2537
    'id' => 'book.id'
2538

            
2539
This is only key mapping. Value is same as original one.
2540

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

            
2543
=item Key and value mapping
2544

            
2545
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2546

            
2547
This is key and value mapping. Frist element of array reference
2548
is mapped key name, second element is code reference to map the value.
2549

            
2550
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2551
      if value length is not zero.
2552

            
2553
=item Condition
2554

            
2555
    'price' => ['book.price', {if => 'exists'}]
2556
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2557
    'price' => ['book.price', {if => sub { defined shift }}]
2558

            
2559
If you need condition, you can sepecify it. this is code reference
2560
or 'exists'. By default, condition is the following one.
2561

            
2562
    sub { defined $_[0] && length $_[0] }
2563

            
2564
=back
2565

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

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

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

            
2572
    {key1 => [1, 1], key2 => 2}
2573

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

            
2576
    $dbi->method(
2577
        update_or_insert => sub {
2578
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2579
            
2580
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2581
        },
2582
        find_or_create   => sub {
2583
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2584
            
2585
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2586
        }
2587
    );
2588

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

            
2591
    $dbi->update_or_insert;
2592
    $dbi->find_or_create;
2593

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

            
2596
    my $model = $dbi->model('book');
2597

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

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

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

            
2604
Create column clause for myself. The follwoing column clause is created.
2605

            
2606
    book.author as author,
2607
    book.title as title
2608

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2611
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2612
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2613
        user => 'ken',
2614
        password => '!LFKD%$&',
2615
        dbi_option => {mysql_enable_utf8 => 1}
2616
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2617

            
2618
Create a new L<DBIx::Custom> object.
2619

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

            
2622
    my $not_exists = $dbi->not_exists;
2623

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

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

            
2629
    my $order = $dbi->order;
2630

            
2631
Create a new L<DBIx::Custom::Order> object.
2632

            
cleanup
yuki-kimoto authored on 2010-10-17
2633
=head2 C<register_filter>
2634

            
update pod
Yuki Kimoto authored on 2011-03-13
2635
    $dbi->register_filter(
2636
        # Time::Piece object to database DATE format
2637
        tp_to_date => sub {
2638
            my $tp = shift;
2639
            return $tp->strftime('%Y-%m-%d');
2640
        },
2641
        # database DATE format to Time::Piece object
2642
        date_to_tp => sub {
2643
           my $date = shift;
2644
           return Time::Piece->strptime($date, '%Y-%m-%d');
2645
        }
2646
    );
cleanup
yuki-kimoto authored on 2010-10-17
2647
    
update pod
Yuki Kimoto authored on 2011-03-13
2648
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2649

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

            
2652
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2653
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2654
            date => sub { ... },
2655
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2656
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2657
        into2 => {
2658
            date => sub { ... },
2659
            datetime => sub { ... }
2660
        },
2661
        from1 => {
2662
            # DATE
2663
            9 => sub { ... },
2664
            # DATETIME or TIMESTAMP
2665
            11 => sub { ... },
2666
        }
2667
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2668
            # DATE
2669
            9 => sub { ... },
2670
            # DATETIME or TIMESTAMP
2671
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2672
        }
2673
    );
2674

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2690
=over 4
2691

            
2692
=item 1. column name
2693

            
2694
    issue_date
2695
    issue_datetime
2696

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

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

            
2701
    book.issue_date
2702
    book.issue_datetime
2703

            
2704
=back
2705

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

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

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

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

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

            
2718
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2719
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2720
            [qw/DATE DATETIME/] => sub { ... },
2721
        ],
2722
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2723

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2726
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2727
        table  => 'book',
2728
        column => ['author', 'title'],
2729
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2730
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2731
    
updated document
Yuki Kimoto authored on 2011-06-09
2732
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2733

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

            
2736
=over 4
2737

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2742
Append statement to last of SQL.
2743
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2744
=item C<column>
2745
    
updated document
Yuki Kimoto authored on 2011-06-09
2746
    column => 'author'
2747
    column => ['author', 'title']
2748

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2757
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2758
        {book => [qw/author title/]},
2759
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2760
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2761

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

            
2764
    book.author as "book.author",
2765
    book.title as "book.title",
2766
    person.name as "person.name",
2767
    person.age as "person.age"
2768

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

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

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

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

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

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

            
2784
=item C<id>
2785

            
2786
    id => 4
2787
    id => [4, 5]
2788

            
2789
ID corresponding to C<primary_key>.
2790
You can select rows by C<id> and C<primary_key>.
2791

            
2792
    $dbi->select(
2793
        parimary_key => ['id1', 'id2'],
2794
        id => [4, 5],
2795
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2796
    );
2797

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
2800
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
2801
        where => {id1 => 4, id2 => 5},
2802
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2803
    );
2804
    
updated document
Yuki Kimoto authored on 2011-06-09
2805
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2806

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

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

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

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

            
2819
    prefix => 'SQL_CALC_FOUND_ROWS'
2820

            
2821
Prefix of column cluase
2822

            
2823
    select SQL_CALC_FOUND_ROWS title, author from book;
2824

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

            
2827
    join => [
2828
        'left outer join company on book.company_id = company_id',
2829
        'left outer join location on company.location_id = location.id'
2830
    ]
2831
        
2832
Join clause. If column cluase or where clause contain table name like "company.name",
2833
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
2834

            
2835
    $dbi->select(
2836
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2837
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2838
        where => {'company.name' => 'Orange'},
2839
        join => [
2840
            'left outer join company on book.company_id = company.id',
2841
            'left outer join location on company.location_id = location.id'
2842
        ]
2843
    );
2844

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2848
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2849
    from book
2850
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2851
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2852

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

            
2856
    $dbi->select(
2857
        table => 'book',
2858
        column => ['company.location_id as location_id'],
2859
        where => {'company.name' => 'Orange'},
2860
        join => [
2861
            {
2862
                clause => 'left outer join location on company.location_id = location.id',
2863
                table => ['company', 'location']
2864
            }
2865
        ]
2866
    );
2867

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2887
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2888

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

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

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

            
2895
    type_rule1_off => 1
2896

            
2897
Same as C<execute> method's C<type_rule1_off> option.
2898

            
2899
=item C<type_rule2_off> EXPERIMENTAL
2900

            
2901
    type_rule2_off => 1
2902

            
2903
Same as C<execute> method's C<type_rule2_off> option.
2904

            
updated document
Yuki Kimoto authored on 2011-06-09
2905
=item C<where>
2906
    
2907
    # Hash refrence
2908
    where => {author => 'Ken', 'title' => 'Perl'}
2909
    
2910
    # DBIx::Custom::Where object
2911
    where => $dbi->where(
2912
        clause => ['and', 'author = :author', 'title like :title'],
2913
        param  => {author => 'Ken', title => '%Perl%'}
2914
    );
updated pod
Yuki Kimoto authored on 2011-06-21
2915
    
2916
    # Array reference 1 (array reference, hash referenc). same as above
2917
    where => [
2918
        ['and', 'author = :author', 'title like :title'],
2919
        {author => 'Ken', title => '%Perl%'}
2920
    ];    
2921
    
2922
    # Array reference 2 (String, hash reference)
2923
    where => [
2924
        'title like :title',
2925
        {title => '%Perl%'}
2926
    ]
2927
    
2928
    # String
2929
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
2930

            
updated document
Yuki Kimoto authored on 2011-06-09
2931
Where clause.
2932
    
improved pod
Yuki Kimoto authored on 2011-04-19
2933
=item C<wrap> EXPERIMENTAL
2934

            
2935
Wrap statement. This is array reference.
2936

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

            
2939
This option is for Oracle and SQL Server paging process.
2940

            
update pod
Yuki Kimoto authored on 2011-03-12
2941
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2942

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

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

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

            
2949
If you want to set constant value to row data, use scalar reference
2950
as parameter value.
2951

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2956
=over 4
2957

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2968
    id => 4
2969
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2970

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2974
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
2975
        {title => 'Perl', author => 'Ken'}
2976
        parimary_key => ['id1', 'id2'],
2977
        id => [4, 5],
2978
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2979
    );
update pod
Yuki Kimoto authored on 2011-03-13
2980

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2983
    $dbi->update(
2984
        {title => 'Perl', author => 'Ken'}
2985
        where => {id1 => 4, id2 => 5},
2986
        table => 'book'
2987
    );
update pod
Yuki Kimoto authored on 2011-03-13
2988

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

            
2991
    prefix => 'or replace'
2992

            
2993
prefix before table name section
2994

            
2995
    update or replace book
2996

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

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

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

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

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

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

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

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

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

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

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

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

            
3022
=item C<type_rule_off> EXPERIMENTAL
3023

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

            
3026
=item C<type_rule1_off> EXPERIMENTAL
3027

            
3028
    type_rule1_off => 1
3029

            
3030
Same as C<execute> method's C<type_rule1_off> option.
3031

            
3032
=item C<type_rule2_off> EXPERIMENTAL
3033

            
3034
    type_rule2_off => 1
3035

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3038
=back
update pod
Yuki Kimoto authored on 2011-03-13
3039

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

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

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

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

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

            
3051
Create update parameter tag.
3052

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

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

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

            
3062
Create a new L<DBIx::Custom::Where> object.
3063

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

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

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

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

            
3073
=head2 C<DBIX_CUSTOM_DEBUG>
3074

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

            
3078
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3079

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

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

            
3084
L<DBIx::Custom>
3085

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

            
3119
L<DBIx::Custom::Model>
3120

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3121
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3122
    filter # will be removed at 2017/1/1
3123
    name # will be removed at 2017/1/1
3124
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3125

            
3126
L<DBIx::Custom::Query>
3127
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3128
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3129
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3130
    table # will be removed at 2017/1/1
3131
    filters # will be removed at 2017/1/1
3132
    
3133
    # Methods
3134
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3135

            
3136
L<DBIx::Custom::QueryBuilder>
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
    tags # will be removed at 2017/1/1
3140
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3141
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3142
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3143
    register_tag # will be removed at 2017/1/1
3144
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3145
    
3146
    # Others
3147
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3148
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3149

            
3150
L<DBIx::Custom::Result>
3151
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3152
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3153
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3154
    
3155
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3156
    end_filter # will be removed at 2017/1/1
3157
    remove_end_filter # will be removed at 2017/1/1
3158
    remove_filter # will be removed at 2017/1/1
3159
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3160

            
3161
L<DBIx::Custom::Tag>
3162

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

            
3165
=head1 BACKWORD COMPATIBLE POLICY
3166

            
3167
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3168
except for attribute method.
3169
You can check all DEPRECATED functionalities by document.
3170
DEPRECATED functionality is removed after five years,
3171
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
3172
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3173

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

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

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

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

            
3182
C<< <kimoto.yuki at gmail.com> >>
3183

            
3184
L<http://github.com/yuki-kimoto/DBIx-Custom>
3185

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3186
=head1 AUTHOR
3187

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

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

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

            
3194
This program is free software; you can redistribute it and/or modify it
3195
under the same terms as Perl itself.
3196

            
3197
=cut