DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3136 lines | 81.222kb
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;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
87
    my $q = $self->_quote;
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
88
    foreach my $column (keys %$param) {
89
        croak qq{"$column" is not safety column name } . _subname
90
          unless $column =~ /^[$safety\.]+$/;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
91
        my $column_quote = "$q$column$q";
92
        $column_quote =~ s/\./$q.$q/;
93
        push @params, "$column_quote = :$column";
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
94
    }
95
    my $tag = join(', ', @params);
96
    
97
    return $tag;
98
}
99

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

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

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

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

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

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

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

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

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

            
250
    # Set model
251
    $self->model($model->name, $model);
252
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
253
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
254
}
255

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
502
    # Reserved word quote
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
503
    my $q = $self->_quote;
cleanup
yuki-kimoto authored on 2010-10-17
504
    
cleanup
Yuki Kimoto authored on 2011-04-02
505
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-01-27
506
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
507
    push @sql, "insert";
508
    push @sql, $prefix if defined $prefix;
509
    push @sql, "into $q$table$q " . $self->insert_param($param);
510
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
511
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
512
    
513
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
514
    return $self->execute($sql, $param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
515
}
516

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
517
sub insert_param {
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
518
    my ($self, $param) = @_;
519
    
cleanup
Yuki Kimoto authored on 2011-04-02
520
    # Create insert parameter tag
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
521
    my $safety = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
522
    my $q = $self->_quote;
cleanup
Yuki Kimoto authored on 2011-04-02
523
    my @columns;
524
    my @placeholders;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
525
    foreach my $column (keys %$param) {
cleanup
Yuki Kimoto authored on 2011-04-25
526
        croak qq{"$column" is not safety column name } . _subname
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
527
          unless $column =~ /^[$safety\.]+$/;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
528
        my $column_quote = "$q$column$q";
529
        $column_quote =~ s/\./$q.$q/;
530
        push @columns, $column_quote;
531
        push @placeholders, ":$column";
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
532
    }
533
    
cleanup
Yuki Kimoto authored on 2011-04-02
534
    return '(' . join(', ', @columns) . ') ' . 'values ' .
535
           '(' . join(', ', @placeholders) . ')'
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
536
}
537

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
538
sub include_model {
539
    my ($self, $name_space, $model_infos) = @_;
540
    
cleanup
Yuki Kimoto authored on 2011-04-02
541
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
542
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
543
    
544
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
545
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
546

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

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

            
629
        # Map parameter
630
        my $value;
631
        if (ref $condition eq 'CODE') {
632
            $map_param->{$map_key} = $value_cb->($param->{$key})
633
              if $condition->($param->{$key});
634
        }
635
        elsif ($condition eq 'exists') {
636
            $map_param->{$map_key} = $value_cb->($param->{$key})
637
              if exists $param->{$key};
638
        }
639
        else { croak qq/Condition must be code reference or "exists" / . _subname }
640
    }
641
    
642
    return $map_param;
