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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1824
L<DBIx::Custom> is L<DBI> wrapper module.
1825

            
1826
=head1 FEATURES
removed reconnect method
yuki-kimoto authored on 2010-05-28
1827

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1833
=item * Execute INSERT, UPDATE, DELETE, SELECT statement easily
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1834

            
updated pod
Yuki Kimoto authored on 2011-06-21
1835
=item * You can specify bind values by hash reference
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1836

            
updated pod
Yuki Kimoto authored on 2011-06-21
1837
=item * Filtering by data type. and you can set filter to any column
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1838

            
updated pod
Yuki Kimoto authored on 2011-06-21
1839
=item * Creating where clause flexibly
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1840

            
updated pod
Yuki Kimoto authored on 2011-06-21
1841
=item * Support model
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1842

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

            
1845
=head1 GUIDE
1846

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1847
L<DBIx::Custom::Guide> - L<DBIx::Custom> Guide
pod fix
Yuki Kimoto authored on 2011-01-21
1848

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1849
=head1 Wiki
pod fix
Yuki Kimoto authored on 2011-01-21
1850

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1851
L<DBIx::Custom Wiki|https://github.com/yuki-kimoto/DBIx-Custom/wiki>
updated document
yuki-kimoto authored on 2010-08-08
1852

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

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

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

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

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

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

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

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

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

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

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

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

            
1890
=head2 C<default_dbi_option>
1891

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1898
    {
1899
        RaiseError => 1,
1900
        PrintError => 0,
1901
        AutoCommit => 1,
1902
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
1903

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

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

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

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

            
1913
    my $last_sql = $dbi->last_sql;
1914
    $dbi = $dbi->last_sql($last_sql);
1915

            
1916
Get last successed SQL executed by C<execute> method.
1917

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1925
=head2 C<password>
1926

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1965
    my $tag_parse = $dbi->tag_parse(0);
1966
    $dbi = $dbi->tag_parse;
1967

            
1968
Enable DEPRECATED tag parsing functionality, default to 1.
1969
If you want to disable tag parsing functionality, set to 0.
1970

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

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

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

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

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

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

            
1986
    print $dbi->available_data_type;
1987

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

            
1991
=head2 C<available_type_name> EXPERIMENTAL
1992

            
1993
    print $dbi->available_type_name;
1994

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

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

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

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

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

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

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

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

            
2012
Create column clause. The follwoing column clause is created.
2013

            
2014
    book.author as "book.author",
2015
    book.title as "book.title"
2016

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2019
    # Separator is double underbar
2020
    $dbi->separator('__');
2021
    
2022
    book.author as "book__author",
2023
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2024

            
cleanup
Yuki Kimoto authored on 2011-06-13
2025
    # Separator is hyphen
2026
    $dbi->separator('-');
2027
    
2028
    book.author as "book-author",
2029
    book.title as "book-title"
2030
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2031
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2032

            
update pod
Yuki Kimoto authored on 2011-03-13
2033
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2034
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2035
        user => 'ken',
2036
        password => '!LFKD%$&',
2037
        dbi_option => {mysql_enable_utf8 => 1}
2038
    );
2039

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

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

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2048
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2049
        table => 'book',
2050
        primary_key => 'id',
2051
        join => [
2052
            'inner join company on book.comparny_id = company.id'
2053
        ],
2054
    );
2055

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

            
2059
   $dbi->model('book')->select(...);
2060

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

            
2063
    my $dbh = $dbi->dbh;
2064

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

            
2068
=head2 C<each_column>
2069

            
2070
    $dbi->each_column(
2071
        sub {
2072
            my ($dbi, $table, $column, $column_info) = @_;
2073
            
2074
            my $type = $column_info->{TYPE_NAME};
2075
            
2076
            if ($type eq 'DATE') {
2077
                # ...
2078
            }
2079
        }
2080
    );
2081

            
2082
Iterate all column informations of all table from database.
2083
Argument is callback when one column is found.
2084
Callback receive four arguments, dbi object, table name,
2085
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2086

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

            
2089
    $dbi->each_table(
2090
        sub {
2091
            my ($dbi, $table, $table_info) = @_;
2092
            
2093
            my $table_name = $table_info->{TABLE_NAME};
2094
        }
2095
    );
2096

            
2097
Iterate all table informationsfrom database.
2098
Argument is callback when one table is found.
2099
Callback receive three arguments, dbi object, table name,
2100
table information.
2101

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

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

            
2109
    my $result = $dbi->execute(
2110
      "select * from book where title = :book.title and author like :book.author",
2111
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2112
    );
