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

            
- removed some EXPERIMENTAL ...
Yuki Kimoto authored on 2011-07-30
4
our $VERSION = '0.1707';
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;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
87
    foreach my $column (sort keys %$param) {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
88
        croak qq{"$column" is not safety column name } . _subname
89
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
90
        my $column_quote = $self->_q($column);
91
        $column_quote =~ s/\./$self->_q(".")/e;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
92
        push @params, ref $param->{$column} eq 'SCALAR'
93
          ? "$column_quote = " . ${$param->{$column}}
94
          : "$column_quote = :$column";
95

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
978
                    $self->{"_$into"}{$table}{$column} = $filter;
979
                }
980
            });
981
        }
982

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
1078
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1079
}
1080

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
1386
sub _remove_duplicate_table {
1387
    my ($self, $tables, $main_table) = @_;
1388
    
1389
    # Remove duplicate table
1390
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1391
    delete $tables{$main_table} if $main_table;
1392
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1393
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1394
    if (my $q = $self->_quote) {
1395
        $q = quotemeta($q);
1396
        $_ =~ s/[$q]//g for @$new_tables;
1397
    }
1398

            
1399
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1400
}
1401

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

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

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

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

            
1528
# DEPRECATED!
1529
sub create_query {
1530
    warn "create_query is DEPRECATED! use query option of each method";
1531
    shift->_create_query(@_);
1532
}
1533

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-08
1596
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1597
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1598
sub update_at {
1599
    my $self = shift;
1600

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

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

            
added warnings
Yuki Kimoto authored on 2011-06-07
1655
# DEPRECATED!
1656
sub register_tag {
1657
    warn "register_tag is DEPRECATED!";
1658
    shift->query_builder->register_tag(@_)
1659
}
1660

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1661
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
1662
has 'data_source';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1663
has dbi_options => sub { {} };
1664
has filter_check  => 1;
1665
has 'reserved_word_quote';
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1666

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

            
cleanup
Yuki Kimoto authored on 2011-01-25
1691
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1692
sub default_fetch_filter {
1693
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1694

            
cleanup
Yuki Kimoto authored on 2011-06-13
1695
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1696
    
1697
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1698
        my $fname = $_[0];
1699

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1773
=head1 NAME
1774

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

            
1777
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1778

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1848
Named place holder support
1849

            
1850
=item *
1851

            
cleanup
Yuki Kimoto authored on 2011-07-29
1852
Model support
1853

            
1854
=item *
1855

            
1856
Connection manager support
1857

            
1858
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1859

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

            
1864
=item *
1865

            
1866
Filtering by data type or column name(EXPERIMENTAL)
1867

            
1868
=item *
1869

            
1870
Create C<order by> clause flexibly(EXPERIMENTAL)
1871

            
1872
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1873

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1881
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
1882
L<DBIx::Custom::Result>,
1883
L<DBIx::Custom::Query>,
1884
L<DBIx::Custom::Where>,
1885
L<DBIx::Custom::Model>,
1886
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
1887

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

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

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

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

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

            
1901
    my $connector = DBIx::Connector->new(
1902
        "dbi:mysql:database=$DATABASE",
1903
        $USER,
1904
        $PASSWORD,
1905
        DBIx::Custom->new->default_dbi_option
1906
    );
1907
    
updated pod
Yuki Kimoto authored on 2011-06-21
1908
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
1909

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

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

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

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

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

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

            
1925
=head2 C<default_dbi_option>
1926

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1933
    {
1934
        RaiseError => 1,
1935
        PrintError => 0,
1936
        AutoCommit => 1,
1937
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
1938

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

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

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

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

            
1948
    my $last_sql = $dbi->last_sql;
1949
    $dbi = $dbi->last_sql($last_sql);
1950

            
1951
Get last successed SQL executed by C<execute> method.
1952

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1960
=head2 C<password>
1961

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1983
You can set quote pair.
1984

            
1985
    $dbi->quote('[]');
1986

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

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

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

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

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

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

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

            
2004
    my $tag_parse = $dbi->tag_parse(0);
2005
    $dbi = $dbi->tag_parse;
2006

            
2007
Enable DEPRECATED tag parsing functionality, default to 1.
2008
If you want to disable tag parsing functionality, set to 0.
2009

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

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

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

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

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

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

            
2025
    print $dbi->available_data_type;
2026

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

            
2030
=head2 C<available_type_name> EXPERIMENTAL
2031

            
2032
    print $dbi->available_type_name;
2033

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

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

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

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

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

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

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

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

            
2051
Create column clause. The follwoing column clause is created.
2052

            
2053
    book.author as "book.author",
2054
    book.title as "book.title"
2055

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2058
    # Separator is double underbar
2059
    $dbi->separator('__');
2060
    
2061
    book.author as "book__author",
2062
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2063

            
cleanup
Yuki Kimoto authored on 2011-06-13
2064
    # Separator is hyphen
2065
    $dbi->separator('-');
2066
    
2067
    book.author as "book-author",
2068
    book.title as "book-title"
2069
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2070
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2071

            
update pod
Yuki Kimoto authored on 2011-03-13
2072
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2073
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2074
        user => 'ken',
2075
        password => '!LFKD%$&',
2076
        dbi_option => {mysql_enable_utf8 => 1}
2077
    );
2078

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

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

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2087
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2088
        table => 'book',
2089
        primary_key => 'id',
2090
        join => [
2091
            'inner join company on book.comparny_id = company.id'
2092
        ],
2093
    );
2094

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

            
2098
   $dbi->model('book')->select(...);
2099

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

            
2102
    my $dbh = $dbi->dbh;
2103

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

            
2107
=head2 C<each_column>
2108

            
2109
    $dbi->each_column(
2110
        sub {
2111
            my ($dbi, $table, $column, $column_info) = @_;
2112
            
2113
            my $type = $column_info->{TYPE_NAME};
2114
            
2115
            if ($type eq 'DATE') {
2116
                # ...
2117
            }
2118
        }
2119
    );
2120

            
2121
Iterate all column informations of all table from database.
2122
Argument is callback when one column is found.
2123
Callback receive four arguments, dbi object, table name,
2124
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2125

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

            
2128
    $dbi->each_table(
2129
        sub {
2130
            my ($dbi, $table, $table_info) = @_;
2131
            
2132
            my $table_name = $table_info->{TABLE_NAME};
2133
        }
2134
    );
2135

            
2136
Iterate all table informationsfrom database.
2137
Argument is callback when one table is found.
2138
Callback receive three arguments, dbi object, table name,
2139
table information.
2140

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

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

            
2148
    my $result = $dbi->execute(
2149
      "select * from book where title = :book.title and author like :book.author",
2150
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2151
    );
2152

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2159
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2160
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2161
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2162
    select * from book where title = :title and author like :author
2163
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2164
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2165
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2166

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2170
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2171
    select * from book where :title{=} and :author{like}
2172
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2173
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2174
    select * from where title = ? and author like ?;
2175

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

            
2178
=over 4
2179

            
2180
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2181
    
2182
    filter => {
2183
        title  => sub { uc $_[0] }
2184
        author => sub { uc $_[0] }
2185
    }
update pod
Yuki Kimoto authored on 2011-03-13
2186

            
updated pod
Yuki Kimoto authored on 2011-06-09
2187
    # Filter name
2188
    filter => {
2189
        title  => 'upper_case',
2190
        author => 'upper_case'
2191
    }
2192
        
2193
    # At once
2194
    filter => [
2195
        [qw/title author/]  => sub { uc $_[0] }
2196
    ]
2197

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

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

            
2205
    query => 1
2206

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

            
2210
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2211
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2212
    my $columns = $query->columns;
2213
    
2214
If you want to execute SQL fast, you can do the following way.
2215

            
2216
    my $query;
2217
    foreach my $row (@$rows) {
2218
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2219
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2220
    }
2221

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

            
2225
If you want to execute SQL as possible as fast and don't need filtering.
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2226
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2227
    
2228
    my $query;
2229
    my $sth;
2230
    foreach my $row (@$rows) {
2231
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2232
      $sth ||= $query->sth;
2233
      $sth->execute(map { $row->{$_} } sort keys %$row);
2234
    }
2235

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2240
=item C<table>
2241
    
2242
    table => 'author'
2243

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2251
    # Same
2252
    $dbi->execute(
2253
      "select * from book where title = :book.title and author = :book.author",
2254
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2255

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

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

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

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

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

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

            
2269
    table_alias => {user => 'hiker'}
2270

            
2271
Table alias. Key is real table name, value is alias table name.
2272
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2273
on alias table name.
2274

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

            
2277
    type_rule_off => 1
2278

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

            
2281
=item C<type_rule1_off> EXPERIMENTAL
2282

            
2283
    type_rule1_off => 1
2284

            
2285
Turn C<into1> type rule off.
2286

            
2287
=item C<type_rule2_off> EXPERIMENTAL
2288

            
2289
    type_rule2_off => 1
2290

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2303
=over 4
2304

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

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

            
2309
=item C<filter>
2310

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2315
    id => 4
2316
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2317

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2321
    $dbi->delete(
2322
        parimary_key => ['id1', 'id2'],
2323
        id => [4, 5],
2324
        table => 'book',
2325
    );
update pod
Yuki Kimoto authored on 2011-03-13
2326

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

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

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

            
2333
    prefix => 'some'
2334

            
2335
prefix before table name section.
2336

            
2337
    delete some from book
2338

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2347
Table name.
2348

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

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

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

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

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

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

            
2361
=item C<type_rule_off> EXPERIMENTAL
2362

            
2363
Same as C<execute> method's C<type_rule_off> option.
2364

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

            
2367
    type_rule1_off => 1
2368

            
2369
Same as C<execute> method's C<type_rule1_off> option.
2370

            
2371
=item C<type_rule2_off> EXPERIMENTAL
2372

            
2373
    type_rule2_off => 1
2374

            
2375
Same as C<execute> method's C<type_rule2_off> option.
2376

            
updated pod
Yuki Kimoto authored on 2011-06-08
2377
=back
update pod
Yuki Kimoto authored on 2011-03-13
2378

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2386
=head2 C<insert>
2387

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

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

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

            
2396
    {date => \"NOW()"}
2397

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

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

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

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

            
2406
=item C<filter>
2407

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

            
2410
=item C<id>
2411

            
updated document
Yuki Kimoto authored on 2011-06-09
2412
    id => 4
2413
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2414

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

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

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

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

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

            
2434
    prefix => 'or replace'
2435

            
2436
prefix before table name section
2437

            
2438
    insert or replace into book
2439

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

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

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

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

            
2449
Same as C<execute> method's C<query> option.
2450

            
2451
=item C<table>
2452

            
2453
    table => 'book'
2454

            
2455
Table name.
2456

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

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

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

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

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

            
2467
    type_rule1_off => 1
2468

            
2469
Same as C<execute> method's C<type_rule1_off> option.
2470

            
2471
=item C<type_rule2_off> EXPERIMENTAL
2472

            
2473
    type_rule2_off => 1
2474

            
2475
Same as C<execute> method's C<type_rule2_off> option.
2476

            
update pod
Yuki Kimoto authored on 2011-03-13
2477
=back
2478

            
2479
=over 4
2480

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2496
    lib / MyModel.pm
2497
        / MyModel / book.pm
2498
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2499

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

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

            
2504
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2505
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2506
    
2507
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2508

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2513
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2514
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2515
    
2516
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2517

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2520
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2521
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2522
    
2523
    1;
2524
    
updated pod
Yuki Kimoto authored on 2011-06-21
2525
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2526

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

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

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

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

            
2536
    my $map_param = $dbi->map_param(
2537
        {id => 1, authro => 'Ken', price => 1900},
2538
        'id' => 'book.id',
2539
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2540
        'price' => [
2541
            'book.price', {if => sub { length $_[0] }}
2542
        ]
2543
    );
2544

            
2545
Map paramters to other key and value. First argument is original
2546
parameter. this is hash reference. Rest argument is mapping.
2547
By default, Mapping is done if the value length is not zero.
2548

            
2549
=over 4
2550

            
2551
=item Key mapping
2552

            
2553
    'id' => 'book.id'
2554

            
2555
This is only key mapping. Value is same as original one.
2556

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

            
2559
=item Key and value mapping
2560

            
2561
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2562

            
2563
This is key and value mapping. Frist element of array reference
2564
is mapped key name, second element is code reference to map the value.
2565

            
2566
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2567
      if value length is not zero.
2568

            
2569
=item Condition
2570

            
2571
    'price' => ['book.price', {if => 'exists'}]
2572
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2573
    'price' => ['book.price', {if => sub { defined shift }}]
2574

            
2575
If you need condition, you can sepecify it. this is code reference
2576
or 'exists'. By default, condition is the following one.
2577

            
2578
    sub { defined $_[0] && length $_[0] }
2579

            
2580
=back
2581

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

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

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

            
2588
    {key1 => [1, 1], key2 => 2}
2589

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

            
2592
    $dbi->method(
2593
        update_or_insert => sub {
2594
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2595
            
2596
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2597
        },
2598
        find_or_create   => sub {
2599
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2600
            
2601
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2602
        }
2603
    );
2604

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

            
2607
    $dbi->update_or_insert;
2608
    $dbi->find_or_create;
2609

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

            
2612
    my $model = $dbi->model('book');
2613

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

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

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

            
2620
Create column clause for myself. The follwoing column clause is created.
2621

            
2622
    book.author as author,
2623
    book.title as title
2624

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2627
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2628
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2629
        user => 'ken',
2630
        password => '!LFKD%$&',
2631
        dbi_option => {mysql_enable_utf8 => 1}
2632
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2633

            
2634
Create a new L<DBIx::Custom> object.
2635

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

            
2638
    my $not_exists = $dbi->not_exists;
2639

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

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

            
2645
    my $order = $dbi->order;
2646

            
2647
Create a new L<DBIx::Custom::Order> object.
2648

            
cleanup
yuki-kimoto authored on 2010-10-17
2649
=head2 C<register_filter>
2650

            
update pod
Yuki Kimoto authored on 2011-03-13
2651
    $dbi->register_filter(
2652
        # Time::Piece object to database DATE format
2653
        tp_to_date => sub {
2654
            my $tp = shift;
2655
            return $tp->strftime('%Y-%m-%d');
2656
        },
2657
        # database DATE format to Time::Piece object
2658
        date_to_tp => sub {
2659
           my $date = shift;
2660
           return Time::Piece->strptime($date, '%Y-%m-%d');
2661
        }
2662
    );
cleanup
yuki-kimoto authored on 2010-10-17
2663
    
update pod
Yuki Kimoto authored on 2011-03-13
2664
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2665

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

            
2668
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2669
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2670
            date => sub { ... },
2671
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2672
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2673
        into2 => {
2674
            date => sub { ... },
2675
            datetime => sub { ... }
2676
        },
2677
        from1 => {
2678
            # DATE
2679
            9 => sub { ... },
2680
            # DATETIME or TIMESTAMP
2681
            11 => sub { ... },
2682
        }
2683
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2684
            # DATE
2685
            9 => sub { ... },
2686
            # DATETIME or TIMESTAMP
2687
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2688
        }
2689
    );
