DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3154 lines | 81.657kb
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
Yuki Kimoto authored on 2011-07-29
4
our $VERSION = '0.1704';
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
5
use 5.008001;
cleanup
yuki-kimoto authored on 2009-12-22
6

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

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

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

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

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
81
sub assign_param {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
82
    my ($self, $param) = @_;
83
    
84
    # Create set tag
85
    my @params;
86
    my $safety = $self->safety_character;
87
    foreach my $column (keys %$param) {
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;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
92
        push @params, "$column_quote = :$column";
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
93
    }
94
    my $tag = join(', ', @params);
95
    
96
    return $tag;
97
}
98

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

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

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

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

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

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

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

            
added helper method
yuki-kimoto authored on 2010-10-17
220
sub DESTROY { }
221

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
222
sub create_model {
223
    my $self = shift;
224
    
cleanup
Yuki Kimoto authored on 2011-04-02
225
    # Arguments
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
226
    my $args = ref $_[0] eq 'HASH' ? $_[0] : {@_};
227
    $args->{dbi} = $self;
228
    my $model_class = delete $args->{model_class} || 'DBIx::Custom::Model';
229
    my $model_name  = delete $args->{name};
230
    my $model_table = delete $args->{table};
231
    $model_name ||= $model_table;
232
    
cleanup
Yuki Kimoto authored on 2011-04-02
233
    # Create model
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
234
    my $model = $model_class->new($args);
235
    $model->name($model_name) unless $model->name;
236
    $model->table($model_table) unless $model->table;
237
    
238
    # Apply filter
DBIx::Custom::Model filter a...
Yuki Kimoto authored on 2011-04-18
239
    my $filter = ref $model->filter eq 'HASH'
240
               ? [%{$model->filter}]
241
               : $model->filter;
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
242
    warn "DBIx::Custom::Model filter method is DEPRECATED!"
243
      if @$filter;
cleanup
Yuki Kimoto authored on 2011-06-13
244
    $self->_apply_filter($model->table, @$filter);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
245

            
246
    # Set model
247
    $self->model($model->name, $model);
248
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
249
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
250
}
251

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

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
271
sub each_table {
272
    my ($self, $cb) = @_;
273
    
274
    # Iterate all tables
275
    my $sth_tables = $self->dbh->table_info;
276
    while (my $table_info = $sth_tables->fetchrow_hashref) {
277
        
278
        # Table
279
        my $table = $table_info->{TABLE_NAME};
280
        $self->$cb($table, $table_info);
281
    }
282
}
283

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
975
                    $self->{"_$into"}{$table}{$column} = $filter;
976
                }
977
            });
978
        }
979

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
1383
sub _remove_duplicate_table {
1384
    my ($self, $tables, $main_table) = @_;
1385
    
1386
    # Remove duplicate table
1387
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1388
    delete $tables{$main_table} if $main_table;
1389
    
1390
    return [keys %tables, $main_table ? $main_table : ()];
1391
}
1392

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1764
=head1 NAME
1765

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

            
1768
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1769

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-29
1839
Model support
1840

            
1841
=item *
1842

            
1843
Connection manager support
1844

            
1845
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1846

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

            
1851
=item *
1852

            
1853
Filtering by data type or column name(EXPERIMENTAL)
1854

            
1855
=item *
1856

            
1857
Create C<order by> clause flexibly(EXPERIMENTAL)
1858

            
1859
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1860

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

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

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

            
1868
Mosdule documentations - 
1869
L<DBIx::Custom::Result>,
1870
L<DBIx::Custom::Query>,
1871
L<DBIx::Custom::Where>,
1872
L<DBIx::Custom::Model>,
1873
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
1874

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

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

            
1879
    my $connector = $dbi->connector;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1880
    $dbi = $dbi->connector(DBIx::Connector->new(...));
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
1881

            
updated pod
Yuki Kimoto authored on 2011-06-21
1882
Connection manager object. if connector is set, you can get C<dbh>
1883
through connection manager. conection manager object must have C<dbh> mehtod.
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
1884

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

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

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

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

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

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

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

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

            
1912
=head2 C<default_dbi_option>
1913

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

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

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

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

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

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

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

            
1935
    my $last_sql = $dbi->last_sql;
1936
    $dbi = $dbi->last_sql($last_sql);
1937

            
1938
Get last successed SQL executed by C<execute> method.
1939

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1947
=head2 C<password>
1948

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1987
    my $tag_parse = $dbi->tag_parse(0);
1988
    $dbi = $dbi->tag_parse;
1989

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

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

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

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

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

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

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

            
2008
    print $dbi->available_data_type;
