DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3192 lines | 82.747kb
cleanup
yuki-kimoto authored on 2009-12-22
1
package DBIx::Custom;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
2
use Object::Simple -base;
cleanup
yuki-kimoto authored on 2009-12-22
3

            
cleanup
Yuki Kimoto authored on 2011-07-30
4
our $VERSION = '0.1706';
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
5
use 5.008001;
cleanup
yuki-kimoto authored on 2009-12-22
6

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

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

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

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

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
81
sub assign_param {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
82
    my ($self, $param) = @_;
83
    
84
    # Create set tag
85
    my @params;
86
    my $safety = $self->safety_character;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
87
    foreach my $column (sort keys %$param) {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
88
        croak qq{"$column" is not safety column name } . _subname
89
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
90
        my $column_quote = $self->_q($column);
91
        $column_quote =~ s/\./$self->_q(".")/e;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
92
        push @params, ref $param->{$column} eq 'SCALAR'
93
          ? "$column_quote = " . ${$param->{$column}}
94
          : "$column_quote = :$column";
95

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-29
1843
Model support
1844

            
1845
=item *
1846

            
1847
Connection manager support
1848

            
1849
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1850

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

            
1855
=item *
1856

            
1857
Filtering by data type or column name(EXPERIMENTAL)
1858

            
1859
=item *
1860

            
1861
Create C<order by> clause flexibly(EXPERIMENTAL)
1862

            
1863
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1864

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

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

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

            
1872
Mosdule documentations - 
1873
L<DBIx::Custom::Result>,
1874
L<DBIx::Custom::Query>,
1875
L<DBIx::Custom::Where>,
1876
L<DBIx::Custom::Model>,
1877
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
1878

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

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

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

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

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

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

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

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

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

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

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

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

            
1916
=head2 C<default_dbi_option>
1917

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

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

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

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

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

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

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

            
1939
    my $last_sql = $dbi->last_sql;
1940
    $dbi = $dbi->last_sql($last_sql);
1941

            
1942
Get last successed SQL executed by C<execute> method.
1943

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1951
=head2 C<password>
1952

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1974
You can set quote pair.
1975

            
1976
    $dbi->quote('[]');
1977

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

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

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

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

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

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

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

            
1995
    my $tag_parse = $dbi->tag_parse(0);
1996
    $dbi = $dbi->tag_parse;
1997

            
1998
Enable DEPRECATED tag parsing functionality, default to 1.
1999
If you want to disable tag parsing functionality, set to 0.
2000

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

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

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

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

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

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

            
2016
    print $dbi->available_data_type;
2017

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

            
2021
=head2 C<available_type_name> EXPERIMENTAL
2022

            
2023
    print $dbi->available_type_name;
2024

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

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

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

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

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

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

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

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

            
2042
Create column clause. The follwoing column clause is created.
2043

            
2044
    book.author as "book.author",
2045
    book.title as "book.title"
2046

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2049
    # Separator is double underbar
2050
    $dbi->separator('__');
2051
    
2052
    book.author as "book__author",
2053
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2054

            
cleanup
Yuki Kimoto authored on 2011-06-13
2055
    # Separator is hyphen
2056
    $dbi->separator('-');
2057
    
2058
    book.author as "book-author",
2059
    book.title as "book-title"
2060
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2061
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2062

            
update pod
Yuki Kimoto authored on 2011-03-13
2063
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2064
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2065
        user => 'ken',
2066
        password => '!LFKD%$&',
2067
        dbi_option => {mysql_enable_utf8 => 1}
2068
    );
2069

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

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

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2078
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2079
        table => 'book',
2080
        primary_key => 'id',
2081
        join => [
2082
            'inner join company on book.comparny_id = company.id'
2083
        ],
2084
    );
2085

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

            
2089
   $dbi->model('book')->select(...);
2090

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

            
2093
    my $dbh = $dbi->dbh;