2690

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2706
=over 4
2707

            
2708
=item 1. column name
2709

            
2710
    issue_date
2711
    issue_datetime
2712

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

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

            
2717
    book.issue_date
2718
    book.issue_datetime
2719

            
2720
=back
2721

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

            
2724
    print $dbi->available_type_name;
2725

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

            
2730
    print $dbi->available_data_type;
2731

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

            
2734
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2735
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2736
            [qw/DATE DATETIME/] => sub { ... },
2737
        ],
2738
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2739

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2742
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2743
        table  => 'book',
2744
        column => ['author', 'title'],
2745
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2746
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2747
    
updated document
Yuki Kimoto authored on 2011-06-09
2748
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2749

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

            
2752
=over 4
2753

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2758
Append statement to last of SQL.
2759
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2760
=item C<column>
2761
    
updated document
Yuki Kimoto authored on 2011-06-09
2762
    column => 'author'
2763
    column => ['author', 'title']
2764

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2773
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2774
        {book => [qw/author title/]},
2775
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2776
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2777

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

            
2780
    book.author as "book.author",
2781
    book.title as "book.title",
2782
    person.name as "person.name",
2783
    person.age as "person.age"
2784

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

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

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

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

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

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

            
2800
=item C<id>
2801

            
2802
    id => 4
