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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1402
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1403
}
1404

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1776
=head1 NAME
1777

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

            
1780
=head1 SYNOPSYS
cleanup
yuki-kimoto authored on 2010-08-05
1781

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1851
Named place holder support
1852

            
1853
=item *
1854

            
cleanup
Yuki Kimoto authored on 2011-07-29
1855
Model support
1856

            
1857
=item *
1858

            
1859
Connection manager support
1860

            
1861
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
1862

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

            
1867
=item *
1868

            
1869
Filtering by data type or column name(EXPERIMENTAL)
1870

            
1871
=item *
1872

            
1873
Create C<order by> clause flexibly(EXPERIMENTAL)
1874

            
1875
=back
pod fix
Yuki Kimoto authored on 2011-01-21
1876

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1928
=head2 C<default_dbi_option>
1929

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

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

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

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

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

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

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

            
1951
    my $last_sql = $dbi->last_sql;
1952
    $dbi = $dbi->last_sql($last_sql);
1953

            
1954
Get last successed SQL executed by C<execute> method.
1955

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1963
=head2 C<password>
1964

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
1986
You can set quote pair.
1987

            
1988
    $dbi->quote('[]');
1989

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

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

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

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

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

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

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

            
2007
    my $tag_parse = $dbi->tag_parse(0);
2008
    $dbi = $dbi->tag_parse;
2009

            
2010
Enable DEPRECATED tag parsing functionality, default to 1.
2011
If you want to disable tag parsing functionality, set to 0.
2012

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

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

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

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

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

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

            
2028
    print $dbi->available_data_type;
2029

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

            
2033
=head2 C<available_type_name> EXPERIMENTAL
2034

            
2035
    print $dbi->available_type_name;
2036

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

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

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

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

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

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

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

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

            
2054
Create column clause. The follwoing column clause is created.
2055

            
2056
    book.author as "book.author",
2057
    book.title as "book.title"
2058

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

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

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

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

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

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

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

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

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

            
2101
   $dbi->model('book')->select(...);
2102

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

            
2105
    my $dbh = $dbi->dbh;
2106

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

            
2110
=head2 C<each_column>
2111

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

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

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

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

            
2139
Iterate all table informationsfrom database.
2140
Argument is callback when one table is found.
2141
Callback receive three arguments, dbi object, table name,
2142
table information.
2143

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

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

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

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

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

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

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

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

            
2181
=over 4
2182

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

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

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

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

            
2208
    query => 1
2209

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

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

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2243
=item C<table>
2244
    
2245
    table => 'author'
2246

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

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

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

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

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

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

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

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

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

            
2272
    table_alias => {user => 'hiker'}
2273

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

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

            
2280
    type_rule_off => 1
2281

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

            
2284
=item C<type_rule1_off> EXPERIMENTAL
2285

            
2286
    type_rule1_off => 1
2287

            
2288
Turn C<into1> type rule off.
2289

            
2290
=item C<type_rule2_off> EXPERIMENTAL
2291

            
2292
    type_rule2_off => 1
2293

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2306
=over 4
2307

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

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

            
2312
=item C<filter>
2313

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2318
    id => 4
2319
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2320

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

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

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

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

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

            
2336
    prefix => 'some'
2337

            
2338
prefix before table name section.
2339

            
2340
    delete some from book
2341

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

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

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2350
Table name.
2351

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

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

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

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

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

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

            
2364
=item C<type_rule_off> EXPERIMENTAL
2365

            
2366
Same as C<execute> method's C<type_rule_off> option.
2367

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

            
2370
    type_rule1_off => 1
2371

            
2372
Same as C<execute> method's C<type_rule1_off> option.
2373

            
2374
=item C<type_rule2_off> EXPERIMENTAL
2375

            
2376
    type_rule2_off => 1
2377

            
2378
Same as C<execute> method's C<type_rule2_off> option.
2379

            
updated pod
Yuki Kimoto authored on 2011-06-08
2380
=back
update pod
Yuki Kimoto authored on 2011-03-13
2381

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2389
=head2 C<insert>
2390

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

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

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

            
2399
    {date => \"NOW()"}
2400

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

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

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

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

            
2409
=item C<filter>
2410

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

            
2413
=item C<id>
2414

            
updated document
Yuki Kimoto authored on 2011-06-09
2415
    id => 4
2416
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2417

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

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

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

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

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

            
2437
    prefix => 'or replace'
2438

            
2439
prefix before table name section
2440

            
2441
    insert or replace into book
2442

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

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

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

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

            
2452
Same as C<execute> method's C<query> option.
2453

            
2454
=item C<table>
2455

            
2456
    table => 'book'
2457

            
2458
Table name.
2459

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

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

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

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

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

            
2470
    type_rule1_off => 1
2471

            
2472
Same as C<execute> method's C<type_rule1_off> option.
2473

            
2474
=item C<type_rule2_off> EXPERIMENTAL
2475

            
2476
    type_rule2_off => 1
2477

            
2478
Same as C<execute> method's C<type_rule2_off> option.
2479

            
update pod
Yuki Kimoto authored on 2011-03-13
2480
=back
2481

            
2482
=over 4
2483

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2552
=over 4
2553

            
2554
=item Key mapping
2555

            
2556
    'id' => 'book.id'