2094

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

            
2098
=head2 C<each_column>
2099

            
2100
    $dbi->each_column(
2101
        sub {
2102
            my ($dbi, $table, $column, $column_info) = @_;
2103
            
2104
            my $type = $column_info->{TYPE_NAME};
2105
            
2106
            if ($type eq 'DATE') {
2107
                # ...
2108
            }
2109
        }
2110
    );
2111

            
2112
Iterate all column informations of all table from database.
2113
Argument is callback when one column is found.
2114
Callback receive four arguments, dbi object, table name,
2115
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2116

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

            
2119
    $dbi->each_table(
2120
        sub {
2121
            my ($dbi, $table, $table_info) = @_;
2122
            
2123
            my $table_name = $table_info->{TABLE_NAME};
2124
        }
2125
    );
2126

            
2127
Iterate all table informationsfrom database.
2128
Argument is callback when one table is found.
2129
Callback receive three arguments, dbi object, table name,
2130
table information.
2131

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

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

            
2139
    my $result = $dbi->execute(
2140
      "select * from book where title = :book.title and author like :book.author",
2141
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2142
    );
2143

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2150
Parameter is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2151
    
2152
    # Before
2153
    select * from book where title = :title and author like :author
2154
    
2155
    # After
2156
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2157

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

            
2161
    # Before
2162
    select * from book where :title{=} and :author{like}
2163
    
2164
    # After
update pod
Yuki Kimoto authored on 2011-03-13
2165
    select * from where title = ? and author like ?;
2166

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

            
2169
=over 4
2170

            
2171
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2172
    
2173
    filter => {
2174
        title  => sub { uc $_[0] }
2175
        author => sub { uc $_[0] }
2176
    }
update pod
Yuki Kimoto authored on 2011-03-13
2177

            
updated pod
Yuki Kimoto authored on 2011-06-09
2178
    # Filter name
2179
    filter => {
2180
        title  => 'upper_case',
2181
        author => 'upper_case'
2182
    }
2183
        
2184
    # At once
2185
    filter => [
2186
        [qw/title author/]  => sub { uc $_[0] }
2187
    ]
2188

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

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

            
2196
    query => 1
2197

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

            
2201
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2202
    my $sth = $query->sth;
2203

            
2204
If you want to execute SQL as possible as fast and don't need filtering.
2205
You do the following way.
2206
    
2207
    my $query;
2208
    my $sth;
2209
    foreach my $row (@$rows) {
2210
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2211
      $sth ||= $query->sth;
2212
      $sth->execute(map { $row->{$_} } sort keys %$row);
2213
    }
2214

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2219
=item C<table>
2220
    
2221
    table => 'author'
2222

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2230
    # Same