643
}
644

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

            
cleanup
Yuki Kimoto authored on 2011-03-21
669
sub method {
670
    my $self = shift;
671
    
cleanup
Yuki Kimoto authored on 2011-04-02
672
    # Register method
cleanup
Yuki Kimoto authored on 2011-03-21
673
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
674
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
675
    
676
    return $self;
677
}
678

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

            
cleanup
Yuki Kimoto authored on 2011-03-21
696
sub mycolumn {
697
    my ($self, $table, $columns) = @_;
698
    
cleanup
Yuki Kimoto authored on 2011-04-02
699
    # Create column clause
700
    my @column;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
701
    my $q = $self->_quote;
cleanup
Yuki Kimoto authored on 2011-03-21
702
    $columns ||= [];
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
703
    push @column, "$q$table$q.$q$_$q as $q$_$q" for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
704
    
705
    return join (', ', @column);
706
}
707

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

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

            
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
738
sub order {
739
    my $self = shift;
added DBIx::Cusotm::Order pr...
Yuki Kimoto authored on 2011-07-11
740
    return DBIx::Custom::Order->new(quote => $self->quote, @_);
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
741
}
742

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

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

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

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

            
added EXPERIMETNAL separator...
Yuki Kimoto authored on 2011-06-13
889
sub separator {
890
    my $self = shift;
891
    
892
    if (@_) {
893
        my $separator = $_[0] || '';
894
        croak qq{Separator must be "." or "__" or "-" } . _subname
895
          unless $separator eq '.' || $separator eq '__'
896
              || $separator eq '-';
897
        
898
        $self->{separator} = $separator;
899
    
900
        return $self;
901
    }
902
    return $self->{separator} ||= '.';
903
}
904

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
905
sub setup_model {
906
    my $self = shift;
907
    
cleanup
Yuki Kimoto authored on 2011-04-02
908
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
909
    $self->each_column(
910
        sub {
911
            my ($self, $table, $column, $column_info) = @_;
912
            if (my $model = $self->models->{$table}) {
913
                push @{$model->columns}, $column;
914
            }
915
        }
916
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
917
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
918
}
919

            
simplify type_rule
Yuki Kimoto authored on 2011-06-10
920
sub available_data_type {
921
    my $self = shift;
922
    
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
923
    my $data_types = '';
simplify type_rule
Yuki Kimoto authored on 2011-06-10
924
    foreach my $i (-1000 .. 1000) {
925
         my $type_info = $self->dbh->type_info($i);
926
         my $data_type = $type_info->{DATA_TYPE};
927
         my $type_name = $type_info->{TYPE_NAME};
928
         $data_types .= "$data_type ($type_name)\n"
929
           if defined $data_type;
930
    }
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
931
    return "Data Type maybe equal to Type Name" unless $data_types;
932
    $data_types = "Data Type (Type name)\n" . $data_types;
simplify type_rule
Yuki Kimoto authored on 2011-06-10
933
    return $data_types;
934
}
935

            
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
936
sub available_type_name {
937
    my $self = shift;
938
    
939
    # Type Names
940
    my $type_names = {};
941
    $self->each_column(sub {
942
        my ($self, $table, $column, $column_info) = @_;
943
        $type_names->{$column_info->{TYPE_NAME}} = 1
944
          if $column_info->{TYPE_NAME};
945
    });
946
    my @output = sort keys %$type_names;
947
    unshift @output, "Type Name";
948
    return join "\n", @output;
949
}
950

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

            
984
                    $self->{"_$into"}{$table}{$column} = $filter;
985
                }
986
            });
987
        }
988

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

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

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

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

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1078
sub update_param {
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1079
    my ($self, $param, $opt) = @_;
1080
    
cleanup
Yuki Kimoto authored on 2011-04-02
1081
    # Create update parameter tag
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1082
    my $tag = $self->assign_param($param);
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1083
    $tag = "set $tag" unless $opt->{no_set};
1084

            
cleanup
Yuki Kimoto authored on 2011-04-02
1085
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1086
}
1087

            
cleanup
Yuki Kimoto authored on 2011-01-25
1088
sub where {
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
1089
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-04-02
1090
    
1091
    # Create where
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
1092
    return DBIx::Custom::Where->new(
1093
        query_builder => $self->query_builder,
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1094
        safety_character => $self->safety_character,
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1095
        quote => $self->_quote,
cleanup
Yuki Kimoto authored on 2011-03-09
1096
        @_
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
1097
    );
cleanup
Yuki Kimoto authored on 2011-01-25
1098
}
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1099

            
updated pod
Yuki Kimoto authored on 2011-06-21
1100
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1101
    
updated pod
Yuki Kimoto authored on 2011-06-21
1102
    my ($self, $source) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1103
    
updated pod
Yuki Kimoto authored on 2011-06-21
1104
    # Cache
1105
    my $cache = $self->cache;
1106
    
1107
    # Query
1108
    my $query;
1109
    
1110
    # Get cached query
1111
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1112
        
updated pod
Yuki Kimoto authored on 2011-06-21
1113
        # Get query
1114
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1115
        
updated pod
Yuki Kimoto authored on 2011-06-21
1116
        # Create query
1117
        if ($q) {
1118
            $query = DBIx::Custom::Query->new($q);
1119
            $query->filters($self->filters);
cleanup
Yuki Kimoto authored on 2011-06-13
1120
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1121
    }
1122
    
1123
    # Create query
