DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3204 lines | 83.29kb
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',
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
57
    stash => sub { {} },
58
    tag_parse => 1;
cleanup
yuki-kimoto authored on 2010-10-17
59

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
1074
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1075
}
1076

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

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

            
1105
        # Create query
1106
        my $builder = $self->query_builder;
1107
        $query = $builder->build_query($source);
1108

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

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

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

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1271
sub _need_tables {
1272
    my ($self, $tree, $need_tables, $tables) = @_;
1273
    
cleanup
Yuki Kimoto authored on 2011-04-02
1274
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1275
    foreach my $table (@$tables) {
1276
        if ($tree->{$table}) {
1277
            $need_tables->{$table} = 1;
1278
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1279
        }
1280
    }
1281
}
1282

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

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1348
sub _quote {
1349
    my $self = shift;
1350
    
1351
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1352
         : defined $self->quote ? $self->quote
1353
         : '';
1354
}
1355

            
cleanup
Yuki Kimoto authored on 2011-07-29
1356
sub _q {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1357
    my ($self, $value) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1358
    
1359
    my $quote = $self->_quote;
1360
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1361
    my $p;
1362
    if (defined $quote && length $quote > 1) {
1363
        $p = substr($quote, 1, 1);
1364
    }
1365
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1366
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1367
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1368
}
1369

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

            
1383
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1384
}
1385

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

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

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

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

            
1513
# DEPRECATED!
1514
sub create_query {
1515
    warn "create_query is DEPRECATED! use query option of each method";
1516
    shift->_create_query(@_);
1517
}
1518

            
cleanup
Yuki Kimoto authored on 2011-06-13
1519
# DEPRECATED!
1520
sub apply_filter {
1521
    my $self = shift;
1522
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1523
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1524
    return $self->_apply_filter(@_);
1525
}
1526

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-08
1581
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1582
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1583
sub update_at {
1584
    my $self = shift;
1585

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

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

            
added warnings
Yuki Kimoto authored on 2011-06-07
1640
# DEPRECATED!
1641
sub register_tag {
1642
    warn "register_tag is DEPRECATED!";
1643
    shift->query_builder->register_tag(@_)
1644
}
1645

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1646
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
1647
has 'data_source';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1648
has dbi_options => sub { {} };
1649
has filter_check  => 1;
1650
has 'reserved_word_quote';
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1651

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

            
cleanup
Yuki Kimoto authored on 2011-01-25
1676
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1677
sub default_fetch_filter {
1678
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1679

            
cleanup
Yuki Kimoto authored on 2011-06-13
1680
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1681
    
1682
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1683
        my $fname = $_[0];
1684

            
cleanup
Yuki Kimoto authored on 2011-01-12
1685
        if (@_ && !$fname) {
1686
            $self->{default_in_filter} = undef;
1687
        }
1688
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1689
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1690
              unless exists $self->filters->{$fname};
1691
        
1692
            $self->{default_in_filter} = $self->filters->{$fname};
1693
        }
1694
        
1695
        return $self;
1696
    }
1697
    
many changed
Yuki Kimoto authored on 2011-01-23
1698
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1699
}
1700

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1701
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1702
sub insert_param_tag {
1703
    warn "insert_param_tag is DEPRECATED! " .
1704
         "use insert_param instead!";
1705
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1706
}
1707

            
cleanup
Yuki Kimoto authored on 2011-01-25
1708
# DEPRECATED!
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1709
sub register_tag_processor {
added warnings
Yuki Kimoto authored on 2011-06-07
1710
    warn "register_tag_processor is DEPRECATED!";
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1711
    return shift->query_builder->register_tag_processor(@_);
1712
}
1713

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1758
=head1 NAME
1759

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

            
1762
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1763

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1833
Named place holder support
1834

            
1835
=item *
1836

            
cleanup
Yuki Kimoto authored on 2011-07-29
1837
Model support
1838

            
1839
=item *
1840

            
1841
Connection manager support
1842

            
1843
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1844

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

            
1849
=item *
1850

            
1851
Filtering by data type or column name(EXPERIMENTAL)
1852

            
1853
=item *
1854

            
1855
Create C<order by> clause flexibly(EXPERIMENTAL)
1856

            
1857
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1858

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1910
=head2 C<default_dbi_option>
1911

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

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

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

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

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

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

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

            
1933
    my $last_sql = $dbi->last_sql;