2009

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

            
2013
=head2 C<available_type_name> EXPERIMENTAL
2014

            
2015
    print $dbi->available_type_name;
2016

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

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

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

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

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

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

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

            
2034
Create column clause. The follwoing column clause is created.
2035

            
2036
    book.author as "book.author",
2037
    book.title as "book.title"
2038

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

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

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

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

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

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

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

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

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

            
2081
   $dbi->model('book')->select(...);
2082

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

            
2085
    my $dbh = $dbi->dbh;
2086

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

            
2090
=head2 C<each_column>
2091

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

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

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

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

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

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2142
Parameter is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2143
    
2144
    # Before
2145
    select * from book where title = :title and author like :author
2146
    
2147
    # After
2148
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2149

            
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2150
You can specify operator with parameter by C<name{operator}> syntax.
2151
This is EXPERIMENTAL.
2152

            
2153
    # Before
2154
    select * from book where :title{=} and :author{like}
2155
    
2156
    # After
update pod
Yuki Kimoto authored on 2011-03-13
2157
    select * from where title = ? and author like ?;
2158

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

            
2161
=over 4
2162

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

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

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

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

            
2188
    query => 1
2189

            
2190
C<execute> method return L<DBIx::Custom::Query> object, not executing SQL.
updated pod
Yuki Kimoto authored on 2011-06-21
2191
You can check executed SQL and columns order.
2192

            
2193
    my $sql = $query->sql;
2194
    my $columns = $query->columns;
updated document
Yuki Kimoto authored on 2011-06-09
2195

            
updated pod
Yuki Kimoto authored on 2011-06-09
2196
=item C<table>
2197
    
2198
    table => 'author'
2199

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2207
    # Same