2231
    $dbi->execute(
2232
      "select * from book where title = :book.title and author = :book.author",
2233
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2234

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

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

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

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

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

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

            
2248
    table_alias => {user => 'hiker'}
2249

            
2250
Table alias. Key is real table name, value is alias table name.
2251
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2252
on alias table name.
2253

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

            
2256
    type_rule_off => 1
2257

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

            
2260
=item C<type_rule1_off> EXPERIMENTAL
2261

            
2262
    type_rule1_off => 1
2263

            
2264
Turn C<into1> type rule off.
2265

            
2266
=item C<type_rule2_off> EXPERIMENTAL
2267

            
2268
    type_rule2_off => 1
2269

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2282
=over 4
2283

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

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

            
2288
=item C<filter>
2289

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2294
    id => 4
2295
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2296

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2300
    $dbi->delete(
2301
        parimary_key => ['id1', 'id2'],
2302
        id => [4, 5],
2303
        table => 'book',
2304
    );
update pod
Yuki Kimoto authored on 2011-03-13
2305

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

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

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

            
2312
    prefix => 'some'
2313

            
2314
prefix before table name section.
2315

            
2316
    delete some from book
2317

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2326
Table name.
2327

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

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

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

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

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

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

            
2340
=item C<type_rule_off> EXPERIMENTAL
2341

            
2342
Same as C<execute> method's C<type_rule_off> option.
2343

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

            
2346
    type_rule1_off => 1
2347

            
2348
Same as C<execute> method's C<type_rule1_off> option.
2349

            
2350
=item C<type_rule2_off> EXPERIMENTAL
2351

            
2352
    type_rule2_off => 1
2353

            
2354
Same as C<execute> method's C<type_rule2_off> option.
2355

            
updated pod
Yuki Kimoto authored on 2011-06-08
2356
=back
update pod
Yuki Kimoto authored on 2011-03-13
2357

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2365
=head2 C<insert>
2366

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

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

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

            
2375
    {date => \"NOW()"}
2376

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

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

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

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

            
2385
=item C<filter>
2386

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

            
2389
=item C<id>
2390

            
updated document
Yuki Kimoto authored on 2011-06-09
2391
    id => 4
2392
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2393

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2397
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2398
        {title => 'Perl', author => 'Ken'}
2399
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2400
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2401
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2402
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2403

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

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

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

            
2413
    prefix => 'or replace'
2414

            
2415
prefix before table name section
2416

            
2417
    insert or replace into book
2418

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

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

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

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

            
2428
Same as C<execute> method's C<query> option.
2429

            
2430
=item C<table>
2431

            
2432
    table => 'book'
2433

            
2434
Table name.
2435

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

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

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

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

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

            
2446
    type_rule1_off => 1
2447

            
2448
Same as C<execute> method's C<type_rule1_off> option.
2449

            
2450
=item C<type_rule2_off> EXPERIMENTAL
2451

            
2452
    type_rule2_off => 1
2453

            
2454
Same as C<execute> method's C<type_rule2_off> option.
2455

            
update pod
Yuki Kimoto authored on 2011-03-13
2456
=back
2457

            
2458
=over 4
2459

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2475
    lib / MyModel.pm
2476
        / MyModel / book.pm
2477
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2478

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

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

            
2483
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2484
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2485
    
2486
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2487

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2492
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2493
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2494
    
2495
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2496

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2499
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2500
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2501
    
2502
    1;
2503
    
updated pod
Yuki Kimoto authored on 2011-06-21
2504
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2505

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

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

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

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

            
2515
    my $map_param = $dbi->map_param(
2516
        {id => 1, authro => 'Ken', price => 1900},
2517
        'id' => 'book.id',
2518
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2519
        'price' => [
2520
            'book.price', {if => sub { length $_[0] }}
2521
        ]
2522
    );
2523

            
2524
Map paramters to other key and value. First argument is original
2525
parameter. this is hash reference. Rest argument is mapping.
2526
By default, Mapping is done if the value length is not zero.
2527

            
2528
=over 4
2529

            
2530
=item Key mapping
2531

            
2532
    'id' => 'book.id'
2533

            
2534
This is only key mapping. Value is same as original one.
2535

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

            
2538
=item Key and value mapping
2539

            
2540
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2541

            
2542
This is key and value mapping. Frist element of array reference
2543
is mapped key name, second element is code reference to map the value.
2544

            
2545
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2546
      if value length is not zero.
2547

            
2548
=item Condition
2549

            
2550
    'price' => ['book.price', {if => 'exists'}]
2551
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2552
    'price' => ['book.price', {if => sub { defined shift }}]
2553

            
2554
If you need condition, you can sepecify it. this is code reference
2555
or 'exists'. By default, condition is the following one.
2556

            
2557
    sub { defined $_[0] && length $_[0] }
2558

            
2559
=back
2560

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

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

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

            
2567
    {key1 => [1, 1], key2 => 2}
2568

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

            
2571
    $dbi->method(
2572
        update_or_insert => sub {
2573
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2574
            
2575
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2576
        },
2577
        find_or_create   => sub {
2578
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2579
            
2580
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2581
        }
2582
    );
2583

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

            
2586
    $dbi->update_or_insert;
2587
    $dbi->find_or_create;
2588

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

            
2591
    my $model = $dbi->model('book');
2592

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

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

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

            
2599
Create column clause for myself. The follwoing column clause is created.
2600

            
2601
    book.author as author,
2602
    book.title as title
2603

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2606
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2607
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2608
        user => 'ken',
2609
        password => '!LFKD%$&',
2610
        dbi_option => {mysql_enable_utf8 => 1}
2611
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2612

            
2613
Create a new L<DBIx::Custom> object.
2614

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

            
2617
    my $not_exists = $dbi->not_exists;
2618

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

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

            
2624
    my $order = $dbi->order;
2625

            
2626
Create a new L<DBIx::Custom::Order> object.
2627

            
cleanup
yuki-kimoto authored on 2010-10-17
2628
=head2 C<register_filter>
2629

            
update pod
Yuki Kimoto authored on 2011-03-13
2630
    $dbi->register_filter(
2631
        # Time::Piece object to database DATE format
2632
        tp_to_date => sub {
2633
            my $tp = shift;
2634
            return $tp->strftime('%Y-%m-%d');
2635
        },
2636
        # database DATE format to Time::Piece object
2637
        date_to_tp => sub {
2638
           my $date = shift;
2639
           return Time::Piece->strptime($date, '%Y-%m-%d');
2640
        }
2641
    );
cleanup
yuki-kimoto authored on 2010-10-17
2642
    
update pod
Yuki Kimoto authored on 2011-03-13
2643
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2644

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

            
2647
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2648
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2649
            date => sub { ... },
2650
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2651
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2652
        into2 => {
2653
            date => sub { ... },
2654
            datetime => sub { ... }
2655
        },
2656
        from1 => {
2657
            # DATE
2658
            9 => sub { ... },
2659
            # DATETIME or TIMESTAMP
2660
            11 => sub { ... },
2661
        }
2662
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2663
            # DATE
2664
            9 => sub { ... },
2665
            # DATETIME or TIMESTAMP
2666
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2667
        }