1124
    unless ($query) {
1125

            
1126
        # Create query
1127
        my $builder = $self->query_builder;
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
1128
        $builder->{_tag_parse} = $self->tag_parse;
cleanup
Yuki Kimoto authored on 2011-07-29
1129
        $builder->safety_character($self->safety_character);
updated pod
Yuki Kimoto authored on 2011-06-21
1130
        $query = $builder->build_query($source);
1131

            
1132
        # Remove reserved word quote
1133
        if (my $q = $self->_quote) {
1134
            $_ =~ s/$q//g for @{$query->columns}
cleanup
Yuki Kimoto authored on 2011-06-13
1135
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1136

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1273
sub _croak {
1274
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1275
    
1276
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1277
    $append ||= "";
1278
    
1279
    # Verbose
1280
    if ($Carp::Verbose) { croak $error }
1281
    
1282
    # Not verbose
1283
    else {
1284
        
1285
        # Remove line and module infromation
1286
        my $at_pos = rindex($error, ' at ');
1287
        $error = substr($error, 0, $at_pos);
1288
        $error =~ s/\s+$//;
1289
        croak "$error$append";
1290
    }
1291
}
1292

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1293
sub _need_tables {
1294
    my ($self, $tree, $need_tables, $tables) = @_;
1295
    
cleanup
Yuki Kimoto authored on 2011-04-02
1296
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1297
    foreach my $table (@$tables) {
1298
        if ($tree->{$table}) {
1299
            $need_tables->{$table} = 1;
1300
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1301
        }
1302
    }
1303
}
1304

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

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1370
sub _quote {
1371
    my $self = shift;
1372
    
1373
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1374
         : defined $self->quote ? $self->quote
1375
         : '';
1376
}
1377

            
cleanup
Yuki Kimoto authored on 2011-07-29
1378
sub _q {
1379
    my $self = shift;
1380
    
1381
    my $quote = $self->_quote;
1382
    my $q = substr($quote, 0, 1) || '';
1383
    my $p = substr($quote, 1, 1) || $q || '';
1384
    
1385
    return ($q, $p);
1386
}
1387

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1830
=head1 FEATURES
removed reconnect method
yuki-kimoto authored on 2010-05-28
1831

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

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

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

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

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

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

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

            
1847
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1848

            
1849
=head1 GUIDE
1850

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1894
=head2 C<default_dbi_option>
1895

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1969
    my $tag_parse = $dbi->tag_parse(0);
1970
    $dbi = $dbi->tag_parse;
1971

            
1972
Enable DEPRECATED tag parsing functionality, default to 1.
1973
If you want to disable tag parsing functionality, set to 0.
1974

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

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

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

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

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

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

            
1990
    print $dbi->available_data_type;
1991

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

            
1995
=head2 C<available_type_name> EXPERIMENTAL
1996

            
1997
    print $dbi->available_type_name;
1998

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2002
=head2 C<assign_param> EXPERIMENTAL
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
    my $assign_param = $dbi->assign_param({title => 'a', age => 2});
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2005

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

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

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

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

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

            
2016
Create column clause. The follwoing column clause is created.
2017

            
2018
    book.author as "book.author",
2019
    book.title as "book.title"
2020

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

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

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

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

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

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

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

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

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

            
2063
   $dbi->model('book')->select(...);
2064

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

            
2067
    my $dbh = $dbi->dbh;
2068

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

            
2072
=head2 C<each_column>
2073

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

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

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

            
2093
    $dbi->each_table(
2094
        sub {
2095
            my ($dbi, $table, $table_info) = @_;
2096
            
2097
            my $table_name = $table_info->{TABLE_NAME};
2098
        }
2099
    );
2100

            
2101
Iterate all table informationsfrom database.
2102
Argument is callback when one table is found.
2103
Callback receive three arguments, dbi object, table name,
2104
table information.
2105

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

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

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

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

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

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

            
2135
    # Before
2136
    select * from book where :title{=} and :author{like}
2137
    
2138
    # After
update pod
Yuki Kimoto authored on 2011-03-13
2139
    select * from where title = ? and author like ?;
2140

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

            
2143
=over 4
2144

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

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

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

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

            
2170
    query => 1
2171

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

            
2175
    my $sql = $query->sql;
2176
    my $columns = $query->columns;
updated document
Yuki Kimoto authored on 2011-06-09
2177

            
updated pod
Yuki Kimoto authored on 2011-06-09
2178
=item C<table>
2179
    
2180
    table => 'author'
2181

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

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

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

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

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

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

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

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

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

            
2207
    table_alias => {user => 'hiker'}
2208

            
2209
Table alias. Key is real table name, value is alias table name.
2210
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2211
on alias table name.
2212

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

            
2215
    type_rule_off => 1
2216

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

            
2219
=item C<type_rule1_off> EXPERIMENTAL
2220

            
2221
    type_rule1_off => 1
2222

            
2223
Turn C<into1> type rule off.
2224

            
2225
=item C<type_rule2_off> EXPERIMENTAL
2226

            
2227
    type_rule2_off => 1
2228

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2241
=over 4
2242

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

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

            
2247
=item C<filter>
2248

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2253
    id => 4
2254
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2255

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

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

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

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

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

            
2271
    prefix => 'some'
2272

            
2273
prefix before table name section.
2274

            
2275
    delete some from book
2276

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2285
Table name.
2286

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

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

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

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

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

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

            
2299
=item C<type_rule_off> EXPERIMENTAL
2300

            
2301
Same as C<execute> method's C<type_rule_off> option.
2302

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

            
2305
    type_rule1_off => 1
2306

            
2307
Same as C<execute> method's C<type_rule1_off> option.
2308

            
2309
=item C<type_rule2_off> EXPERIMENTAL
2310

            
2311
    type_rule2_off => 1
2312

            
2313
Same as C<execute> method's C<type_rule2_off> option.
2314

            
updated pod
Yuki Kimoto authored on 2011-06-08
2315
=back
update pod
Yuki Kimoto authored on 2011-03-13
2316

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2324
=head2 C<insert>
2325

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

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

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

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

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

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

            
2339
=item C<filter>
2340

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

            
2343
=item C<id>
2344

            
updated document
Yuki Kimoto authored on 2011-06-09
2345
    id => 4
2346
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2347

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

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

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

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

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

            
2367
    prefix => 'or replace'
2368

            
2369
prefix before table name section
2370

            
2371
    insert or replace into book
2372

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

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

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

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

            
2382
Same as C<execute> method's C<query> option.
2383

            
2384
=item C<table>
2385

            
2386
    table => 'book'
2387

            
2388
Table name.
2389

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

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

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

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

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

            
2400
    type_rule1_off => 1
2401

            
2402
Same as C<execute> method's C<type_rule1_off> option.
2403

            
2404
=item C<type_rule2_off> EXPERIMENTAL
2405

            
2406
    type_rule2_off => 1
2407

            
2408
Same as C<execute> method's C<type_rule2_off> option.
2409

            
update pod
Yuki Kimoto authored on 2011-03-13
2410
=back
2411

            
2412
=over 4
2413

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2414
=head2 C<insert_param>
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
    my $insert_param = $dbi->insert_param({title => 'a', age => 2});
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2417

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2429
    lib / MyModel.pm
2430
        / MyModel / book.pm
2431
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2432

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2446
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2447
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2448
    
2449
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2450

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

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

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

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

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

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

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

            
2478
Map paramters to other key and value. First argument is original
2479
parameter. this is hash reference. Rest argument is mapping.
2480
By default, Mapping is done if the value length is not zero.
2481

            
2482
=over 4
2483

            
2484
=item Key mapping
2485

            
2486
    'id' => 'book.id'
2487

            
2488
This is only key mapping. Value is same as original one.
2489

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

            
2492
=item Key and value mapping
2493

            
2494
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2495

            
2496
This is key and value mapping. Frist element of array reference
2497
is mapped key name, second element is code reference to map the value.
2498

            
2499
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2500
      if value length is not zero.
2501

            
2502
=item Condition
2503

            
2504
    'price' => ['book.price', {if => 'exists'}]
2505
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2506
    'price' => ['book.price', {if => sub { defined shift }}]
2507

            
2508
If you need condition, you can sepecify it. this is code reference
2509
or 'exists'. By default, condition is the following one.
2510

            
2511
    sub { defined $_[0] && length $_[0] }
2512

            
2513
=back
2514

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

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

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

            
2521
    {key1 => [1, 1], key2 => 2}
2522

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

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

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

            
2540
    $dbi->update_or_insert;
2541
    $dbi->find_or_create;
2542

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

            
2545
    my $model = $dbi->model('book');
2546

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

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

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

            
2553
Create column clause for myself. The follwoing column clause is created.
2554

            
2555
    book.author as author,
2556
    book.title as title
2557

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

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

            
2567
Create a new L<DBIx::Custom> object.
2568

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

            
2571
    my $not_exists = $dbi->not_exists;
2572

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

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

            
2578
    my $order = $dbi->order;
2579

            
2580
Create a new L<DBIx::Custom::Order> object.
2581

            
cleanup
yuki-kimoto authored on 2010-10-17
2582
=head2 C<register_filter>
2583

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2639
=over 4
2640

            
2641
=item 1. column name
2642

            
2643
    issue_date
2644
    issue_datetime
2645

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

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

            
2650
    book.issue_date
2651
    book.issue_datetime
2652

            
2653
=back
2654

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

            
2657
    print $dbi->available_type_name;
2658

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

            
2663
    print $dbi->available_data_type;
2664

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

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

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

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

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

            
2685
=over 4
2686

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2706
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2707
        {book => [qw/author title/]},
2708
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2709
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2710

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

            
2713
    book.author as "book.author",
2714
    book.title as "book.title",
2715
    person.name as "person.name",
2716
    person.age as "person.age"
2717

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

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

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

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

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

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

            
2733
=item C<id>
2734

            
2735
    id => 4
2736
    id => [4, 5]
2737

            
2738
ID corresponding to C<primary_key>.
2739
You can select rows by C<id> and C<primary_key>.
2740

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

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

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

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

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

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

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

            
2768
    prefix => 'SQL_CALC_FOUND_ROWS'
2769

            
2770
Prefix of column cluase
2771

            
2772
    select SQL_CALC_FOUND_ROWS title, author from book;
2773

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2797
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2798
    from book
2799
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2800
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2801

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

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

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2836
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2837

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

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

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

            
2844
    type_rule1_off => 1
2845

            
2846
Same as C<execute> method's C<type_rule1_off> option.
2847

            
2848
=item C<type_rule2_off> EXPERIMENTAL
2849

            
2850
    type_rule2_off => 1
2851

            
2852
Same as C<execute> method's C<type_rule2_off> option.
2853

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2880
Where clause.
2881
    
improved pod
Yuki Kimoto authored on 2011-04-19
2882
=item C<wrap> EXPERIMENTAL
2883

            
2884
Wrap statement. This is array reference.
2885

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

            
2888
This option is for Oracle and SQL Server paging process.
2889

            
update pod
Yuki Kimoto authored on 2011-03-12
2890
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2891

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2900
=over 4
2901

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2904
Same as C<select> method's C<append> 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<filter>
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2907

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2912
    id => 4
2913
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2914

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

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

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

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

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

            
2935
    prefix => 'or replace'
2936

            
2937
prefix before table name section
2938

            
2939
    update or replace book
2940

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

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

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

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

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

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

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

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

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

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

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

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

            
2966
=item C<type_rule_off> EXPERIMENTAL
2967

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

            
2970
=item C<type_rule1_off> EXPERIMENTAL
2971

            
2972
    type_rule1_off => 1
2973

            
2974
Same as C<execute> method's C<type_rule1_off> option.
2975

            
2976
=item C<type_rule2_off> EXPERIMENTAL
2977

            
2978
    type_rule2_off => 1
2979

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
2982
=back
update pod
Yuki Kimoto authored on 2011-03-13
2983

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

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

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

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

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

            
2995
Create update parameter tag.
2996

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

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

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

            
3006
Create a new L<DBIx::Custom::Where> object.
3007

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

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

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

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

            
3017
=head2 C<DBIX_CUSTOM_DEBUG>
3018

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

            
3022
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3023

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

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

            
3028
L<DBIx::Custom>
3029

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

            
3063
L<DBIx::Custom::Model>
3064

            
3065
    # Attribute method
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3066
    filter # will be removed at 2017/1/1
3067
    name # will be removed at 2017/1/1
3068
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3069

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

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

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

            
3100
L<DBIx::Custom::Tag>
3101

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

            
3104
=head1 BACKWORD COMPATIBLE POLICY
3105

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

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

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

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

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

            
3121
C<< <kimoto.yuki at gmail.com> >>
3122

            
3123
L<http://github.com/yuki-kimoto/DBIx-Custom>
3124

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3125
=head1 AUTHOR
3126

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

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

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

            
3133
This program is free software; you can redistribute it and/or modify it
3134
under the same terms as Perl itself.
3135

            
3136
=cut