1934
    $dbi = $dbi->last_sql($last_sql);
1935

            
1936
Get last successed SQL executed by C<execute> method.
1937

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1945
=head2 C<password>
1946

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1968
You can set quote pair.
1969

            
1970
    $dbi->quote('[]');
1971

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

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

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

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

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

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

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

            
1989
    my $tag_parse = $dbi->tag_parse(0);
1990
    $dbi = $dbi->tag_parse;
1991

            
1992
Enable DEPRECATED tag parsing functionality, default to 1.
1993
If you want to disable tag parsing functionality, set to 0.
1994

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2036
Create column clause. The follwoing column clause is created.
2037

            
2038
    book.author as "book.author",
2039
    book.title as "book.title"
2040

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2043
    # Separator is double underbar
2044
    $dbi->separator('__');
2045
    
2046
    book.author as "book__author",
2047
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2048

            
cleanup
Yuki Kimoto authored on 2011-06-13
2049
    # Separator is hyphen
2050
    $dbi->separator('-');
2051
    
2052
    book.author as "book-author",
2053
    book.title as "book-title"
2054
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2055
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2056

            
update pod
Yuki Kimoto authored on 2011-03-13
2057
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2058
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2059
        user => 'ken',
2060
        password => '!LFKD%$&',
2061
        dbi_option => {mysql_enable_utf8 => 1}
2062
    );
2063

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

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

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2072
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2073
        table => 'book',
2074
        primary_key => 'id',
2075
        join => [
2076
            'inner join company on book.comparny_id = company.id'
2077
        ],
2078
    );
2079

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

            
2083
   $dbi->model('book')->select(...);
2084

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

            
2087
    my $dbh = $dbi->dbh;
2088

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

            
2092
=head2 C<each_column>
2093

            
2094
    $dbi->each_column(
2095
        sub {
2096
            my ($dbi, $table, $column, $column_info) = @_;
2097
            
2098
            my $type = $column_info->{TYPE_NAME};
2099
            
2100
            if ($type eq 'DATE') {
2101
                # ...
2102
            }
2103
        }
2104
    );
2105

            
2106
Iterate all column informations of all table from database.
2107
Argument is callback when one column is found.
2108
Callback receive four arguments, dbi object, table name,
2109
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2110

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

            
2113
    $dbi->each_table(
2114
        sub {
2115
            my ($dbi, $table, $table_info) = @_;
2116
            
2117
            my $table_name = $table_info->{TABLE_NAME};
2118
        }
2119
    );
2120

            
2121
Iterate all table informationsfrom database.
2122
Argument is callback when one table is found.
2123
Callback receive three arguments, dbi object, table name,
2124
table information.
2125

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

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

            
2133
    my $result = $dbi->execute(
2134
      "select * from book where title = :book.title and author like :book.author",
2135
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2136
    );
2137

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2144
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2145
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2146
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2147
    select * from book where title = :title and author like :author
2148
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2149
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2150
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2151

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2155
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2156
    select * from book where :title{=} and :author{like}
2157
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2158
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2159
    select * from where title = ? and author like ?;
2160

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

            
2165
    select * from where title = "aa\\:bb";
2166

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

            
2169
=over 4
2170

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

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

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

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

            
2196
    query => 1
2197

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

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

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2231
=item C<table>
2232
    
2233
    table => 'author'