2113

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2120
Parameter is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2121
    
2122
    # Before
2123
    select * from book where title = :title and author like :author
2124
    
2125
    # After
2126
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2127

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

            
2131
    # Before
2132
    select * from book where :title{=} and :author{like}
2133
    
2134
    # After
update pod
Yuki Kimoto authored on 2011-03-13
2135
    select * from where title = ? and author like ?;
2136

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

            
2139
=over 4
2140

            
2141
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2142
    
2143
    filter => {
2144
        title  => sub { uc $_[0] }
2145
        author => sub { uc $_[0] }
2146
    }
update pod
Yuki Kimoto authored on 2011-03-13
2147

            
updated pod
Yuki Kimoto authored on 2011-06-09
2148
    # Filter name
2149
    filter => {
2150
        title  => 'upper_case',
2151
        author => 'upper_case'
2152
    }
2153
        
2154
    # At once
2155
    filter => [
2156
        [qw/title author/]  => sub { uc $_[0] }
2157
    ]
2158

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

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

            
2166
    query => 1
2167

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

            
2171
    my $sql = $query->sql;
2172
    my $columns = $query->columns;
updated document
Yuki Kimoto authored on 2011-06-09
2173

            
updated pod
Yuki Kimoto authored on 2011-06-09
2174
=item C<table>
2175
    
2176
    table => 'author'
2177

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2185
    # Same