2557

            
2558
This is only key mapping. Value is same as original one.
2559

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

            
2562
=item Key and value mapping
2563

            
2564
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2565

            
2566
This is key and value mapping. Frist element of array reference
2567
is mapped key name, second element is code reference to map the value.
2568

            
2569
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2570
      if value length is not zero.
2571

            
2572
=item Condition
2573

            
2574
    'price' => ['book.price', {if => 'exists'}]
2575
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2576
    'price' => ['book.price', {if => sub { defined shift }}]
2577

            
2578
If you need condition, you can sepecify it. this is code reference
2579
or 'exists'. By default, condition is the following one.
2580

            
2581
    sub { defined $_[0] && length $_[0] }
2582

            
2583
=back
2584

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

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

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

            
2591
    {key1 => [1, 1], key2 => 2}
2592

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

            
2595
    $dbi->method(
2596
        update_or_insert => 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
        find_or_create   => sub {
2602
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2603
            
2604
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2605
        }
2606
    );
2607

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

            
2610
    $dbi->update_or_insert;
2611
    $dbi->find_or_create;
2612

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

            
2615
    my $model = $dbi->model('book');
2616

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

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

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

            
2623
Create column clause for myself. The follwoing column clause is created.
2624

            
2625
    book.author as author,
2626
    book.title as title
2627

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

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

            
2637
Create a new L<DBIx::Custom> object.
2638

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

            
2641
    my $not_exists = $dbi->not_exists;
2642

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

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

            
2648
    my $order = $dbi->order;
2649

            
2650
Create a new L<DBIx::Custom::Order> object.
2651

            
cleanup
yuki-kimoto authored on 2010-10-17
2652
=head2 C<register_filter>
2653

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2709
=over 4
2710

            
2711
=item 1. column name
2712

            
2713
    issue_date
2714
    issue_datetime
2715

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

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

            
2720
    book.issue_date
2721
    book.issue_datetime
2722

            
2723
=back
2724

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

            
2727
    print $dbi->available_type_name;
2728

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

            
2733
    print $dbi->available_data_type;
2734

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

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

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

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

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

            
2755
=over 4
2756

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

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

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

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

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

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

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

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

            
2783
    book.author as "book.author",
2784
    book.title as "book.title",
2785
    person.name as "person.name",
2786
    person.age as "person.age"
2787

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

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

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

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

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

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

            
2803
=item C<id>
2804

            
2805
    id => 4
2806
    id => [4, 5]
2807

            
2808
ID corresponding to C<primary_key>.
2809
You can select rows by C<id> and C<primary_key>.
2810

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

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

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

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

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

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

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

            
2838
    prefix => 'SQL_CALC_FOUND_ROWS'
2839

            
2840
Prefix of column cluase
2841

            
2842
    select SQL_CALC_FOUND_ROWS title, author from book;
2843

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2906
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
2907

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

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

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

            
2914
    type_rule1_off => 1
2915

            
2916
Same as C<execute> method's C<type_rule1_off> option.
2917

            
2918
=item C<type_rule2_off> EXPERIMENTAL
2919

            
2920
    type_rule2_off => 1
2921

            
2922
Same as C<execute> method's C<type_rule2_off> option.
2923

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

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

            
2954
Wrap statement. This is array reference.
2955

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

            
2958
This option is for Oracle and SQL Server paging process.
2959

            
update pod
Yuki Kimoto authored on 2011-03-12
2960
=back
cleanup
Yuki Kimoto authored on 2011-03-08
2961

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

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

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

            
2968
If you want to set constant value to row data, use scalar reference
2969
as parameter value.
2970

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2975
=over 4
2976

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2987
    id => 4
2988
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
2989

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

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

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

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

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

            
3010
    prefix => 'or replace'
3011

            
3012
prefix before table name section
3013

            
3014
    update or replace book
3015

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

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

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

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

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

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

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

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

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

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

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

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

            
3041
=item C<type_rule_off> EXPERIMENTAL
3042

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

            
3045
=item C<type_rule1_off> EXPERIMENTAL
3046

            
3047
    type_rule1_off => 1
3048

            
3049
Same as C<execute> method's C<type_rule1_off> option.
3050

            
3051
=item C<type_rule2_off> EXPERIMENTAL
3052

            
3053
    type_rule2_off => 1
3054

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3057
=back
update pod
Yuki Kimoto authored on 2011-03-13
3058

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

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

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

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

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

            
3070
Create update parameter tag.
3071

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

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

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

            
3081
Create a new L<DBIx::Custom::Where> object.
3082

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

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

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

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

            
3092
=head2 C<DBIX_CUSTOM_DEBUG>
3093

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

            
3097
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3098

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

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

            
3103
L<DBIx::Custom>
3104

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

            
3138
L<DBIx::Custom::Model>
3139

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

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

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

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

            
3180
L<DBIx::Custom::Tag>
3181

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

            
3184
=head1 BACKWORD COMPATIBLE POLICY
3185

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

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

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

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

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

            
3201
C<< <kimoto.yuki at gmail.com> >>
3202

            
3203
L<http://github.com/yuki-kimoto/DBIx-Custom>
3204

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3205
=head1 AUTHOR
3206

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

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

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

            
3213
This program is free software; you can redistribute it and/or modify it
3214
under the same terms as Perl itself.
3215

            
3216
=cut