2234

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

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

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

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

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

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

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

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

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

            
2260
    table_alias => {user => 'hiker'}
2261

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

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

            
2268
    type_rule_off => 1
2269

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

            
2272
=item C<type_rule1_off> EXPERIMENTAL
2273

            
2274
    type_rule1_off => 1
2275

            
2276
Turn C<into1> type rule off.
2277

            
2278
=item C<type_rule2_off> EXPERIMENTAL
2279

            
2280
    type_rule2_off => 1
2281

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2294
=over 4
2295

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

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

            
2300
=item C<filter>
2301

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2306
    id => 4
2307
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2308

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

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

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

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

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

            
2324
    prefix => 'some'
2325

            
2326
prefix before table name section.
2327

            
2328
    delete some from book
2329

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2338
Table name.
2339

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

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

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

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

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

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

            
2352
=item C<type_rule_off> EXPERIMENTAL
2353

            
2354
Same as C<execute> method's C<type_rule_off> option.
2355

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

            
2358
    type_rule1_off => 1
2359

            
2360
Same as C<execute> method's C<type_rule1_off> option.
2361

            
2362
=item C<type_rule2_off> EXPERIMENTAL
2363

            
2364
    type_rule2_off => 1
2365

            
2366
Same as C<execute> method's C<type_rule2_off> option.
2367

            
updated pod
Yuki Kimoto authored on 2011-06-08
2368
=back
update pod
Yuki Kimoto authored on 2011-03-13
2369

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2377
=head2 C<insert>
2378

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

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

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

            
2387
    {date => \"NOW()"}
2388

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

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

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

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

            
2397
=item C<filter>
2398

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

            
2401
=item C<id>
2402

            
updated document
Yuki Kimoto authored on 2011-06-09
2403
    id => 4
2404
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2405

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

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

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

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

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

            
2425
    prefix => 'or replace'
2426

            
2427
prefix before table name section
2428

            
2429
    insert or replace into book
2430

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

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

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

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

            
2440
Same as C<execute> method's C<query> option.
2441

            
2442
=item C<table>
2443

            
2444
    table => 'book'
2445

            
2446
Table name.
2447

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

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

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

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

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

            
2458
    type_rule1_off => 1
2459

            
2460
Same as C<execute> method's C<type_rule1_off> option.
2461

            
2462
=item C<type_rule2_off> EXPERIMENTAL
2463

            
2464
    type_rule2_off => 1
2465

            
2466
Same as C<execute> method's C<type_rule2_off> option.
2467

            
update pod
Yuki Kimoto authored on 2011-03-13
2468
=back
2469

            
2470
=over 4
2471

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2540
=over 4
2541

            
2542
=item Key mapping
2543

            
2544
    'id' => 'book.id'
2545

            
2546
This is only key mapping. Value is same as original one.
2547

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

            
2550
=item Key and value mapping
2551

            
2552
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2553

            
2554
This is key and value mapping. Frist element of array reference
2555
is mapped key name, second element is code reference to map the value.
2556

            
2557
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2558
      if value length is not zero.
2559

            
2560
=item Condition
2561

            
2562
    'price' => ['book.price', {if => 'exists'}]
2563
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2564
    'price' => ['book.price', {if => sub { defined shift }}]
2565

            
2566
If you need condition, you can sepecify it. this is code reference
2567
or 'exists'. By default, condition is the following one.
2568

            
2569
    sub { defined $_[0] && length $_[0] }
2570

            
2571
=back
2572

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

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

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

            
2579
    {key1 => [1, 1], key2 => 2}
2580

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

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

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

            
2598
    $dbi->update_or_insert;
2599
    $dbi->find_or_create;
2600

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

            
2603
    my $model = $dbi->model('book');
2604

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

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

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

            
2611
Create column clause for myself. The follwoing column clause is created.
2612

            
2613
    book.author as author,
2614
    book.title as title