2186
    $dbi->execute(
2187
      "select * from book where title = :book.title and author = :book.author",
2188
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2189

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

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

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

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

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

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

            
2203
    table_alias => {user => 'hiker'}
2204

            
2205
Table alias. Key is real table name, value is alias table name.
2206
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2207
on alias table name.
2208

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

            
2211
    type_rule_off => 1
2212

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

            
2215
=item C<type_rule1_off> EXPERIMENTAL
2216

            
2217
    type_rule1_off => 1
2218

            
2219
Turn C<into1> type rule off.
2220

            
2221
=item C<type_rule2_off> EXPERIMENTAL
2222

            
2223
    type_rule2_off => 1
2224

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2237
=over 4
2238

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

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

            
2243
=item C<filter>
2244

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2249
    id => 4
2250
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2251

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2255
    $dbi->delete(
2256
        parimary_key => ['id1', 'id2'],
2257
        id => [4, 5],
2258
        table => 'book',
2259
    );
update pod
Yuki Kimoto authored on 2011-03-13
2260

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

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

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

            
2267
    prefix => 'some'
2268

            
2269
prefix before table name section.
2270

            
2271
    delete some from book
2272

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2281
Table name.
2282

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

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

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

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

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

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

            
2295
=item C<type_rule_off> EXPERIMENTAL
2296

            
2297
Same as C<execute> method's C<type_rule_off> option.
2298

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

            
2301
    type_rule1_off => 1
2302

            
2303
Same as C<execute> method's C<type_rule1_off> option.
2304

            
2305
=item C<type_rule2_off> EXPERIMENTAL
2306

            
2307
    type_rule2_off => 1
2308

            
2309
Same as C<execute> method's C<type_rule2_off> option.
2310

            
updated pod
Yuki Kimoto authored on 2011-06-08
2311
=back
update pod
Yuki Kimoto authored on 2011-03-13
2312

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2320
=head2 C<insert>
2321

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

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

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

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

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

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

            
2335
=item C<filter>
2336

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

            
2339
=item C<id>
2340

            
updated document
Yuki Kimoto authored on 2011-06-09
2341
    id => 4
2342
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2343

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2347
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2348
        {title => 'Perl', author => 'Ken'}
2349
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2350
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2351
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2352
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2353

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

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

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

            
2363
    prefix => 'or replace'
2364

            
2365
prefix before table name section
2366

            
2367
    insert or replace into book
2368

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

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

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

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

            
2378
Same as C<execute> method's C<query> option.
2379

            
2380
=item C<table>
2381

            
2382
    table => 'book'
2383

            
2384
Table name.
2385

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

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

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

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

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

            
2396
    type_rule1_off => 1
2397

            
2398
Same as C<execute> method's C<type_rule1_off> option.
2399

            
2400
=item C<type_rule2_off> EXPERIMENTAL
2401

            
2402
    type_rule2_off => 1
2403

            
2404
Same as C<execute> method's C<type_rule2_off> option.
2405

            
update pod
Yuki Kimoto authored on 2011-03-13
2406
=back
2407

            
2408
=over 4
2409

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2425
    lib / MyModel.pm
2426
        / MyModel / book.pm
2427
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2428

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

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

            
2433
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2434
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2435
    
2436
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2437

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2442
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2443
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2444
    
2445
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2446

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2449
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2450
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2451
    
2452
    1;
2453
    
updated pod
Yuki Kimoto authored on 2011-06-21
2454
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2455

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

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

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

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

            
2465
    my $map_param = $dbi->map_param(
2466
        {id => 1, authro => 'Ken', price => 1900},
2467
        'id' => 'book.id',
2468
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2469
        'price' => [
2470
            'book.price', {if => sub { length $_[0] }}
2471
        ]
2472
    );
2473

            
2474
Map paramters to other key and value. First argument is original
2475
parameter. this is hash reference. Rest argument is mapping.
2476
By default, Mapping is done if the value length is not zero.
2477

            
2478
=over 4
2479

            
2480
=item Key mapping
2481

            
2482
    'id' => 'book.id'
2483

            
2484
This is only key mapping. Value is same as original one.
2485

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

            
2488
=item Key and value mapping
2489

            
2490
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2491

            
2492
This is key and value mapping. Frist element of array reference
2493
is mapped key name, second element is code reference to map the value.
2494

            
2495
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2496
      if value length is not zero.
2497

            
2498
=item Condition
2499

            
2500
    'price' => ['book.price', {if => 'exists'}]
2501
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2502
    'price' => ['book.price', {if => sub { defined shift }}]
2503

            
2504
If you need condition, you can sepecify it. this is code reference
2505
or 'exists'. By default, condition is the following one.
2506

            
2507
    sub { defined $_[0] && length $_[0] }
2508

            
2509
=back
2510

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

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

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

            
2517
    {key1 => [1, 1], key2 => 2}
2518

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

            
2521
    $dbi->method(
2522
        update_or_insert => sub {
2523
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2524
            
2525
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2526
        },
2527
        find_or_create   => sub {
2528
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2529
            
2530
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2531
        }
2532
    );
2533

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

            
2536
    $dbi->update_or_insert;
2537
    $dbi->find_or_create;
2538

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

            
2541
    my $model = $dbi->model('book');
2542

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

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

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

            
2549
Create column clause for myself. The follwoing column clause is created.
2550

            
2551
    book.author as author,
2552
    book.title as title
2553

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2556
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2557
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2558
        user => 'ken',
2559
        password => '!LFKD%$&',
2560
        dbi_option => {mysql_enable_utf8 => 1}
2561
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2562

            
2563
Create a new L<DBIx::Custom> object.
2564

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

            
2567
    my $not_exists = $dbi->not_exists;
2568

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

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

            
2574
    my $order = $dbi->order;
2575

            
2576
Create a new L<DBIx::Custom::Order> object.
2577

            
cleanup
yuki-kimoto authored on 2010-10-17
2578
=head2 C<register_filter>
2579

            
update pod
Yuki Kimoto authored on 2011-03-13
2580
    $dbi->register_filter(
2581
        # Time::Piece object to database DATE format
2582
        tp_to_date => sub {
2583
            my $tp = shift;
2584
            return $tp->strftime('%Y-%m-%d');
2585
        },
2586
        # database DATE format to Time::Piece object
2587
        date_to_tp => sub {
2588
           my $date = shift;
2589
           return Time::Piece->strptime($date, '%Y-%m-%d');
2590
        }
2591
    );
cleanup
yuki-kimoto authored on 2010-10-17
2592
    
update pod
Yuki Kimoto authored on 2011-03-13
2593
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2594

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

            
2597
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2598
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2599
            date => sub { ... },
2600
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2601
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2602
        into2 => {
2603
            date => sub { ... },
2604
            datetime => sub { ... }
2605
        },
2606
        from1 => {
2607
            # DATE
2608
            9 => sub { ... },
2609
            # DATETIME or TIMESTAMP
2610
            11 => sub { ... },
2611
        }
2612
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2613
            # DATE
2614
            9 => sub { ... },
2615
            # DATETIME or TIMESTAMP
2616
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2617
        }
2618
    );
2619

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2635
=over 4
2636

            
2637
=item 1. column name
2638

            
2639
    issue_date
2640
    issue_datetime
2641

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

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

            
2646
    book.issue_date
2647
    book.issue_datetime
2648

            
2649
=back
2650

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

            
2653
    print $dbi->available_type_name;