2208
    $dbi->execute(
2209
      "select * from book where title = :book.title and author = :book.author",
2210
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2211

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

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

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

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

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

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

            
2225
    table_alias => {user => 'hiker'}
2226

            
2227
Table alias. Key is real table name, value is alias table name.
2228
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2229
on alias table name.
2230

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

            
2233
    type_rule_off => 1
2234

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

            
2237
=item C<type_rule1_off> EXPERIMENTAL
2238

            
2239
    type_rule1_off => 1
2240

            
2241
Turn C<into1> type rule off.
2242

            
2243
=item C<type_rule2_off> EXPERIMENTAL
2244

            
2245
    type_rule2_off => 1
2246

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2259
=over 4
2260

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

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

            
2265
=item C<filter>
2266

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2271
    id => 4
2272
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2273

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2277
    $dbi->delete(
2278
        parimary_key => ['id1', 'id2'],
2279
        id => [4, 5],
2280
        table => 'book',
2281
    );
update pod
Yuki Kimoto authored on 2011-03-13
2282

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

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

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

            
2289
    prefix => 'some'
2290

            
2291
prefix before table name section.
2292

            
2293
    delete some from book
2294

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2303
Table name.
2304

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

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

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

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

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

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

            
2317
=item C<type_rule_off> EXPERIMENTAL
2318

            
2319
Same as C<execute> method's C<type_rule_off> option.
2320

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

            
2323
    type_rule1_off => 1
2324

            
2325
Same as C<execute> method's C<type_rule1_off> option.
2326

            
2327
=item C<type_rule2_off> EXPERIMENTAL
2328

            
2329
    type_rule2_off => 1
2330

            
2331
Same as C<execute> method's C<type_rule2_off> option.
2332

            
updated pod
Yuki Kimoto authored on 2011-06-08
2333
=back
update pod
Yuki Kimoto authored on 2011-03-13
2334

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2342
=head2 C<insert>
2343

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

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

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

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

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

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

            
2357
=item C<filter>
2358

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

            
2361
=item C<id>
2362

            
updated document
Yuki Kimoto authored on 2011-06-09
2363
    id => 4
2364
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2365

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2369
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2370
        {title => 'Perl', author => 'Ken'}
2371
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2372
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2373
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2374
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2375

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

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

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

            
2385
    prefix => 'or replace'
2386

            
2387
prefix before table name section
2388

            
2389
    insert or replace into book
2390

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

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

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

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

            
2400
Same as C<execute> method's C<query> option.
2401

            
2402
=item C<table>
2403

            
2404
    table => 'book'
2405

            
2406
Table name.
2407

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

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

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

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

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

            
2418
    type_rule1_off => 1
2419

            
2420
Same as C<execute> method's C<type_rule1_off> option.
2421

            
2422
=item C<type_rule2_off> EXPERIMENTAL
2423

            
2424
    type_rule2_off => 1
2425

            
2426
Same as C<execute> method's C<type_rule2_off> option.
2427

            
update pod
Yuki Kimoto authored on 2011-03-13
2428
=back
2429

            
2430
=over 4
2431

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2447
    lib / MyModel.pm
2448
        / MyModel / book.pm
2449
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2450

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

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

            
2455
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2456
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2457
    
2458
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2459

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2464
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2465
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2466
    
2467
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2468

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2471
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2472
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2473
    
2474
    1;
2475
    
updated pod
Yuki Kimoto authored on 2011-06-21
2476
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2477

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

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

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

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

            
2487
    my $map_param = $dbi->map_param(
2488
        {id => 1, authro => 'Ken', price => 1900},
2489
        'id' => 'book.id',
2490
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2491
        'price' => [
2492
            'book.price', {if => sub { length $_[0] }}
2493
        ]
2494
    );
2495

            
2496
Map paramters to other key and value. First argument is original
2497
parameter. this is hash reference. Rest argument is mapping.
2498
By default, Mapping is done if the value length is not zero.
2499

            
2500
=over 4
2501

            
2502
=item Key mapping
2503

            
2504
    'id' => 'book.id'
2505

            
2506
This is only key mapping. Value is same as original one.
2507

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

            
2510
=item Key and value mapping
2511

            
2512
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2513

            
2514
This is key and value mapping. Frist element of array reference
2515
is mapped key name, second element is code reference to map the value.
2516

            
2517
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2518
      if value length is not zero.
2519

            
2520
=item Condition
2521

            
2522
    'price' => ['book.price', {if => 'exists'}]
2523
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2524
    'price' => ['book.price', {if => sub { defined shift }}]
2525

            
2526
If you need condition, you can sepecify it. this is code reference
2527
or 'exists'. By default, condition is the following one.
2528

            
2529
    sub { defined $_[0] && length $_[0] }
2530

            
2531
=back
2532

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

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

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

            
2539
    {key1 => [1, 1], key2 => 2}
2540

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

            
2543
    $dbi->method(
2544
        update_or_insert => sub {
2545
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2546
            
2547
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2548
        },
2549
        find_or_create   => sub {
2550
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2551
            
2552
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2553
        }
2554
    );
2555

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

            
2558
    $dbi->update_or_insert;
2559
    $dbi->find_or_create;
2560

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

            
2563
    my $model = $dbi->model('book');
2564

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

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

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

            
2571
Create column clause for myself. The follwoing column clause is created.
2572

            
2573
    book.author as author,
2574
    book.title as title
2575

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2578
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2579
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2580
        user => 'ken',
2581
        password => '!LFKD%$&',
2582
        dbi_option => {mysql_enable_utf8 => 1}
2583
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2584

            
2585
Create a new L<DBIx::Custom> object.
2586

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

            
2589
    my $not_exists = $dbi->not_exists;
2590

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

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

            
2596
    my $order = $dbi->order;
2597

            
2598
Create a new L<DBIx::Custom::Order> object.
2599

            
cleanup
yuki-kimoto authored on 2010-10-17
2600
=head2 C<register_filter>
2601

            
update pod
Yuki Kimoto authored on 2011-03-13
2602
    $dbi->register_filter(
2603
        # Time::Piece object to database DATE format
2604
        tp_to_date => sub {
2605
            my $tp = shift;
2606
            return $tp->strftime('%Y-%m-%d');
2607
        },
2608
        # database DATE format to Time::Piece object
2609
        date_to_tp => sub {
2610
           my $date = shift;
2611
           return Time::Piece->strptime($date, '%Y-%m-%d');
2612
        }
2613
    );
cleanup
yuki-kimoto authored on 2010-10-17
2614
    
update pod
Yuki Kimoto authored on 2011-03-13
2615
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2616

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

            
2619
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2620
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2621
            date => sub { ... },
2622
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2623
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2624
        into2 => {
2625
            date => sub { ... },
2626
            datetime => sub { ... }
2627
        },
2628
        from1 => {
2629
            # DATE
2630
            9 => sub { ... },
2631
            # DATETIME or TIMESTAMP
2632
            11 => sub { ... },
2633
        }
2634
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2635
            # DATE
2636
            9 => sub { ... },
2637
            # DATETIME or TIMESTAMP
2638
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2639
        }
2640
    );
2641

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2657
=over 4
2658

            
2659
=item 1. column name
2660

            
2661
    issue_date
2662
    issue_datetime
2663

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

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

            
2668
    book.issue_date
2669
    book.issue_datetime