2803
    id => [4, 5]
2804

            
2805
ID corresponding to C<primary_key>.
2806
You can select rows by C<id> and C<primary_key>.
2807

            
2808
    $dbi->select(
2809
        parimary_key => ['id1', 'id2'],
2810
        id => [4, 5],
2811
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2812
    );
2813

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
2816
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
2817
        where => {id1 => 4, id2 => 5},
2818
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2819
    );
2820
    
updated document
Yuki Kimoto authored on 2011-06-09
2821
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2822

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

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

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

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

            
2835
    prefix => 'SQL_CALC_FOUND_ROWS'
2836

            
2837
Prefix of column cluase
2838

            
2839
    select SQL_CALC_FOUND_ROWS title, author from book;
2840

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

            
2843
    join => [
2844
        'left outer join company on book.company_id = company_id',
2845
        'left outer join location on company.location_id = location.id'
2846
    ]
2847
        
2848
Join clause. If column cluase or where clause contain table name like "company.name",
2849
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
2850

            
2851
    $dbi->select(
2852
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2853
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2854
        where => {'company.name' => 'Orange'},
2855
        join => [
2856
            'left outer join company on book.company_id = company.id',
2857
            'left outer join location on company.location_id = location.id'
2858
        ]
2859
    );
2860

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2864
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2865
    from book