2654

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

            
2659
    print $dbi->available_data_type;
2660

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

            
2663
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2664
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2665
            [qw/DATE DATETIME/] => sub { ... },
2666
        ],
2667
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2668

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2671
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2672
        table  => 'book',
2673
        column => ['author', 'title'],
2674
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2675
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2676
    
updated document
Yuki Kimoto authored on 2011-06-09
2677
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2678

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

            
2681
=over 4
2682

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2687
Append statement to last of SQL.
2688
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2689
=item C<column>
2690
    
updated document
Yuki Kimoto authored on 2011-06-09
2691
    column => 'author'
2692
    column => ['author', 'title']
2693

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2702
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2703
        {book => [qw/author title/]},
2704
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2705
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2706

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

            
2709
    book.author as "book.author",
2710
    book.title as "book.title",
2711
    person.name as "person.name",
2712
    person.age as "person.age"
2713

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

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

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

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

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

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

            
2729
=item C<id>
2730

            
2731
    id => 4
2732
    id => [4, 5]
2733

            
2734
ID corresponding to C<primary_key>.
2735
You can select rows by C<id> and C<primary_key>.
2736

            
2737
    $dbi->select(
2738
        parimary_key => ['id1', 'id2'],
2739
        id => [4, 5],
2740
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2741
    );
2742

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
2745
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
2746
        where => {id1 => 4, id2 => 5},
2747
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2748
    );
2749
    
updated document
Yuki Kimoto authored on 2011-06-09
2750
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2751

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

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

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

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

            
2764
    prefix => 'SQL_CALC_FOUND_ROWS'
2765

            
2766
Prefix of column cluase
2767

            
2768
    select SQL_CALC_FOUND_ROWS title, author from book;
2769

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

            
2772
    join => [
2773
        'left outer join company on book.company_id = company_id',
2774
        'left outer join location on company.location_id = location.id'
2775
    ]
2776
        
2777
Join clause. If column cluase or where clause contain table name like "company.name",
2778
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
2779

            
2780
    $dbi->select(
2781
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2782
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2783
        where => {'company.name' => 'Orange'},
2784
        join => [
2785
            'left outer join company on book.company_id = company.id',
2786
            'left outer join location on company.location_id = location.id'
2787
        ]
2788
    );
2789

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2793
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2794
    from book
2795
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2796
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2797

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

            
2801
    $dbi->select(
2802
        table => 'book',
2803
        column => ['company.location_id as location_id'],
2804
        where => {'company.name' => 'Orange'},
2805
        join => [
2806
            {
2807
                clause => 'left outer join location on company.location_id = location.id',
2808
                table => ['company', 'location']
2809
            }
2810
        ]
2811
    );
2812

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2832
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2833

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

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

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

            
2840
    type_rule1_off => 1
2841

            
2842
Same as C<execute> method's C<type_rule1_off> option.
2843

            
2844
=item C<type_rule2_off> EXPERIMENTAL
2845

            
2846
    type_rule2_off => 1
2847

            
2848
Same as C<execute> method's C<type_rule2_off> option.
2849

            
updated document
Yuki Kimoto authored on 2011-06-09
2850
=item C<where>
2851
    
2852
    # Hash refrence
2853
    where => {author => 'Ken', 'title' => 'Perl'}
2854
    
2855
    # DBIx::Custom::Where object
2856
    where => $dbi->where(
2857
        clause => ['and', 'author = :author', 'title like :title'],
2858
        param  => {author => 'Ken', title => '%Perl%'}
2859
    );
updated pod
Yuki Kimoto authored on 2011-06-21
2860
    
2861
    # Array reference 1 (array reference, hash referenc). same as above
2862
    where => [
2863
        ['and', 'author = :author', 'title like :title'],
2864
        {author => 'Ken', title => '%Perl%'}
2865
    ];    
2866
    
2867
    # Array reference 2 (String, hash reference)
2868
    where => [
2869
        'title like :title',
2870
        {title => '%Perl%'}
2871
    ]
2872
    
2873
    # String
2874
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
2875

            
updated document
Yuki Kimoto authored on 2011-06-09
2876
Where clause.
2877
    
improved pod
Yuki Kimoto authored on 2011-04-19
2878
=item C<wrap> EXPERIMENTAL
2879

            
2880
Wrap statement. This is array reference.
2881

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

            
2884
This option is for Oracle and SQL Server paging process.
2885

            
update pod
Yuki Kimoto authored on 2011-03-12
2886
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2887

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2896
=over 4
2897

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2908
    id => 4