2670

            
2671
=back
2672

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

            
2675
    print $dbi->available_type_name;
2676

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

            
2681
    print $dbi->available_data_type;
2682

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

            
2685
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2686
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2687
            [qw/DATE DATETIME/] => sub { ... },
2688
        ],
2689
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2690

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2693
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2694
        table  => 'book',
2695
        column => ['author', 'title'],
2696
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2697
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2698
    
updated document
Yuki Kimoto authored on 2011-06-09
2699
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2700

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

            
2703
=over 4
2704

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2709
Append statement to last of SQL.
2710
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2711
=item C<column>
2712
    
updated document
Yuki Kimoto authored on 2011-06-09
2713
    column => 'author'
2714
    column => ['author', 'title']
2715

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2724
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2725
        {book => [qw/author title/]},
2726
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2727
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2728

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

            
2731
    book.author as "book.author",
2732
    book.title as "book.title",
2733
    person.name as "person.name",
2734
    person.age as "person.age"
2735

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

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

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

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

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

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

            
2751
=item C<id>
2752

            
2753
    id => 4
2754
    id => [4, 5]
2755

            
2756
ID corresponding to C<primary_key>.
2757
You can select rows by C<id> and C<primary_key>.
2758

            
2759
    $dbi->select(
2760
        parimary_key => ['id1', 'id2'],
2761
        id => [4, 5],
2762
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2763
    );
2764

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
2767
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
2768
        where => {id1 => 4, id2 => 5},
2769
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2770
    );
2771
    
updated document
Yuki Kimoto authored on 2011-06-09
2772
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2773

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

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

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

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

            
2786
    prefix => 'SQL_CALC_FOUND_ROWS'
2787

            
2788
Prefix of column cluase
2789

            
2790
    select SQL_CALC_FOUND_ROWS title, author from book;
2791

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

            
2794
    join => [
2795
        'left outer join company on book.company_id = company_id',
2796
        'left outer join location on company.location_id = location.id'
2797
    ]
2798
        
2799
Join clause. If column cluase or where clause contain table name like "company.name",
2800
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
2801

            
2802
    $dbi->select(
2803
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2804
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2805
        where => {'company.name' => 'Orange'},
2806
        join => [
2807
            'left outer join company on book.company_id = company.id',
2808
            'left outer join location on company.location_id = location.id'
2809
        ]
2810
    );
2811

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2815
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2816
    from book
2817
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2818
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2819

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

            
2823
    $dbi->select(
2824
        table => 'book',
2825
        column => ['company.location_id as location_id'],
2826
        where => {'company.name' => 'Orange'},
2827
        join => [
2828
            {
2829
                clause => 'left outer join location on company.location_id = location.id',
2830
                table => ['company', 'location']
2831
            }
2832
        ]
2833
    );
2834

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2854
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2855

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

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

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

            
2862
    type_rule1_off => 1
2863

            
2864
Same as C<execute> method's C<type_rule1_off> option.
2865

            
2866
=item C<type_rule2_off> EXPERIMENTAL
2867

            
2868
    type_rule2_off => 1
2869

            
2870
Same as C<execute> method's C<type_rule2_off> option.
2871

            
updated document
Yuki Kimoto authored on 2011-06-09
2872
=item C<where>
2873
    
2874
    # Hash refrence
2875
    where => {author => 'Ken', 'title' => 'Perl'}
2876
    
2877
    # DBIx::Custom::Where object
2878
    where => $dbi->where(
2879
        clause => ['and', 'author = :author', 'title like :title'],
2880
        param  => {author => 'Ken', title => '%Perl%'}
2881
    );
updated pod
Yuki Kimoto authored on 2011-06-21
2882
    
2883
    # Array reference 1 (array reference, hash referenc). same as above
2884
    where => [
2885
        ['and', 'author = :author', 'title like :title'],
2886
        {author => 'Ken', title => '%Perl%'}
2887
    ];    
2888
    
2889
    # Array reference 2 (String, hash reference)
2890
    where => [
2891
        'title like :title',
2892
        {title => '%Perl%'}
2893
    ]
2894
    
2895
    # String
2896
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
2897

            
updated document
Yuki Kimoto authored on 2011-06-09
2898
Where clause.
2899
    
improved pod
Yuki Kimoto authored on 2011-04-19
2900
=item C<wrap> EXPERIMENTAL
2901

            
2902
Wrap statement. This is array reference.
2903

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

            
2906
This option is for Oracle and SQL Server paging process.
2907

            
update pod
Yuki Kimoto authored on 2011-03-12
2908
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2909

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2914
Execute update statement. First argument is update data.
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2915

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2918
=over 4
2919

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2930
    id => 4