2866
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2867
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2868

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

            
2872
    $dbi->select(
2873
        table => 'book',
2874
        column => ['company.location_id as location_id'],
2875
        where => {'company.name' => 'Orange'},
2876
        join => [
2877
            {
2878
                clause => 'left outer join location on company.location_id = location.id',
2879
                table => ['company', 'location']
2880
            }
2881
        ]
2882
    );
2883

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2903
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2904

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

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

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

            
2911
    type_rule1_off => 1
2912

            
2913
Same as C<execute> method's C<type_rule1_off> option.
2914

            
2915
=item C<type_rule2_off> EXPERIMENTAL
2916

            
2917
    type_rule2_off => 1
2918

            
2919
Same as C<execute> method's C<type_rule2_off> option.
2920

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2947
Where clause.
2948
    
improved pod
Yuki Kimoto authored on 2011-04-19
2949
=item C<wrap> EXPERIMENTAL
2950

            
2951
Wrap statement. This is array reference.
2952

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

            
2955
This option is for Oracle and SQL Server paging process.
2956

            
update pod
Yuki Kimoto authored on 2011-03-12
2957
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2958

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

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

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

            
2965
If you want to set constant value to row data, use scalar reference
2966
as parameter value.
2967

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2972
=over 4
2973

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2984
    id => 4
