DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3219 lines | 83.509kb
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
    
micro optimization
Yuki Kimoto authored on 2011-07-30
241
    # Apply filter(DEPRECATED logic)
242
    if ($model->{filter}) {
243
        my $filter = ref $model->filter eq 'HASH'
244
                   ? [%{$model->filter}]
245
                   : $model->filter;
246
        $filter ||= [];
247
        warn "DBIx::Custom::Model filter method is DEPRECATED!"
248
          if @$filter;
249
        $self->_apply_filter($model->table, @$filter);
250
    }
251
    
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
252
    # Set model
253
    $self->model($model->name, $model);
254
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
255
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
256
}
257

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

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

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

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

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

            
472
        return $result;
473
    }
cleanup
Yuki Kimoto authored on 2011-04-02
474
    
475
    # Not select statement
476
    else { return $affected }
cleanup
yuki-kimoto authored on 2010-10-17
477
}
478

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1404
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1405
}
1406

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

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

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

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

            
1534
# DEPRECATED!
1535
sub create_query {
1536
    warn "create_query is DEPRECATED! use query option of each method";
1537
    shift->_create_query(@_);
1538
}
1539

            
cleanup
Yuki Kimoto authored on 2011-06-13
1540
# DEPRECATED!
1541
sub apply_filter {
1542
    my $self = shift;
1543
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1544
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1545
    return $self->_apply_filter(@_);
1546
}
1547

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-08
1602
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1603
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1604
sub update_at {
1605
    my $self = shift;
1606

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

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

            
added warnings
Yuki Kimoto authored on 2011-06-07
1661
# DEPRECATED!
1662
sub register_tag {
1663
    warn "register_tag is DEPRECATED!";
1664
    shift->query_builder->register_tag(@_)
1665
}
1666

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1667
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
1668
has 'data_source';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1669
has dbi_options => sub { {} };
1670
has filter_check  => 1;
1671
has 'reserved_word_quote';
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1672

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

            
cleanup
Yuki Kimoto authored on 2011-01-25
1697
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1698
sub default_fetch_filter {
1699
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1700

            
cleanup
Yuki Kimoto authored on 2011-06-13
1701
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1702
    
1703
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1704
        my $fname = $_[0];
1705

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

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1722
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1723
sub insert_param_tag {
1724
    warn "insert_param_tag is DEPRECATED! " .
1725
         "use insert_param instead!";
1726
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1727
}
1728

            
cleanup
Yuki Kimoto authored on 2011-01-25
1729
# DEPRECATED!
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1730
sub register_tag_processor {
added warnings
Yuki Kimoto authored on 2011-06-07
1731
    warn "register_tag_processor is DEPRECATED!";
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1732
    return shift->query_builder->register_tag_processor(@_);
1733
}
1734

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1779
=head1 NAME
1780

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

            
1783
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1784

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1854
Named place holder support
1855

            
1856
=item *
1857

            
cleanup
Yuki Kimoto authored on 2011-07-29
1858
Model support
1859

            
1860
=item *
1861

            
1862
Connection manager support
1863

            
1864
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1865

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

            
1870
=item *
1871

            
1872
Filtering by data type or column name(EXPERIMENTAL)
1873

            
1874
=item *
1875

            
1876
Create C<order by> clause flexibly(EXPERIMENTAL)
1877

            
1878
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1879

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1887
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
1888
L<DBIx::Custom::Result>,
1889
L<DBIx::Custom::Query>,
1890
L<DBIx::Custom::Where>,
1891
L<DBIx::Custom::Model>,
1892
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
1893

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

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

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

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

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

            
1907
    my $connector = DBIx::Connector->new(
1908
        "dbi:mysql:database=$DATABASE",
1909
        $USER,
1910
        $PASSWORD,
1911
        DBIx::Custom->new->default_dbi_option
1912
    );
1913
    
updated pod
Yuki Kimoto authored on 2011-06-21
1914
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
1915

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

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

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

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

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

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

            
1931
=head2 C<default_dbi_option>
1932

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1939
    {
1940
        RaiseError => 1,
1941
        PrintError => 0,
1942
        AutoCommit => 1,
1943
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
1944

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

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

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

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

            
1954
    my $last_sql = $dbi->last_sql;
1955
    $dbi = $dbi->last_sql($last_sql);
1956

            
1957
Get last successed SQL executed by C<execute> method.
1958

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1966
=head2 C<password>
1967

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1989
You can set quote pair.
1990

            
1991
    $dbi->quote('[]');
1992

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

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

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

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

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

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

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

            
2010
    my $tag_parse = $dbi->tag_parse(0);
2011
    $dbi = $dbi->tag_parse;
2012

            
2013
Enable DEPRECATED tag parsing functionality, default to 1.
2014
If you want to disable tag parsing functionality, set to 0.
2015

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

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

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

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

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

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

            
2031
    print $dbi->available_data_type;
2032

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

            
2036
=head2 C<available_type_name> EXPERIMENTAL
2037

            
2038
    print $dbi->available_type_name;
2039

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

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

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

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

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

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

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

            
2057
Create column clause. The follwoing column clause is created.
2058

            
2059
    book.author as "book.author",
2060
    book.title as "book.title"
2061

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2064
    # Separator is double underbar
2065
    $dbi->separator('__');
2066
    
2067
    book.author as "book__author",
2068
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2069

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

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

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

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

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2093
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2094
        table => 'book',
2095
        primary_key => 'id',
2096
        join => [
2097
            'inner join company on book.comparny_id = company.id'
2098
        ],
2099
    );
2100

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

            
2104
   $dbi->model('book')->select(...);
2105

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

            
2108
    my $dbh = $dbi->dbh;
2109

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

            
2113
=head2 C<each_column>
2114

            
2115
    $dbi->each_column(
2116
        sub {
2117
            my ($dbi, $table, $column, $column_info) = @_;
2118
            
2119
            my $type = $column_info->{TYPE_NAME};
2120
            
2121
            if ($type eq 'DATE') {
2122
                # ...
2123
            }
2124
        }
2125
    );
2126

            
2127
Iterate all column informations of all table from database.
2128
Argument is callback when one column is found.
2129
Callback receive four arguments, dbi object, table name,
2130
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2131

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

            
2134
    $dbi->each_table(
2135
        sub {
2136
            my ($dbi, $table, $table_info) = @_;
2137
            
2138
            my $table_name = $table_info->{TABLE_NAME};
2139
        }
2140
    );
2141

            
2142
Iterate all table informationsfrom database.
2143
Argument is callback when one table is found.
2144
Callback receive three arguments, dbi object, table name,
2145
table information.
2146

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

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

            
2154
    my $result = $dbi->execute(
2155
      "select * from book where title = :book.title and author like :book.author",
2156
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2157
    );
2158

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2176
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2177
    select * from book where :title{=} and :author{like}
2178
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2179
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2180
    select * from where title = ? and author like ?;
2181

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

            
2184
=over 4
2185

            
2186
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2187
    
2188
    filter => {
2189
        title  => sub { uc $_[0] }
2190
        author => sub { uc $_[0] }
2191
    }
update pod
Yuki Kimoto authored on 2011-03-13
2192

            
updated pod
Yuki Kimoto authored on 2011-06-09
2193
    # Filter name
2194
    filter => {
2195
        title  => 'upper_case',
2196
        author => 'upper_case'
2197
    }
2198
        
2199
    # At once
2200
    filter => [
2201
        [qw/title author/]  => sub { uc $_[0] }
2202
    ]
2203

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

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

            
2211
    query => 1
2212

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

            
2216
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2217
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2218
    my $columns = $query->columns;
2219
    
2220
If you want to execute SQL fast, you can do the following way.
2221

            
2222
    my $query;
2223
    foreach my $row (@$rows) {
2224
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2225
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2226
    }
2227

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

            
2231
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
2232
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2233
    
2234
    my $query;
2235
    my $sth;
2236
    foreach my $row (@$rows) {
2237
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2238
      $sth ||= $query->sth;
2239
      $sth->execute(map { $row->{$_} } sort keys %$row);
2240
    }
2241

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2246
=item C<table>
2247
    
2248
    table => 'author'
2249

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2257
    # Same
2258
    $dbi->execute(
2259
      "select * from book where title = :book.title and author = :book.author",
2260
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2261

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

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

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

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

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

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

            
2275
    table_alias => {user => 'hiker'}
2276

            
2277
Table alias. Key is real table name, value is alias table name.
2278
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2279
on alias table name.
2280

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

            
2283
    type_rule_off => 1
2284

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

            
2287
=item C<type_rule1_off> EXPERIMENTAL
2288

            
2289
    type_rule1_off => 1
2290

            
2291
Turn C<into1> type rule off.
2292

            
2293
=item C<type_rule2_off> EXPERIMENTAL
2294

            
2295
    type_rule2_off => 1
2296

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2309
=over 4
2310

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

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

            
2315
=item C<filter>
2316

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2321
    id => 4
2322
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2323

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2327
    $dbi->delete(
2328
        parimary_key => ['id1', 'id2'],
2329
        id => [4, 5],
2330
        table => 'book',
2331
    );
update pod
Yuki Kimoto authored on 2011-03-13
2332

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

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

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

            
2339
    prefix => 'some'
2340

            
2341
prefix before table name section.
2342

            
2343
    delete some from book
2344

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2353
Table name.
2354

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

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

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

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

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

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

            
2367
=item C<type_rule_off> EXPERIMENTAL
2368

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

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

            
2373
    type_rule1_off => 1
2374

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

            
2377
=item C<type_rule2_off> EXPERIMENTAL
2378

            
2379
    type_rule2_off => 1
2380

            
2381
Same as C<execute> method's C<type_rule2_off> option.
2382

            
updated pod
Yuki Kimoto authored on 2011-06-08
2383
=back
update pod
Yuki Kimoto authored on 2011-03-13
2384

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2392
=head2 C<insert>
2393

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

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

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

            
2402
    {date => \"NOW()"}
2403

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

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

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

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

            
2412
=item C<filter>
2413

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

            
2416
=item C<id>
2417

            
updated document
Yuki Kimoto authored on 2011-06-09
2418
    id => 4
2419
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2420

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

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

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

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

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

            
2440
    prefix => 'or replace'
2441

            
2442
prefix before table name section
2443

            
2444
    insert or replace into book
2445

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

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

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

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

            
2455
Same as C<execute> method's C<query> option.
2456

            
2457
=item C<table>
2458

            
2459
    table => 'book'
2460

            
2461
Table name.
2462

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

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

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

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

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

            
2473
    type_rule1_off => 1
2474

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

            
2477
=item C<type_rule2_off> EXPERIMENTAL
2478

            
2479
    type_rule2_off => 1
2480

            
2481
Same as C<execute> method's C<type_rule2_off> option.
2482

            
update pod
Yuki Kimoto authored on 2011-03-13
2483
=back
2484

            
2485
=over 4
2486

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2502
    lib / MyModel.pm
2503
        / MyModel / book.pm
2504
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2505

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

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

            
2510
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2511
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2512
    
2513
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2514

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2519
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2520
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2521
    
2522
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2523

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2526
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2527
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2528
    
2529
    1;
2530
    
updated pod
Yuki Kimoto authored on 2011-06-21
2531
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2532

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

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

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

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

            
2542
    my $map_param = $dbi->map_param(
2543
        {id => 1, authro => 'Ken', price => 1900},
2544
        'id' => 'book.id',
2545
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2546
        'price' => [
2547
            'book.price', {if => sub { length $_[0] }}
2548
        ]
2549
    );
2550

            
2551
Map paramters to other key and value. First argument is original
2552
parameter. this is hash reference. Rest argument is mapping.
2553
By default, Mapping is done if the value length is not zero.
2554

            
2555
=over 4
2556

            
2557
=item Key mapping
2558

            
2559
    'id' => 'book.id'
2560

            
2561
This is only key mapping. Value is same as original one.
2562

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

            
2565
=item Key and value mapping
2566

            
2567
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2568

            
2569
This is key and value mapping. Frist element of array reference
2570
is mapped key name, second element is code reference to map the value.
2571

            
2572
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2573
      if value length is not zero.
2574

            
2575
=item Condition
2576

            
2577
    'price' => ['book.price', {if => 'exists'}]
2578
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2579
    'price' => ['book.price', {if => sub { defined shift }}]
2580

            
2581
If you need condition, you can sepecify it. this is code reference
2582
or 'exists'. By default, condition is the following one.
2583

            
2584
    sub { defined $_[0] && length $_[0] }
2585

            
2586
=back
2587

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

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

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

            
2594
    {key1 => [1, 1], key2 => 2}
2595

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

            
2598
    $dbi->method(
2599
        update_or_insert => sub {
2600
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2601
            
2602
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2603
        },
2604
        find_or_create   => sub {
2605
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2606
            
2607
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2608
        }
2609
    );
2610

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

            
2613
    $dbi->update_or_insert;
2614
    $dbi->find_or_create;
2615

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

            
2618
    my $model = $dbi->model('book');
2619

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

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

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

            
2626
Create column clause for myself. The follwoing column clause is created.
2627

            
2628
    book.author as author,
2629
    book.title as title
2630

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

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

            
2640
Create a new L<DBIx::Custom> object.
2641

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

            
2644
    my $not_exists = $dbi->not_exists;
2645

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

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

            
2651
    my $order = $dbi->order;
2652

            
2653
Create a new L<DBIx::Custom::Order> object.
2654

            
cleanup
yuki-kimoto authored on 2010-10-17
2655
=head2 C<register_filter>
2656

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2712
=over 4
2713

            
2714
=item 1. column name
2715

            
2716
    issue_date
2717
    issue_datetime
2718

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

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

            
2723
    book.issue_date
2724
    book.issue_datetime
2725

            
2726
=back
2727

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

            
2730
    print $dbi->available_type_name;
2731

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

            
2736
    print $dbi->available_data_type;
2737

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

            
2740
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2741
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2742
            [qw/DATE DATETIME/] => sub { ... },
2743
        ],
2744
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2745

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2748
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2749
        table  => 'book',
2750
        column => ['author', 'title'],
2751
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2752
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2753
    
updated document
Yuki Kimoto authored on 2011-06-09
2754
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2755

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

            
2758
=over 4
2759

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2764
Append statement to last of SQL.
2765
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2766
=item C<column>
2767
    
updated document
Yuki Kimoto authored on 2011-06-09
2768
    column => 'author'
2769
    column => ['author', 'title']
2770

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2779
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2780
        {book => [qw/author title/]},
2781
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2782
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2783

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

            
2786
    book.author as "book.author",
2787
    book.title as "book.title",
2788
    person.name as "person.name",
2789
    person.age as "person.age"
2790

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

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

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

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

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

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

            
2806
=item C<id>
2807

            
2808
    id => 4
2809
    id => [4, 5]
2810

            
2811
ID corresponding to C<primary_key>.
2812
You can select rows by C<id> and C<primary_key>.
2813

            
2814
    $dbi->select(
2815
        parimary_key => ['id1', 'id2'],
2816
        id => [4, 5],
2817
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2818
    );
2819

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

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

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

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

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

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

            
2841
    prefix => 'SQL_CALC_FOUND_ROWS'
2842

            
2843
Prefix of column cluase
2844

            
2845
    select SQL_CALC_FOUND_ROWS title, author from book;
2846

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

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

            
2857
    $dbi->select(
2858
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2859
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2860
        where => {'company.name' => 'Orange'},
2861
        join => [
2862
            'left outer join company on book.company_id = company.id',
2863
            'left outer join location on company.location_id = location.id'
2864
        ]
2865
    );
2866

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2870
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2871
    from book
2872
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2873
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2874

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

            
2878
    $dbi->select(
2879
        table => 'book',
2880
        column => ['company.location_id as location_id'],
2881
        where => {'company.name' => 'Orange'},
2882
        join => [
2883
            {
2884
                clause => 'left outer join location on company.location_id = location.id',
2885
                table => ['company', 'location']
2886
            }
2887
        ]
2888
    );
2889

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2909
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2910

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

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

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

            
2917
    type_rule1_off => 1
2918

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

            
2921
=item C<type_rule2_off> EXPERIMENTAL
2922

            
2923
    type_rule2_off => 1
2924

            
2925
Same as C<execute> method's C<type_rule2_off> option.
2926

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2953
Where clause.
2954
    
improved pod
Yuki Kimoto authored on 2011-04-19
2955
=item C<wrap> EXPERIMENTAL
2956

            
2957
Wrap statement. This is array reference.
2958

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

            
2961
This option is for Oracle and SQL Server paging process.
2962

            
update pod
Yuki Kimoto authored on 2011-03-12
2963
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2964

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

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

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

            
2971
If you want to set constant value to row data, use scalar reference
2972
as parameter value.
2973

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2978
=over 4
2979

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2990
    id => 4
2991
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2992

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3005
    $dbi->update(
3006
        {title => 'Perl', author => 'Ken'}
3007
        where => {id1 => 4, id2 => 5},
3008
        table => 'book'
3009
    );
update pod
Yuki Kimoto authored on 2011-03-13
3010

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

            
3013
    prefix => 'or replace'
3014

            
3015
prefix before table name section
3016

            
3017
    update or replace book
3018

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

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

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

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

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

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

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

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

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

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

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

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

            
3044
=item C<type_rule_off> EXPERIMENTAL
3045

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

            
3048
=item C<type_rule1_off> EXPERIMENTAL
3049

            
3050
    type_rule1_off => 1
3051

            
3052
Same as C<execute> method's C<type_rule1_off> option.
3053

            
3054
=item C<type_rule2_off> EXPERIMENTAL
3055

            
3056
    type_rule2_off => 1
3057

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3060
=back
update pod
Yuki Kimoto authored on 2011-03-13
3061

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

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

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

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

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

            
3073
Create update parameter tag.
3074

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

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

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

            
3084
Create a new L<DBIx::Custom::Where> object.
3085

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

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

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

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

            
3095
=head2 C<DBIX_CUSTOM_DEBUG>
3096

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

            
3100
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3101

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

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

            
3106
L<DBIx::Custom>
3107

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

            
3141
L<DBIx::Custom::Model>
3142

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3143
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3144
    filter # will be removed at 2017/1/1
3145
    name # will be removed at 2017/1/1
3146
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3147

            
3148
L<DBIx::Custom::Query>
3149
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3150
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3151
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3152
    table # will be removed at 2017/1/1
3153
    filters # will be removed at 2017/1/1
3154
    
3155
    # Methods
3156
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3157

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

            
3172
L<DBIx::Custom::Result>
3173
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3174
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3175
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3176
    
3177
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3178
    end_filter # will be removed at 2017/1/1
3179
    remove_end_filter # will be removed at 2017/1/1
3180
    remove_filter # will be removed at 2017/1/1
3181
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3182

            
3183
L<DBIx::Custom::Tag>
3184

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

            
3187
=head1 BACKWORD COMPATIBLE POLICY
3188

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

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

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

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

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

            
3204
C<< <kimoto.yuki at gmail.com> >>
3205

            
3206
L<http://github.com/yuki-kimoto/DBIx-Custom>
3207

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3208
=head1 AUTHOR
3209

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

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

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

            
3216
This program is free software; you can redistribute it and/or modify it
3217
under the same terms as Perl itself.
3218

            
3219
=cut