2931
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2932

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2936
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
2937
        {title => 'Perl', author => 'Ken'}
2938
        parimary_key => ['id1', 'id2'],
2939
        id => [4, 5],
2940
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2941
    );
update pod
Yuki Kimoto authored on 2011-03-13
2942

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2945
    $dbi->update(
2946
        {title => 'Perl', author => 'Ken'}
2947
        where => {id1 => 4, id2 => 5},
2948
        table => 'book'
2949
    );
update pod
Yuki Kimoto authored on 2011-03-13
2950

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

            
2953
    prefix => 'or replace'
2954

            
2955
prefix before table name section
2956

            
2957
    update or replace book
2958

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

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

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

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

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

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

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

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

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

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

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

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

            
2984
=item C<type_rule_off> EXPERIMENTAL
2985

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

            
2988
=item C<type_rule1_off> EXPERIMENTAL
2989

            
2990
    type_rule1_off => 1
2991

            
2992
Same as C<execute> method's C<type_rule1_off> option.
2993

            
2994
=item C<type_rule2_off> EXPERIMENTAL
2995

            
2996
    type_rule2_off => 1
2997

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3000
=back
update pod
Yuki Kimoto authored on 2011-03-13
3001

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

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

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

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

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

            
3013
Create update parameter tag.
3014

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

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

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

            
3024
Create a new L<DBIx::Custom::Where> object.
3025

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

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

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

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

            
3035
=head2 C<DBIX_CUSTOM_DEBUG>
3036

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

            
3040
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3041

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

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

            
3046
L<DBIx::Custom>
3047

            
3048
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3049
    data_source # will be removed at 2017/1/1
3050
    dbi_options # will be removed at 2017/1/1
3051
    filter_check # will be removed at 2017/1/1
3052
    reserved_word_quote # will be removed at 2017/1/1
3053
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3054
    
3055
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3056
    create_query # will be removed at 2017/1/1
3057
    apply_filter # will be removed at 2017/1/1
3058
    select_at # will be removed at 2017/1/1
3059
    delete_at # will be removed at 2017/1/1
3060
    update_at # will be removed at 2017/1/1
3061
    insert_at # will be removed at 2017/1/1
3062
    register_tag # will be removed at 2017/1/1
3063
    default_bind_filter # will be removed at 2017/1/1
3064
    default_fetch_filter # will be removed at 2017/1/1
3065
    insert_param_tag # will be removed at 2017/1/1
3066
    register_tag_processor # will be removed at 2017/1/1
3067
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3068
    
3069
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3070
    select method relation option # will be removed at 2017/1/1
3071
    select method param option # will be removed at 2017/1/1
3072
    select method column option [COLUMN, as => ALIAS] format
3073
      # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3074
    
3075
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3076
    execute("select * from {= title}"); # execute method's
3077
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3078
                                        # will be removed at 2017/1/1
3079
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3080

            
3081
L<DBIx::Custom::Model>
3082

            
3083
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3084
    filter # will be removed at 2017/1/1
3085
    name # will be removed at 2017/1/1
3086
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3087

            
3088
L<DBIx::Custom::Query>
3089
    
3090
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3091
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3092

            
3093
L<DBIx::Custom::QueryBuilder>
3094
    
3095
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3096
    tags # will be removed at 2017/1/1
3097
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3098
    
3099
    # Method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3100
    register_tag # will be removed at 2017/1/1
3101
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3102
    
3103
    # Others
3104
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3105
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3106

            
3107
L<DBIx::Custom::Result>
3108
    
3109
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3110
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3111
    
3112
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3113
    end_filter # will be removed at 2017/1/1
3114
    remove_end_filter # will be removed at 2017/1/1
3115
    remove_filter # will be removed at 2017/1/1
3116
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3117

            
3118
L<DBIx::Custom::Tag>
3119

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

            
3122
=head1 BACKWORD COMPATIBLE POLICY
3123

            
3124
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3125
except for attribute method.
3126
You can check all DEPRECATED functionalities by document.
3127
DEPRECATED functionality is removed after five years,
3128
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
3129
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3130

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

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

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

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

            
3139
C<< <kimoto.yuki at gmail.com> >>
3140

            
3141
L<http://github.com/yuki-kimoto/DBIx-Custom>
3142

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3143
=head1 AUTHOR
3144

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

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

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

            
3151
This program is free software; you can redistribute it and/or modify it
3152
under the same terms as Perl itself.
3153

            
3154
=cut