2985
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2986

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2990
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
2991
        {title => 'Perl', author => 'Ken'}
2992
        parimary_key => ['id1', 'id2'],
2993
        id => [4, 5],
2994
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2995
    );
update pod
Yuki Kimoto authored on 2011-03-13
2996

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2999
    $dbi->update(
3000
        {title => 'Perl', author => 'Ken'}
3001
        where => {id1 => 4, id2 => 5},
3002
        table => 'book'
3003
    );
update pod
Yuki Kimoto authored on 2011-03-13
3004

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

            
3007
    prefix => 'or replace'
3008

            
3009
prefix before table name section
3010

            
3011
    update or replace book
3012

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

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

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

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

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

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

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

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

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

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

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

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

            
3038
=item C<type_rule_off> EXPERIMENTAL
3039

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

            
3042
=item C<type_rule1_off> EXPERIMENTAL
3043

            
3044
    type_rule1_off => 1
3045

            
3046
Same as C<execute> method's C<type_rule1_off> option.
3047

            
3048
=item C<type_rule2_off> EXPERIMENTAL
3049

            
3050
    type_rule2_off => 1
3051

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3054
=back
update pod
Yuki Kimoto authored on 2011-03-13
3055

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

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

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

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

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

            
3067
Create update parameter tag.
3068

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

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

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

            
3078
Create a new L<DBIx::Custom::Where> object.
3079

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

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

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

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

            
3089
=head2 C<DBIX_CUSTOM_DEBUG>
3090

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

            
3094
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3095

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

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

            
3100
L<DBIx::Custom>
3101

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

            
3135
L<DBIx::Custom::Model>
3136

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3137
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3138
    filter # will be removed at 2017/1/1
3139
    name # will be removed at 2017/1/1
3140
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3141

            
3142
L<DBIx::Custom::Query>
3143
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3144
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3145
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3146
    table # will be removed at 2017/1/1
3147
    filters # will be removed at 2017/1/1
3148
    
3149
    # Methods
3150
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3151

            
3152
L<DBIx::Custom::QueryBuilder>
3153
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3154
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3155
    tags # will be removed at 2017/1/1
3156
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3157
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3158
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3159
    register_tag # will be removed at 2017/1/1
3160
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3161
    
3162
    # Others
3163
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3164
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3165

            
3166
L<DBIx::Custom::Result>
3167
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3168
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3169
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3170
    
3171
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3172
    end_filter # will be removed at 2017/1/1
3173
    remove_end_filter # will be removed at 2017/1/1
3174
    remove_filter # will be removed at 2017/1/1
3175
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3176

            
3177
L<DBIx::Custom::Tag>
3178

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

            
3181
=head1 BACKWORD COMPATIBLE POLICY
3182

            
3183
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3184
except for attribute method.
3185
You can check all DEPRECATED functionalities by document.
3186
DEPRECATED functionality is removed after five years,
3187
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
3188
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3189

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

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

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

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

            
3198
C<< <kimoto.yuki at gmail.com> >>
3199

            
3200
L<http://github.com/yuki-kimoto/DBIx-Custom>
3201

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3202
=head1 AUTHOR
3203

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

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

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

            
3210
This program is free software; you can redistribute it and/or modify it
3211
under the same terms as Perl itself.
3212

            
3213
=cut