2615

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

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

            
2625
Create a new L<DBIx::Custom> object.
2626

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

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

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

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

            
2636
    my $order = $dbi->order;
2637

            
2638
Create a new L<DBIx::Custom::Order> object.
2639

            
cleanup
yuki-kimoto authored on 2010-10-17
2640
=head2 C<register_filter>
2641

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2697
=over 4
2698

            
2699
=item 1. column name
2700

            
2701
    issue_date
2702
    issue_datetime
2703

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

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

            
2708
    book.issue_date
2709
    book.issue_datetime
2710

            
2711
=back
2712

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

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

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

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

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

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

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

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

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

            
2743
=over 4
2744

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

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

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

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

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

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

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

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

            
2771
    book.author as "book.author",
2772
    book.title as "book.title",
2773
    person.name as "person.name",
2774
    person.age as "person.age"
2775

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

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

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

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

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

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

            
2791
=item C<id>
2792

            
2793
    id => 4
2794
    id => [4, 5]
2795

            
2796
ID corresponding to C<primary_key>.
2797
You can select rows by C<id> and C<primary_key>.
2798

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

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

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

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

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

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

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

            
2826
    prefix => 'SQL_CALC_FOUND_ROWS'
2827

            
2828
Prefix of column cluase
2829

            
2830
    select SQL_CALC_FOUND_ROWS title, author from book;
2831

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2894
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2895

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

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

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

            
2902
    type_rule1_off => 1
2903

            
2904
Same as C<execute> method's C<type_rule1_off> option.
2905

            
2906
=item C<type_rule2_off> EXPERIMENTAL
2907

            
2908
    type_rule2_off => 1
2909

            
2910
Same as C<execute> method's C<type_rule2_off> option.
2911

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

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

            
2942
Wrap statement. This is array reference.
2943

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

            
2946
This option is for Oracle and SQL Server paging process.
2947

            
update pod
Yuki Kimoto authored on 2011-03-12
2948
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2949

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

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

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

            
2956
If you want to set constant value to row data, use scalar reference
2957
as parameter value.
2958

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2963
=over 4
2964

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2975
    id => 4
2976
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2977

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

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

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

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

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

            
2998
    prefix => 'or replace'
2999

            
3000
prefix before table name section
3001

            
3002
    update or replace book
3003

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

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

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

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

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

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

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

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

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

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

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

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

            
3029
=item C<type_rule_off> EXPERIMENTAL
3030

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

            
3033
=item C<type_rule1_off> EXPERIMENTAL
3034

            
3035
    type_rule1_off => 1
3036

            
3037
Same as C<execute> method's C<type_rule1_off> option.
3038

            
3039
=item C<type_rule2_off> EXPERIMENTAL
3040

            
3041
    type_rule2_off => 1
3042

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3045
=back
update pod
Yuki Kimoto authored on 2011-03-13
3046

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

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

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

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

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

            
3058
Create update parameter tag.
3059

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

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

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

            
3069
Create a new L<DBIx::Custom::Where> object.
3070

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

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

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

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

            
3080
=head2 C<DBIX_CUSTOM_DEBUG>
3081

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

            
3085
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3086

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

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

            
3091
L<DBIx::Custom>
3092

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

            
3126
L<DBIx::Custom::Model>
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
    filter # will be removed at 2017/1/1
3130
    name # will be removed at 2017/1/1
3131
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3132

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

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

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

            
3168
L<DBIx::Custom::Tag>
3169

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

            
3172
=head1 BACKWORD COMPATIBLE POLICY
3173

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

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

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

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

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

            
3189
C<< <kimoto.yuki at gmail.com> >>
3190

            
3191
L<http://github.com/yuki-kimoto/DBIx-Custom>
3192

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3193
=head1 AUTHOR
3194

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

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

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

            
3201
This program is free software; you can redistribute it and/or modify it
3202
under the same terms as Perl itself.
3203

            
3204
=cut