2668
    );
2669

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2685
=over 4
2686

            
2687
=item 1. column name
2688

            
2689
    issue_date
2690
    issue_datetime
2691

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

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

            
2696
    book.issue_date
2697
    book.issue_datetime
2698

            
2699
=back
2700

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

            
2703
    print $dbi->available_type_name;
2704

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

            
2709
    print $dbi->available_data_type;
2710

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

            
2713
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2714
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2715
            [qw/DATE DATETIME/] => sub { ... },
2716
        ],
2717
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2718

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2721
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2722
        table  => 'book',
2723
        column => ['author', 'title'],
2724
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2725
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2726
    
updated document
Yuki Kimoto authored on 2011-06-09
2727
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2728

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

            
2731
=over 4
2732

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2737
Append statement to last of SQL.
2738
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2739
=item C<column>
2740
    
updated document
Yuki Kimoto authored on 2011-06-09
2741
    column => 'author'
2742
    column => ['author', 'title']
2743

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2752
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2753
        {book => [qw/author title/]},
2754
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2755
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2756

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

            
2759
    book.author as "book.author",
2760
    book.title as "book.title",
2761
    person.name as "person.name",
2762
    person.age as "person.age"
2763

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

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

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

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

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

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

            
2779
=item C<id>
2780

            
2781
    id => 4
2782
    id => [4, 5]
2783

            
2784
ID corresponding to C<primary_key>.
2785
You can select rows by C<id> and C<primary_key>.
2786

            
2787
    $dbi->select(
2788
        parimary_key => ['id1', 'id2'],
2789
        id => [4, 5],
2790
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2791
    );
2792

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
2795
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
2796
        where => {id1 => 4, id2 => 5},
2797
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2798
    );
2799
    
