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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1771
=head1 NAME
1772

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

            
1775
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1776

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1846
Named place holder support
1847

            
1848
=item *
1849

            
cleanup
Yuki Kimoto authored on 2011-07-29
1850
Model support
1851

            
1852
=item *
1853

            
1854
Connection manager support
1855

            
1856
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1857

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

            
1862
=item *
1863

            
1864
Filtering by data type or column name(EXPERIMENTAL)
1865

            
1866
=item *
1867

            
1868
Create C<order by> clause flexibly(EXPERIMENTAL)
1869

            
1870
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1871

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1923
=head2 C<default_dbi_option>
1924

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

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

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

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

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

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

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

            
1946
    my $last_sql = $dbi->last_sql;
1947
    $dbi = $dbi->last_sql($last_sql);
1948

            
1949
Get last successed SQL executed by C<execute> method.
1950

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1958
=head2 C<password>
1959

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1981
You can set quote pair.
1982

            
1983
    $dbi->quote('[]');
1984

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

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

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

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

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

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

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

            
2002
    my $tag_parse = $dbi->tag_parse(0);
2003
    $dbi = $dbi->tag_parse;
2004

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

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

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

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

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

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

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

            
2023
    print $dbi->available_data_type;
2024

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

            
2028
=head2 C<available_type_name> EXPERIMENTAL
2029

            
2030
    print $dbi->available_type_name;
2031

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

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

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

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

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

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

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

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

            
2049
Create column clause. The follwoing column clause is created.
2050

            
2051
    book.author as "book.author",
2052
    book.title as "book.title"
2053

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

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

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

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

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

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

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

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

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

            
2096
   $dbi->model('book')->select(...);
2097

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

            
2100
    my $dbh = $dbi->dbh;
2101

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

            
2105
=head2 C<each_column>
2106

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2176
=over 4
2177

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

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

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

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

            
2203
    query => 1
2204

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2267
    table_alias => {user => 'hiker'}
2268

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

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

            
2275
    type_rule_off => 1
2276

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

            
2279
=item C<type_rule1_off> EXPERIMENTAL
2280

            
2281
    type_rule1_off => 1
2282

            
2283
Turn C<into1> type rule off.
2284

            
2285
=item C<type_rule2_off> EXPERIMENTAL
2286

            
2287
    type_rule2_off => 1
2288

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2301
=over 4
2302

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

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

            
2307
=item C<filter>
2308

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

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

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

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

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

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

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

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

            
2331
    prefix => 'some'
2332

            
2333
prefix before table name section.
2334

            
2335
    delete some from book
2336

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2345
Table name.
2346

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

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

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

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

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

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

            
2359
=item C<type_rule_off> EXPERIMENTAL
2360

            
2361
Same as C<execute> method's C<type_rule_off> option.
2362

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

            
2365
    type_rule1_off => 1
2366

            
2367
Same as C<execute> method's C<type_rule1_off> option.
2368

            
2369
=item C<type_rule2_off> EXPERIMENTAL
2370

            
2371
    type_rule2_off => 1
2372

            
2373
Same as C<execute> method's C<type_rule2_off> option.
2374

            
updated pod
Yuki Kimoto authored on 2011-06-08
2375
=back
update pod
Yuki Kimoto authored on 2011-03-13
2376

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2384
=head2 C<insert>
2385

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

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

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

            
2394
    {date => \"NOW()"}
2395

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

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

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

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

            
2404
=item C<filter>
2405

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

            
2408
=item C<id>
2409

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

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

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

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

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

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

            
2432
    prefix => 'or replace'
2433

            
2434
prefix before table name section
2435

            
2436
    insert or replace into book
2437

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

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

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

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

            
2447
Same as C<execute> method's C<query> option.
2448

            
2449
=item C<table>
2450

            
2451
    table => 'book'
2452

            
2453
Table name.
2454

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

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

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

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

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

            
2465
    type_rule1_off => 1
2466

            
2467
Same as C<execute> method's C<type_rule1_off> option.
2468

            
2469
=item C<type_rule2_off> EXPERIMENTAL
2470

            
2471
    type_rule2_off => 1
2472

            
2473
Same as C<execute> method's C<type_rule2_off> option.
2474

            
update pod
Yuki Kimoto authored on 2011-03-13
2475
=back
2476

            
2477
=over 4
2478

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2547
=over 4
2548

            
2549
=item Key mapping
2550

            
2551
    'id' => 'book.id'