2909
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2910

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2914
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
2915
        {title => 'Perl', author => 'Ken'}
2916
        parimary_key => ['id1', 'id2'],
2917
        id => [4, 5],
2918
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2919
    );
update pod
Yuki Kimoto authored on 2011-03-13
2920

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2923
    $dbi->update(
2924
        {title => 'Perl', author => 'Ken'}
2925
        where => {id1 => 4, id2 => 5},
2926
        table => 'book'
2927
    );
update pod
Yuki Kimoto authored on 2011-03-13
2928

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

            
2931
    prefix => 'or replace'
2932

            
2933
prefix before table name section
2934

            
2935
    update or replace book
2936

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

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

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

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

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

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

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

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

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

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

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

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

            
2962
=item C<type_rule_off> EXPERIMENTAL
2963

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

            
2966
=item C<type_rule1_off> EXPERIMENTAL
2967

            
2968
    type_rule1_off => 1
2969

            
2970
Same as C<execute> method's C<type_rule1_off> option.
2971

            
2972
=item C<type_rule2_off> EXPERIMENTAL
2973

            
2974
    type_rule2_off => 1
2975

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
2978
=back
update pod
Yuki Kimoto authored on 2011-03-13
2979

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

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

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

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

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

            
2991
Create update parameter tag.
2992

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

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

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

            
3002
Create a new L<DBIx::Custom::Where> object.
3003

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

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

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

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

            
3013
=head2 C<DBIX_CUSTOM_DEBUG>
3014

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

            
3018
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3019

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

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

            
3024
L<DBIx::Custom>
3025

            
3026
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3027
    data_source # will be removed at 2017/1/1
3028
    dbi_options # will be removed at 2017/1/1
3029
    filter_check # will be removed at 2017/1/1
3030
    reserved_word_quote # will be removed at 2017/1/1
3031
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3032
    
3033
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3034
    create_query # will be removed at 2017/1/1
3035
    apply_filter # will be removed at 2017/1/1
3036
    select_at # will be removed at 2017/1/1
3037
    delete_at # will be removed at 2017/1/1
3038
    update_at # will be removed at 2017/1/1
3039
    insert_at # will be removed at 2017/1/1
3040
    register_tag # will be removed at 2017/1/1
3041
    default_bind_filter # will be removed at 2017/1/1
3042
    default_fetch_filter # will be removed at 2017/1/1
3043
    insert_param_tag # will be removed at 2017/1/1
3044
    register_tag_processor # will be removed at 2017/1/1
3045
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3046
    
3047
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3048
    select method relation option # will be removed at 2017/1/1
3049
    select method param option # will be removed at 2017/1/1
3050
    select method column option [COLUMN, as => ALIAS] format
3051
      # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3052
    
3053
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3054
    execute("select * from {= title}"); # execute method's
3055
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3056
                                        # will be removed at 2017/1/1
3057
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3058

            
3059
L<DBIx::Custom::Model>
3060

            
3061
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3062
    filter # will be removed at 2017/1/1
3063
    name # will be removed at 2017/1/1
3064
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3065

            
3066
L<DBIx::Custom::Query>
3067
    
3068
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3069
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3070

            
3071
L<DBIx::Custom::QueryBuilder>
3072
    
3073
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3074
    tags # will be removed at 2017/1/1
3075
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3076
    
3077
    # Method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3078
    register_tag # will be removed at 2017/1/1
3079
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3080
    
3081
    # Others
3082
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3083
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3084

            
3085
L<DBIx::Custom::Result>
3086
    
3087
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3088
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3089
    
3090
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3091
    end_filter # will be removed at 2017/1/1
3092
    remove_end_filter # will be removed at 2017/1/1
3093
    remove_filter # will be removed at 2017/1/1
3094
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3095

            
3096
L<DBIx::Custom::Tag>
3097

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

            
3100
=head1 BACKWORD COMPATIBLE POLICY
3101

            
3102
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3103
except for attribute method.
3104
You can check all DEPRECATED functionalities by document.
3105
DEPRECATED functionality is removed after five years,
3106
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
3107
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3108

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

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

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

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

            
3117
C<< <kimoto.yuki at gmail.com> >>
3118

            
3119
L<http://github.com/yuki-kimoto/DBIx-Custom>
3120

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3121
=head1 AUTHOR
3122

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

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

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

            
3129
This program is free software; you can redistribute it and/or modify it
3130
under the same terms as Perl itself.
3131

            
3132
=cut