updated document
Yuki Kimoto authored on 2011-06-09
2800
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2801

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

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

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

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

            
2814
    prefix => 'SQL_CALC_FOUND_ROWS'
2815

            
2816
Prefix of column cluase
2817

            
2818
    select SQL_CALC_FOUND_ROWS title, author from book;
2819

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

            
2822
    join => [
2823
        'left outer join company on book.company_id = company_id',
2824
        'left outer join location on company.location_id = location.id'
2825
    ]
2826
        
2827
Join clause. If column cluase or where clause contain table name like "company.name",
2828
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
2829

            
2830
    $dbi->select(
2831
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
2832
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
2833
        where => {'company.name' => 'Orange'},
2834
        join => [
2835
            'left outer join company on book.company_id = company.id',
2836
            'left outer join location on company.location_id = location.id'
2837
        ]
2838
    );
2839

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2843
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
2844
    from book
2845
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
2846
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
2847

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

            
2851
    $dbi->select(
2852
        table => 'book',
2853
        column => ['company.location_id as location_id'],
2854
        where => {'company.name' => 'Orange'},
2855
        join => [
2856
            {
2857
                clause => 'left outer join location on company.location_id = location.id',
2858
                table => ['company', 'location']
2859
            }
2860
        ]
2861
    );
2862

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2882
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2883

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

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

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

            
2890
    type_rule1_off => 1
2891

            
2892
Same as C<execute> method's C<type_rule1_off> option.
2893

            
2894
=item C<type_rule2_off> EXPERIMENTAL
2895

            
2896
    type_rule2_off => 1
2897

            
2898
Same as C<execute> method's C<type_rule2_off> option.
2899

            
updated document
Yuki Kimoto authored on 2011-06-09
2900
=item C<where>
2901
    
2902
    # Hash refrence
2903
    where => {author => 'Ken', 'title' => 'Perl'}
2904
    
2905
    # DBIx::Custom::Where object
2906
    where => $dbi->where(
2907
        clause => ['and', 'author = :author', 'title like :title'],
2908
        param  => {author => 'Ken', title => '%Perl%'}
2909
    );
updated pod
Yuki Kimoto authored on 2011-06-21
2910
    
2911
    # Array reference 1 (array reference, hash referenc). same as above
2912
    where => [
2913
        ['and', 'author = :author', 'title like :title'],
2914
        {author => 'Ken', title => '%Perl%'}
2915
    ];    
2916
    
2917
    # Array reference 2 (String, hash reference)
2918
    where => [
2919
        'title like :title',
2920
        {title => '%Perl%'}
2921
    ]
2922
    
2923
    # String
2924
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
2925

            
updated document
Yuki Kimoto authored on 2011-06-09
2926
Where clause.
2927
    
improved pod
Yuki Kimoto authored on 2011-04-19
2928
=item C<wrap> EXPERIMENTAL
2929

            
2930
Wrap statement. This is array reference.
2931

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

            
2934
This option is for Oracle and SQL Server paging process.
2935

            
update pod
Yuki Kimoto authored on 2011-03-12
2936
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2937

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

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

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

            
2944
If you want to set constant value to row data, use scalar reference
2945
as parameter value.
2946

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2951
=over 4
2952

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2963
    id => 4
2964
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2965

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2969
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
2970
        {title => 'Perl', author => 'Ken'}
2971
        parimary_key => ['id1', 'id2'],
2972
        id => [4, 5],
2973
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
2974
    );
update pod
Yuki Kimoto authored on 2011-03-13
2975

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2978
    $dbi->update(
2979
        {title => 'Perl', author => 'Ken'}
2980
        where => {id1 => 4, id2 => 5},
2981
        table => 'book'
2982
    );
update pod
Yuki Kimoto authored on 2011-03-13
2983

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

            
2986
    prefix => 'or replace'
2987

            
2988
prefix before table name section
2989

            
2990
    update or replace book