2552

            
2553
This is only key mapping. Value is same as original one.
2554

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

            
2557
=item Key and value mapping
2558

            
2559
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2560

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

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

            
2567
=item Condition
2568

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

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

            
2576
    sub { defined $_[0] && length $_[0] }
2577

            
2578
=back
2579

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

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

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

            
2586
    {key1 => [1, 1], key2 => 2}
2587

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

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

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

            
2605
    $dbi->update_or_insert;
2606
    $dbi->find_or_create;
2607

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

            
2610
    my $model = $dbi->model('book');
2611

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

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

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

            
2618
Create column clause for myself. The follwoing column clause is created.
2619

            
2620
    book.author as author,
2621
    book.title as title
2622

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

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

            
2632
Create a new L<DBIx::Custom> object.
2633

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

            
2636
    my $not_exists = $dbi->not_exists;
2637

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

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

            
2643
    my $order = $dbi->order;
2644

            
2645
Create a new L<DBIx::Custom::Order> object.
2646

            
cleanup
yuki-kimoto authored on 2010-10-17
2647
=head2 C<register_filter>
2648

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2704
=over 4
2705

            
2706
=item 1. column name
2707

            
2708
    issue_date
2709
    issue_datetime
2710

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

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

            
2715
    book.issue_date
2716
    book.issue_datetime
2717

            
2718
=back
2719

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

            
2722
    print $dbi->available_type_name;
2723

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

            
2728
    print $dbi->available_data_type;
2729

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

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

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

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

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

            
2750
=over 4
2751

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

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

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

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

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

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

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

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

            
2778
    book.author as "book.author",
2779
    book.title as "book.title",
2780
    person.name as "person.name",
2781
    person.age as "person.age"
2782

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

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

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

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

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

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

            
2798
=item C<id>
2799

            
2800
    id => 4
2801
    id => [4, 5]
2802

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

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

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

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

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

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

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

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

            
2833
    prefix => 'SQL_CALC_FOUND_ROWS'
2834

            
2835
Prefix of column cluase
2836

            
2837
    select SQL_CALC_FOUND_ROWS title, author from book;
2838

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2901
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2902

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

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

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

            
2909
    type_rule1_off => 1
2910

            
2911
Same as C<execute> method's C<type_rule1_off> option.
2912

            
2913
=item C<type_rule2_off> EXPERIMENTAL
2914

            
2915
    type_rule2_off => 1
2916

            
2917
Same as C<execute> method's C<type_rule2_off> option.
2918

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

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

            
2949
Wrap statement. This is array reference.
2950

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

            
2953
This option is for Oracle and SQL Server paging process.
2954

            
update pod
Yuki Kimoto authored on 2011-03-12
2955
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2956

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2970
=over 4
2971

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

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

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

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

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

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

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

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

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

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

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

            
3005
    prefix => 'or replace'
3006

            
3007
prefix before table name section
3008

            
3009
    update or replace book
3010

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

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

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

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

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

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

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

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

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

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

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

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

            
3036
=item C<type_rule_off> EXPERIMENTAL
3037

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

            
3040
=item C<type_rule1_off> EXPERIMENTAL
3041

            
3042
    type_rule1_off => 1
3043

            
3044
Same as C<execute> method's C<type_rule1_off> option.
3045

            
3046
=item C<type_rule2_off> EXPERIMENTAL
3047

            
3048
    type_rule2_off => 1
3049

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3052
=back
update pod
Yuki Kimoto authored on 2011-03-13
3053

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

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

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

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

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

            
3065
Create update parameter tag.
3066

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

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

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

            
3076
Create a new L<DBIx::Custom::Where> object.
3077

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

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

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

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

            
3087
=head2 C<DBIX_CUSTOM_DEBUG>
3088

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

            
3092
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3093

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

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

            
3098
L<DBIx::Custom>
3099

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

            
3133
L<DBIx::Custom::Model>
3134

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

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

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

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

            
3175
L<DBIx::Custom::Tag>
3176

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

            
3179
=head1 BACKWORD COMPATIBLE POLICY
3180

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

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

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

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

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

            
3196
C<< <kimoto.yuki at gmail.com> >>
3197

            
3198
L<http://github.com/yuki-kimoto/DBIx-Custom>
3199

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3200
=head1 AUTHOR
3201

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

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

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

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

            
3211
=cut