2991

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

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

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

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

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

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

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

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

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

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

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

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

            
3017
=item C<type_rule_off> EXPERIMENTAL
3018

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

            
3021
=item C<type_rule1_off> EXPERIMENTAL
3022

            
3023
    type_rule1_off => 1
3024

            
3025
Same as C<execute> method's C<type_rule1_off> option.
3026

            
3027
=item C<type_rule2_off> EXPERIMENTAL
3028

            
3029
    type_rule2_off => 1
3030

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3033
=back
update pod
Yuki Kimoto authored on 2011-03-13
3034

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

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

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

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

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

            
3046
Create update parameter tag.
3047

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

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

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

            
3057
Create a new L<DBIx::Custom::Where> object.
3058

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

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

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

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

            
3068
=head2 C<DBIX_CUSTOM_DEBUG>
3069

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

            
3073
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3074

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

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

            
3079
L<DBIx::Custom>
3080

            
3081
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3082
    data_source # will be removed at 2017/1/1
3083
    dbi_options # will be removed at 2017/1/1
3084
    filter_check # will be removed at 2017/1/1
3085
    reserved_word_quote # will be removed at 2017/1/1
3086
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3087
    
3088
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3089
    create_query # will be removed at 2017/1/1
3090
    apply_filter # will be removed at 2017/1/1
3091
    select_at # will be removed at 2017/1/1
3092
    delete_at # will be removed at 2017/1/1
3093
    update_at # will be removed at 2017/1/1
3094
    insert_at # will be removed at 2017/1/1
3095
    register_tag # will be removed at 2017/1/1
3096
    default_bind_filter # will be removed at 2017/1/1
3097
    default_fetch_filter # will be removed at 2017/1/1
3098
    insert_param_tag # will be removed at 2017/1/1
3099
    register_tag_processor # will be removed at 2017/1/1
3100
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3101
    
3102
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3103
    select method relation option # will be removed at 2017/1/1
3104
    select method param option # will be removed at 2017/1/1
3105
    select method column option [COLUMN, as => ALIAS] format
3106
      # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3107
    
3108
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3109
    execute("select * from {= title}"); # execute method's
3110
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3111
                                        # will be removed at 2017/1/1
3112
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3113

            
3114
L<DBIx::Custom::Model>
3115

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3116
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3117
    filter # will be removed at 2017/1/1
3118
    name # will be removed at 2017/1/1
3119
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3120

            
3121
L<DBIx::Custom::Query>
3122
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3123
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3124
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3125
    table # will be removed at 2017/1/1
3126
    filters # will be removed at 2017/1/1
3127
    
3128
    # Methods
3129
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3130

            
3131
L<DBIx::Custom::QueryBuilder>
3132
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3133
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3134
    tags # will be removed at 2017/1/1
3135
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3136
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3137
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3138
    register_tag # will be removed at 2017/1/1
3139
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3140
    
3141
    # Others
3142
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3143
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3144

            
3145
L<DBIx::Custom::Result>
3146
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3147
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3148
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3149
    
3150
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3151
    end_filter # will be removed at 2017/1/1
3152
    remove_end_filter # will be removed at 2017/1/1
3153
    remove_filter # will be removed at 2017/1/1
3154
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3155

            
3156
L<DBIx::Custom::Tag>
3157

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

            
3160
=head1 BACKWORD COMPATIBLE POLICY
3161

            
3162
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3163
except for attribute method.
3164
You can check all DEPRECATED functionalities by document.
3165
DEPRECATED functionality is removed after five years,
3166
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
3167
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3168

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

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

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

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

            
3177
C<< <kimoto.yuki at gmail.com> >>
3178

            
3179
L<http://github.com/yuki-kimoto/DBIx-Custom>
3180

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3181
=head1 AUTHOR
3182

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

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

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

            
3189
This program is free software; you can redistribute it and/or modify it
3190
under the same terms as Perl itself.
3191

            
3192
=cut