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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
4
our $VERSION = '0.1724';
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/;
added tests
Yuki Kimoto authored on 2011-08-26
17
use DBIx::Custom::Mapper;
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
18
use DBIx::Custom::NotExists;
improved debug message
Yuki Kimoto authored on 2011-05-23
19
use Encode qw/encode encode_utf8 decode_utf8/;
cleanup
Yuki Kimoto authored on 2011-08-13
20
use Scalar::Util qw/weaken/;
packaging one directory
yuki-kimoto authored on 2009-11-16
21

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

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

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
70
sub available_datatype {
test cleanup
Yuki Kimoto authored on 2011-08-10
71
    my $self = shift;
72
    
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
73
    my $data_types = '';
74
    foreach my $i (-1000 .. 1000) {
75
         my $type_info = $self->dbh->type_info($i);
76
         my $data_type = $type_info->{DATA_TYPE};
77
         my $type_name = $type_info->{TYPE_NAME};
78
         $data_types .= "$data_type ($type_name)\n"
79
           if defined $data_type;
80
    }
81
    return "Data Type maybe equal to Type Name" unless $data_types;
82
    $data_types = "Data Type (Type name)\n" . $data_types;
83
    return $data_types;
84
}
85

            
86
sub available_typename {
87
    my $self = shift;
88
    
89
    # Type Names
90
    my $type_names = {};
91
    $self->each_column(sub {
92
        my ($self, $table, $column, $column_info) = @_;
93
        $type_names->{$column_info->{TYPE_NAME}} = 1
94
          if $column_info->{TYPE_NAME};
95
    });
96
    my @output = sort keys %$type_names;
97
    unshift @output, "Type Name";
98
    return join "\n", @output;
test cleanup
Yuki Kimoto authored on 2011-08-10
99
}
100

            
added helper method
yuki-kimoto authored on 2010-10-17
101
our $AUTOLOAD;
102
sub AUTOLOAD {
103
    my $self = shift;
104

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
108
    # Call method
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
109
    $self->{_methods} ||= {};
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
110
    if (my $method = $self->{_methods}->{$mname}) {
111
        return $self->$method(@_)
112
    }
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
113
    elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
114
        $self->dbh->$dbh_method(@_);
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
115
    }
116
    else {
cleanup
Yuki Kimoto authored on 2011-04-25
117
        croak qq{Can't locate object method "$mname" via "$package" }
118
            . _subname;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
119
    }
added helper method
yuki-kimoto authored on 2010-10-17
120
}
121

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
122
sub assign_param {
updated pod
Yuki Kimoto authored on 2011-09-02
123
    my ($self, $param, $opts) = @_;
124
    
125
    my $wrap = $opts->{wrap} || {};
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
126
    
127
    # Create set tag
128
    my @params;
129
    my $safety = $self->safety_character;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
130
    foreach my $column (sort keys %$param) {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
131
        croak qq{"$column" is not safety column name } . _subname
132
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
133
        my $column_quote = $self->_q($column);
134
        $column_quote =~ s/\./$self->_q(".")/e;
updated pod
Yuki Kimoto authored on 2011-09-02
135
        my $func = $wrap->{$column} || sub { $_[0] };
136
        push @params,
137
          ref $param->{$column} eq 'SCALAR' ? "$column_quote = " . ${$param->{$column}}
138
        : "$column_quote = " . $func->(":$column");
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
139
    }
140
    my $tag = join(', ', @params);
141
    
142
    return $tag;
143
}
144

            
cleanup
Yuki Kimoto authored on 2011-03-21
145
sub column {
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
146
    my $self = shift;
147
    my $option = pop if ref $_[-1] eq 'HASH';
148
    my $real_table = shift;
149
    my $columns = shift;
150
    my $table = $option->{alias} || $real_table;
151
    
152
    # Columns
153
    unless ($columns) {
154
        $columns ||= $self->model($real_table)->columns;
155
    }
added helper method
yuki-kimoto authored on 2010-10-17
156
    
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
157
    # Separator
158
    my $separator = $self->separator;
159
    
cleanup
Yuki Kimoto authored on 2011-04-02
160
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-21
161
    my @column;
cleanup
Yuki Kimoto authored on 2011-04-02
162
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
163
    push @column, $self->_q($table) . "." . $self->_q($_) .
164
      " as " . $self->_q("${table}${separator}$_")
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
165
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
166
    
167
    return join (', ', @column);
added helper method
yuki-kimoto authored on 2010-10-17
168
}
169

            
packaging one directory
yuki-kimoto authored on 2009-11-16
170
sub connect {
cleanup
Yuki Kimoto authored on 2011-08-16
171
    my $self = ref $_[0] ? shift : shift->new(@_);
172
    
173
    my $connector = $self->connector;
174
    
175
    if (!ref $connector && $connector) {
176
        require DBIx::Connector;
177
        
178
        my $dsn = $self->dsn;
179
        my $user = $self->user;
180
        my $password = $self->password;
181
        my $dbi_option = {%{$self->dbi_options}, %{$self->dbi_option}};
182
        my $connector = DBIx::Connector->new($dsn, $user, $password,
183
          {%{$self->default_dbi_option} , %$dbi_option});
184
        $self->connector($connector);
185
    }
removed register_format()
yuki-kimoto authored on 2010-05-26
186
    
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
187
    # Connect
188
    $self->dbh;
update document
yuki-kimoto authored on 2010-01-30
189
    
packaging one directory
yuki-kimoto authored on 2009-11-16
190
    return $self;
191
}
192

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
193
sub count { shift->select(column => 'count(*)', @_)->fetch_first->[0] }
194

            
update pod
Yuki Kimoto authored on 2011-03-13
195
sub dbh {
196
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-04-02
197
    
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
198
    # Set
199
    if (@_) {
200
        $self->{dbh} = $_[0];
201
        
202
        return $self;
203
    }
204
    
205
    # Get
206
    else {
207
        # From Connction manager
208
        if (my $connector = $self->connector) {
cleanup
Yuki Kimoto authored on 2011-04-25
209
            croak "connector must have dbh() method " . _subname
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
210
              unless ref $connector && $connector->can('dbh');
211
              
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
212
            $self->{dbh} = $connector->dbh;
fixed dbh() method bug:wq
Yuki Kimoto authored on 2011-04-05
213
        }
214
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
215
        # Connect
216
        $self->{dbh} ||= $self->_connect;
217
        
218
        # Quote
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
219
        if (!defined $self->reserved_word_quote && !defined $self->quote) {
prepare oracle test
Yuki Kimoto authored on 2011-08-15
220
            my $driver = $self->_driver;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
221
            my $quote =  $driver eq 'odbc' ? '[]'
222
                       : $driver eq 'ado' ? '[]'
223
                       : $driver eq 'mysql' ? '`'
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
224
                       : '"';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
225
            $self->quote($quote);
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
226
        }
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
227
        
set reserved_word_quote auto...
Yuki Kimoto authored on 2011-06-08
228
        return $self->{dbh};
update pod
Yuki Kimoto authored on 2011-03-13
229
    }
230
}
231

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

            
cleanup update and update_al...
yuki-kimoto authored on 2010-04-28
235
    # Arguments
cleanup
Yuki Kimoto authored on 2011-03-21
236
    my $table = $args{table} || '';
cleanup
Yuki Kimoto authored on 2011-04-25
237
    croak qq{"table" option must be specified. } . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
238
      unless $table;
cleanup
Yuki Kimoto authored on 2011-03-21
239
    my $where            = delete $args{where} || {};
240
    my $append           = delete $args{append};
241
    my $allow_delete_all = delete $args{allow_delete_all};
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
242
    my $where_param      = delete $args{where_param} || {};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
243
    my $id = delete $args{id};
244
    my $primary_key = delete $args{primary_key};
245
    croak "update method primary_key option " .
246
          "must be specified when id is specified " . _subname
247
      if defined $id && !defined $primary_key;
248
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
249
    my $prefix = delete $args{prefix};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
250
    
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
251
    # Where
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
252
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
253
    my $where_clause = '';
updated pod
Yuki Kimoto authored on 2011-06-21
254
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
255
        $where_clause = "where " . $where->[0];
256
        $where_param = $where->[1];
257
    }
258
    elsif (ref $where) {
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
259
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
260
        $where_param = keys %$where_param
261
                     ? $self->merge_param($where_param, $where->param)
262
                     : $where->param;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
263
        
264
        # String where
265
        $where_clause = $where->to_string;
266
    }
267
    elsif ($where) { $where_clause = "where $where" }
cleanup
Yuki Kimoto authored on 2011-04-25
268
    croak qq{"where" must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
269
      if $where_clause eq '' && !$allow_delete_all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
270

            
cleanup
Yuki Kimoto authored on 2011-04-02
271
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-01-27
272
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
273
    push @sql, "delete";
274
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
275
    push @sql, "from " . $self->_q($table) . " $where_clause";
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
276
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
277
    my $sql = join(' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
278
    
279
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
280
    return $self->execute($sql, $where_param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
281
}
282

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

            
added memory leak check test
Yuki Kimoto authored on 2011-08-15
285
sub DESTROY {}
added helper method
yuki-kimoto authored on 2010-10-17
286

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
287
sub create_model {
288
    my $self = shift;
289
    
cleanup
Yuki Kimoto authored on 2011-04-02
290
    # Arguments
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
291
    my $args = ref $_[0] eq 'HASH' ? $_[0] : {@_};
292
    $args->{dbi} = $self;
293
    my $model_class = delete $args->{model_class} || 'DBIx::Custom::Model';
294
    my $model_name  = delete $args->{name};
295
    my $model_table = delete $args->{table};
296
    $model_name ||= $model_table;
297
    
cleanup
Yuki Kimoto authored on 2011-04-02
298
    # Create model
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
299
    my $model = $model_class->new($args);
cleanup
Yuki Kimoto authored on 2011-08-13
300
    weaken $model->{dbi};
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
301
    $model->name($model_name) unless $model->name;
302
    $model->table($model_table) unless $model->table;
303
    
micro optimization
Yuki Kimoto authored on 2011-07-30
304
    # Apply filter(DEPRECATED logic)
305
    if ($model->{filter}) {
306
        my $filter = ref $model->filter eq 'HASH'
307
                   ? [%{$model->filter}]
308
                   : $model->filter;
309
        $filter ||= [];
310
        warn "DBIx::Custom::Model filter method is DEPRECATED!"
311
          if @$filter;
312
        $self->_apply_filter($model->table, @$filter);
313
    }
314
    
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
315
    # Set model
316
    $self->model($model->name, $model);
317
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
318
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
319
}
320

            
321
sub each_column {
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
322
    my ($self, $cb, %options) = @_;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
323

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
324
    my $user_column_info = $self->user_column_info;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
325
    
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
326
    if ($user_column_info) {
327
        $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
328
    }
329
    else {
330
    
331
        my $re = $self->exclude_table || $options{exclude_table};
332
        # Tables
333
        my %tables;
334
        $self->each_table(sub { $tables{$_[1]}++ });
added SQL Server test
Yuki Kimoto authored on 2011-08-14
335

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
336
        # Iterate all tables
337
        my @tables = sort keys %tables;
338
        for (my $i = 0; $i < @tables; $i++) {
339
            my $table = $tables[$i];
340
            
341
            # Iterate all columns
342
            my $sth_columns;
343
            eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
344
            next if $@;
345
            while (my $column_info = $sth_columns->fetchrow_hashref) {
346
                my $column = $column_info->{COLUMN_NAME};
347
                $self->$cb($table, $column, $column_info);
348
            }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
349
        }
350
    }
351
}
352

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
353
sub each_table {
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
354
    my ($self, $cb, %option) = @_;
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
355
    
cleanup test
Yuki Kimoto authored on 2011-08-16
356
    my $user_table_infos = $self->user_table_info;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
357
    
added test
Yuki Kimoto authored on 2011-08-16
358
    # Iterate tables
359
    if ($user_table_infos) {
360
        $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
361
    }
362
    else {
363
        my $re = $self->exclude_table || $option{exclude};
364
        my $sth_tables = $self->dbh->table_info;
365
        while (my $table_info = $sth_tables->fetchrow_hashref) {
366
            
367
            # Table
368
            my $table = $table_info->{TABLE_NAME};
369
            next if defined $re && $table =~ /$re/;
370
            $self->$cb($table, $table_info);
371
        }
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
372
    }
373
}
374

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
375
our %VALID_ARGS = map { $_ => 1 } qw/append after_build_sql allow_delete_all
simplified arguments check
Yuki Kimoto authored on 2011-07-11
376
  allow_update_all bind_type column filter id join param prefix primary_key
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
377
  query relation sqlfilter table table_alias timestamp type type_rule_off
378
  type_rule1_off type_rule2_off wrap/;
cleanup
Yuki Kimoto authored on 2011-04-02
379

            
380
sub execute {
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
381
    my $self = shift;
382
    my $query = shift;
383
    my $param;
384
    $param = shift if @_ % 2;
385
    my %args = @_;
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
386
    
cleanup
Yuki Kimoto authored on 2011-04-02
387
    # Arguments
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
388
    my $p = delete $args{param} || {};
389
    $param ||= $p;
cleanup
Yuki Kimoto authored on 2011-04-02
390
    my $tables = delete $args{table} || [];
391
    $tables = [$tables] unless ref $tables eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-04-02
392
    my $filter = delete $args{filter};
cleanup
Yuki Kimoto authored on 2011-04-25
393
    $filter = _array_to_hash($filter);
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
394
    my $bind_type = delete $args{bind_type} || delete $args{type};
395
    $bind_type = _array_to_hash($bind_type);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
396
    my $type_rule_off = delete $args{type_rule_off};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
397
    my $type_rule_off_parts = {
398
        1 => delete $args{type_rule1_off},
399
        2 => delete $args{type_rule2_off}
400
    };
cleanup
Yuki Kimoto authored on 2011-06-09
401
    my $query_return = delete $args{query};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
402
    my $table_alias = delete $args{table_alias} || {};
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
403
    my $after_build_sql = $args{after_build_sql} || $args{sqlfilter};
404
    warn "sqlfilter option is DEPRECATED" if $args{sqlfilter};
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
405
    my $id = delete $args{id};
406
    my $primary_key = delete $args{primary_key};
407
    croak "insert method primary_key option " .
408
          "must be specified when id is specified " . _subname
409
      if defined $id && !defined $primary_key;
410
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
411

            
412
    if (defined $id) {
413
        my $id_param = $self->_create_param_from_id($id, $primary_key);
414
        $param = $self->merge_param($id_param, $param);
415
    }
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
416
    
cleanup
Yuki Kimoto authored on 2011-03-09
417
    # Check argument names
select, insert, update, upda...
yuki-kimoto authored on 2010-06-14
418
    foreach my $name (keys %args) {
cleanup
Yuki Kimoto authored on 2011-04-25
419
        croak qq{"$name" is wrong option } . _subname
simplified arguments check
Yuki Kimoto authored on 2011-07-11
420
          unless $VALID_ARGS{$name};
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
421
    }
422
    
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
423
    $query = $self->_create_query($query, $after_build_sql) unless ref $query;
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
424
    
425
    # Save query
426
    $self->last_sql($query->sql);
427

            
cleanup
Yuki Kimoto authored on 2011-06-09
428
    return $query if $query_return;
micro optimization
Yuki Kimoto authored on 2011-07-30
429
    
430
    # DEPRECATED! Merge query filter
DBIx::Custom::Query filter m...
Yuki Kimoto authored on 2011-07-30
431
    $filter ||= $query->{filter} || {};
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
432
    
cleanup
Yuki Kimoto authored on 2011-04-02
433
    # Tables
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
434
    unshift @$tables, @{$query->{tables} || []};
micro optimization
Yuki Kimoto authored on 2011-07-30
435
    my $main_table = @{$tables}[-1];
micro optimization
Yuki Kimoto authored on 2011-07-30
436
    
micro optimization
Yuki Kimoto authored on 2011-07-30
437
    # DEPRECATED! Cleanup tables
micro optimization
Yuki Kimoto authored on 2011-07-30
438
    $tables = $self->_remove_duplicate_table($tables, $main_table)
439
      if @$tables > 1;
cleanup
Yuki Kimoto authored on 2011-04-02
440
    
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
441
    # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
442
    my $type_filters = {};
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
443
    unless ($type_rule_off) {
micro optimization
Yuki Kimoto authored on 2011-07-30
444
        foreach my $i (1, 2) {
445
            unless ($type_rule_off_parts->{$i}) {
446
                $type_filters->{$i} = {};
447
                foreach my $alias (keys %$table_alias) {
448
                    my $table = $table_alias->{$alias};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
449
                    
micro optimization
Yuki Kimoto authored on 2011-07-30
450
                    foreach my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
451
                        $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
452
                    }
453
                }
micro optimization
Yuki Kimoto authored on 2011-07-30
454
                $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
455
                  if $main_table;
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
456
            }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
457
        }
458
    }
cleanup
Yuki Kimoto authored on 2011-04-02
459
    
micro optimization
Yuki Kimoto authored on 2011-07-30
460
    # DEPRECATED! Applied filter
micro optimization
Yuki Kimoto authored on 2011-07-30
461
    if ($self->{filter}{on}) {
462
        my $applied_filter = {};
463
        foreach my $table (@$tables) {
464
            $applied_filter = {
465
                %$applied_filter,
466
                %{$self->{filter}{out}->{$table} || {}}
467
            }
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
468
        }
micro optimization
Yuki Kimoto authored on 2011-07-30
469
        $filter = {%$applied_filter, %$filter};
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
470
    }
471
    
cleanup
Yuki Kimoto authored on 2011-04-02
472
    # Replace filter name to code
473
    foreach my $column (keys %$filter) {
474
        my $name = $filter->{$column};
475
        if (!defined $name) {
476
            $filter->{$column} = undef;
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
477
        }
cleanup
Yuki Kimoto authored on 2011-04-02
478
        elsif (ref $name ne 'CODE') {
cleanup
Yuki Kimoto authored on 2011-04-25
479
          croak qq{Filter "$name" is not registered" } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
480
            unless exists $self->filters->{$name};
481
          $filter->{$column} = $self->filters->{$name};
cleanup
Yuki Kimoto authored on 2010-12-21
482
        }
483
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
484
    
cleanup
Yuki Kimoto authored on 2011-04-02
485
    # Create bind values
486
    my $bind = $self->_create_bind_values(
487
        $param,
488
        $query->columns,
489
        $filter,
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
490
        $type_filters,
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
491
        $bind_type
cleanup
Yuki Kimoto authored on 2011-04-02
492
    );
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
493

            
cleanup
yuki-kimoto authored on 2010-10-17
494
    # Execute
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
495
    my $sth = $query->sth;
cleanup
yuki-kimoto authored on 2010-10-17
496
    my $affected;
cleanup
Yuki Kimoto authored on 2011-03-21
497
    eval {
498
        for (my $i = 0; $i < @$bind; $i++) {
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
499
            my $bind_type = $bind->[$i]->{bind_type};
500
            $sth->bind_param(
501
                $i + 1,
502
                $bind->[$i]->{value},
503
                $bind_type ? $bind_type : ()
504
            );
cleanup
Yuki Kimoto authored on 2011-03-21
505
        }
506
        $affected = $sth->execute;
507
    };
improved error messages
Yuki Kimoto authored on 2011-04-18
508
    
micro optimization
Yuki Kimoto authored on 2011-07-30
509
    $self->_croak($@, qq{. Following SQL is executed.\n}
510
      . qq{$query->{sql}\n} . _subname) if $@;
cleanup
yuki-kimoto authored on 2010-10-17
511
    
improved debug message
Yuki Kimoto authored on 2011-05-23
512
    # DEBUG message
513
    if (DEBUG) {
514
        print STDERR "SQL:\n" . $query->sql . "\n";
515
        my @output;
516
        foreach my $b (@$bind) {
517
            my $value = $b->{value};
518
            $value = 'undef' unless defined $value;
519
            $value = encode(DEBUG_ENCODING(), $value)
520
              if utf8::is_utf8($value);
521
            push @output, $value;
522
        }
523
        print STDERR "Bind values: " . join(', ', @output) . "\n\n";
524
    }
added environment variable D...
Yuki Kimoto authored on 2011-04-02
525
    
cleanup
Yuki Kimoto authored on 2011-04-02
526
    # Select statement
cleanup
yuki-kimoto authored on 2010-10-17
527
    if ($sth->{NUM_OF_FIELDS}) {
528
        
micro optimization
Yuki Kimoto authored on 2011-07-30
529
        # DEPRECATED! Filter
cleanup
Yuki Kimoto authored on 2011-04-02
530
        my $filter = {};
micro optimization
Yuki Kimoto authored on 2011-07-30
531
        if ($self->{filter}{on}) {
532
            $filter->{in}  = {};
533
            $filter->{end} = {};
534
            push @$tables, $main_table if $main_table;
535
            foreach my $table (@$tables) {
536
                foreach my $way (qw/in end/) {
537
                    $filter->{$way} = {
538
                        %{$filter->{$way}},
539
                        %{$self->{filter}{$way}{$table} || {}}
540
                    };
541
                }
cleanup
Yuki Kimoto authored on 2011-04-02
542
            }
cleanup
Yuki Kimoto authored on 2011-01-12
543
        }
544
        
545
        # Result
546
        my $result = $self->result_class->new(
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
547
            sth => $sth,
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
548
            dbi => $self,
cleanup
Yuki Kimoto authored on 2011-01-12
549
            default_filter => $self->{default_in_filter},
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
550
            filter => $filter->{in} || {},
551
            end_filter => $filter->{end} || {},
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
552
            type_rule => {
553
                from1 => $self->type_rule->{from1},
554
                from2 => $self->type_rule->{from2}
555
            },
cleanup
yuki-kimoto authored on 2010-10-17
556
        );
557

            
558
        return $result;
559
    }
cleanup
Yuki Kimoto authored on 2011-04-02
560
    
561
    # Not select statement
562
    else { return $affected }
cleanup
yuki-kimoto authored on 2010-10-17
563
}
564

            
added test
Yuki Kimoto authored on 2011-08-16
565
sub get_table_info {
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
566
    my ($self, %args) = @_;
567
    
568
    my $exclude = delete $args{exclude};
569
    croak qq/"$_" is wrong option/ for keys %args;
570
    
added test
Yuki Kimoto authored on 2011-08-16
571
    my $table_info = [];
572
    $self->each_table(
573
        sub { push @$table_info, {table => $_[1], info => $_[2] } },
574
        exclude => $exclude
575
    );
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
576
    
cleanup test
Yuki Kimoto authored on 2011-08-16
577
    return [sort {$a->{table} cmp $b->{table} } @$table_info];
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
578
}
579

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
580
sub get_column_info {
581
    my ($self, %args) = @_;
582
    
583
    my $exclude_table = delete $args{exclude_table};
584
    croak qq/"$_" is wrong option/ for keys %args;
585
    
586
    my $column_info = [];
587
    $self->each_column(
588
        sub { push @$column_info, {table => $_[1], column => $_[2], info => $_[3] } },
589
        exclude_table => $exclude_table
590
    );
591
    
592
    return [
593
      sort {$a->{table} cmp $b->{table} || $a->{column} cmp $b->{column} }
cleanup
Yuki Kimoto authored on 2011-08-16
594
        @$column_info];
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
595
}
596

            
cleanup
yuki-kimoto authored on 2010-10-17
597
sub insert {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
598
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
599
    
cleanup
yuki-kimoto authored on 2010-10-17
600
    # Arguments
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
601
    my $param;
602
    $param = shift if @_ % 2;
603
    my %args = @_;
cleanup
Yuki Kimoto authored on 2011-03-21
604
    my $table  = delete $args{table};
cleanup
Yuki Kimoto authored on 2011-04-25
605
    croak qq{"table" option must be specified } . _subname
simplified arguments check
Yuki Kimoto authored on 2011-07-11
606
      unless defined $table;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
607
    my $p = delete $args{param} || {};
608
    $param  ||= $p;
cleanup
Yuki Kimoto authored on 2011-03-21
609
    my $append = delete $args{append} || '';
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
610
    my $id = delete $args{id};
611
    my $primary_key = delete $args{primary_key};
cleanup
Yuki Kimoto authored on 2011-06-08
612
    croak "insert method primary_key option " .
added tests
Yuki Kimoto authored on 2011-06-08
613
          "must be specified when id is specified " . _subname
614
      if defined $id && !defined $primary_key;
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
615
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
616
    my $prefix = delete $args{prefix};
updated pod
Yuki Kimoto authored on 2011-09-02
617
    my $wrap = delete $args{wrap};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
618
    my $timestamp = $args{timestamp};
619
    
620
    # Timestamp
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
621
    if ($timestamp && (my $insert_timestamp = $self->insert_timestamp)) {
622
        my $columns = $insert_timestamp->[0];
623
        $columns = [$columns] unless ref $columns eq 'ARRAY';
624
        my $value = $insert_timestamp->[1];
625
        $value = $value->() if ref $value eq 'CODE';
626
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
627
    }
cleanup
Yuki Kimoto authored on 2011-04-02
628

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
629
    # Merge parameter
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
630
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
631
        my $id_param = $self->_create_param_from_id($id, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
632
        $param = $self->merge_param($id_param, $param);
633
    }
634

            
cleanup
Yuki Kimoto authored on 2011-04-02
635
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-01-27
636
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
637
    push @sql, "insert";
638
    push @sql, $prefix if defined $prefix;
updated pod
Yuki Kimoto authored on 2011-09-02
639
    push @sql, "into " . $self->_q($table) . " "
640
      . $self->insert_param($param, {wrap => $wrap});
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
641
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
642
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
643
    
644
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
645
    return $self->execute($sql, $param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
646
}
647

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
648
sub insert_param {
updated pod
Yuki Kimoto authored on 2011-09-02
649
    my ($self, $param, $opts) = @_;
650
    
651
    my $wrap = $opts->{wrap} || {};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
652
    
cleanup
Yuki Kimoto authored on 2011-04-02
653
    # Create insert parameter tag
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
654
    my $safety = $self->safety_character;
cleanup
Yuki Kimoto authored on 2011-04-02
655
    my @columns;
656
    my @placeholders;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
657
    foreach my $column (sort keys %$param) {
cleanup
Yuki Kimoto authored on 2011-04-25
658
        croak qq{"$column" is not safety column name } . _subname
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
659
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
660
        my $column_quote = $self->_q($column);
661
        $column_quote =~ s/\./$self->_q(".")/e;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
662
        push @columns, $column_quote;
updated pod
Yuki Kimoto authored on 2011-09-02
663
        
664
        my $func = $wrap->{$column} || sub { $_[0] };
665
        push @placeholders,
666
          ref $param->{$column} eq 'SCALAR' ? ${$param->{$column}}
667
        : $func->(":$column");
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
668
    }
669
    
cleanup
Yuki Kimoto authored on 2011-04-02
670
    return '(' . join(', ', @columns) . ') ' . 'values ' .
671
           '(' . join(', ', @placeholders) . ')'
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
672
}
673

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
674
sub insert_timestamp {
675
    my $self = shift;
676
    
677
    if (@_) {
678
        $self->{insert_timestamp} = [@_];
679
        
680
        return $self;
681
    }
682
    return $self->{insert_timestamp};
683
}
684

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
685
sub include_model {
686
    my ($self, $name_space, $model_infos) = @_;
687
    
cleanup
Yuki Kimoto authored on 2011-04-02
688
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
689
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
690
    
691
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
692
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
693

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
694
        # Load name space module
cleanup
Yuki Kimoto authored on 2011-04-25
695
        croak qq{"$name_space" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
696
          if $name_space =~ /[^\w:]/;
697
        eval "use $name_space";
cleanup
Yuki Kimoto authored on 2011-04-25
698
        croak qq{Name space module "$name_space.pm" is needed. $@ }
699
            . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
700
          if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
701
        
702
        # Search model modules
703
        my $path = $INC{"$name_space.pm"};
704
        $path =~ s/\.pm$//;
705
        opendir my $dh, $path
cleanup
Yuki Kimoto authored on 2011-04-25
706
          or croak qq{Can't open directory "$path": $! } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
707
        $model_infos = [];
708
        while (my $module = readdir $dh) {
709
            push @$model_infos, $module
710
              if $module =~ s/\.pm$//;
711
        }
712
        close $dh;
713
    }
714
    
cleanup
Yuki Kimoto authored on 2011-04-02
715
    # Include models
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
716
    foreach my $model_info (@$model_infos) {
717
        
cleanup
Yuki Kimoto authored on 2011-04-02
718
        # Load model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
719
        my $model_class;
720
        my $model_name;
721
        my $model_table;
722
        if (ref $model_info eq 'HASH') {
723
            $model_class = $model_info->{class};
724
            $model_name  = $model_info->{name};
725
            $model_table = $model_info->{table};
726
            
727
            $model_name  ||= $model_class;
728
            $model_table ||= $model_name;
729
        }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
730
        else { $model_class = $model_name = $model_table = $model_info }
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
731
        my $mclass = "${name_space}::$model_class";
cleanup
Yuki Kimoto authored on 2011-04-25
732
        croak qq{"$mclass" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
733
          if $mclass =~ /[^\w:]/;
734
        unless ($mclass->can('isa')) {
735
            eval "use $mclass";
cleanup
Yuki Kimoto authored on 2011-04-25
736
            croak "$@ " . _subname if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
737
        }
738
        
cleanup
Yuki Kimoto authored on 2011-04-02
739
        # Create model
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
740
        my $args = {};
741
        $args->{model_class} = $mclass if $mclass;
742
        $args->{name}        = $model_name if $model_name;
743
        $args->{table}       = $model_table if $model_table;
744
        $self->create_model($args);
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
745
    }
746
    
747
    return $self;
748
}
749

            
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
750
sub mapper {
751
    my $self = shift;
752
    return DBIx::Custom::Mapper->new(@_);
753
}
754

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
755
sub merge_param {
756
    my ($self, @params) = @_;
757
    
cleanup
Yuki Kimoto authored on 2011-04-02
758
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
759
    my $merge = {};
760
    foreach my $param (@params) {
761
        foreach my $column (keys %$param) {
762
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
763
            
764
            if (exists $merge->{$column}) {
765
                $merge->{$column} = [$merge->{$column}]
766
                  unless ref $merge->{$column} eq 'ARRAY';
767
                push @{$merge->{$column}},
768
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
769
            }
770
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
771
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
772
            }
773
        }
774
    }
775
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
776
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
777
}
778

            
cleanup
Yuki Kimoto authored on 2011-03-21
779
sub method {
780
    my $self = shift;
781
    
cleanup
Yuki Kimoto authored on 2011-04-02
782
    # Register method
cleanup
Yuki Kimoto authored on 2011-03-21
783
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
784
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
785
    
786
    return $self;
787
}
788

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
789
sub model {
790
    my ($self, $name, $model) = @_;
791
    
cleanup
Yuki Kimoto authored on 2011-04-02
792
    # Set model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
793
    if ($model) {
794
        $self->models->{$name} = $model;
795
        return $self;
796
    }
797
    
798
    # Check model existance
cleanup
Yuki Kimoto authored on 2011-04-25
799
    croak qq{Model "$name" is not included } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
800
      unless $self->models->{$name};
801
    
cleanup
Yuki Kimoto authored on 2011-04-02
802
    # Get model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
803
    return $self->models->{$name};
804
}
805

            
cleanup
Yuki Kimoto authored on 2011-03-21
806
sub mycolumn {
807
    my ($self, $table, $columns) = @_;
808
    
cleanup
Yuki Kimoto authored on 2011-04-02
809
    # Create column clause
810
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
811
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
812
    push @column, $self->_q($table) . "." . $self->_q($_) .
813
      " as " . $self->_q($_)
814
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
815
    
816
    return join (', ', @column);
817
}
818

            
added dbi_options attribute
kimoto authored on 2010-12-20
819
sub new {
820
    my $self = shift->SUPER::new(@_);
821
    
cleanup
Yuki Kimoto authored on 2011-04-02
822
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
823
    my @attrs = keys %$self;
824
    foreach my $attr (@attrs) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
825
        croak qq{Invalid attribute: "$attr" } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
826
          unless $self->can($attr);
827
    }
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
828

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
829
    # DEPRECATED
cleanup
Yuki Kimoto authored on 2011-08-13
830
    $self->{_tags} = {
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
831
        '?'     => \&DBIx::Custom::Tag::placeholder,
832
        '='     => \&DBIx::Custom::Tag::equal,
833
        '<>'    => \&DBIx::Custom::Tag::not_equal,
834
        '>'     => \&DBIx::Custom::Tag::greater_than,
835
        '<'     => \&DBIx::Custom::Tag::lower_than,
836
        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
837
        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
838
        'like'  => \&DBIx::Custom::Tag::like,
839
        'in'    => \&DBIx::Custom::Tag::in,
840
        'insert_param' => \&DBIx::Custom::Tag::insert_param,
841
        'update_param' => \&DBIx::Custom::Tag::update_param
cleanup
Yuki Kimoto authored on 2011-08-13
842
    };
843
    
844
    return $self;
845
}
846

            
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
847
sub not_exists { DBIx::Custom::NotExists->singleton }
cleanup
Yuki Kimoto authored on 2011-08-13
848

            
849
sub order {
850
    my $self = shift;
851
    return DBIx::Custom::Order->new(dbi => $self, @_);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
852
}
853

            
cleanup
yuki-kimoto authored on 2010-10-17
854
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
855
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
856
    
857
    # Register filter
858
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
859
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
860
    
cleanup
Yuki Kimoto authored on 2011-04-02
861
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
862
}
packaging one directory
yuki-kimoto authored on 2009-11-16
863

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

            
refactoring select
yuki-kimoto authored on 2010-04-28
867
    # Arguments
cleanup
Yuki Kimoto authored on 2011-03-21
868
    my $table = delete $args{table};
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
869
    my $tables = ref $table eq 'ARRAY' ? $table
870
               : defined $table ? [$table]
871
               : [];
cleanup
Yuki Kimoto authored on 2011-03-21
872
    my $columns   = delete $args{column};
873
    my $where     = delete $args{where} || {};
874
    my $append    = delete $args{append};
875
    my $join      = delete $args{join} || [];
cleanup
Yuki Kimoto authored on 2011-04-25
876
    croak qq{"join" must be array reference } . _subname
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
877
      unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-03-21
878
    my $relation = delete $args{relation};
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
879
    warn "select() relation option is DEPRECATED!"
added warnings
Yuki Kimoto authored on 2011-06-07
880
      if $relation;
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
881
    my $param = delete $args{param} || {}; # DEPRECATED!
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
882
    warn "select() param option is DEPRECATED!"
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
883
      if keys %$param;
884
    my $where_param = delete $args{where_param} || $param || {};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
885
    my $id = delete $args{id};
886
    my $primary_key = delete $args{primary_key};
887
    croak "update method primary_key option " .
888
          "must be specified when id is specified " . _subname
889
      if defined $id && !defined $primary_key;
890
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
891
    my $prefix = delete $args{prefix};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
892
    
cleanup
Yuki Kimoto authored on 2011-03-09
893
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-03-21
894
    $self->_add_relation_table($tables, $relation);
packaging one directory
yuki-kimoto authored on 2009-11-16
895
    
cleanup
Yuki Kimoto authored on 2011-04-02
896
    # Select statement
cleanup
Yuki Kimoto authored on 2011-01-27
897
    my @sql;
898
    push @sql, 'select';
packaging one directory
yuki-kimoto authored on 2009-11-16
899
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
900
    # Prefix
901
    push @sql, $prefix if defined $prefix;
902
    
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
903
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-30
904
    if ($columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-07
905
        $columns = [$columns] unless ref $columns eq 'ARRAY';
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
906
        foreach my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
907
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
908
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
909
            }
910
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
911
                if (@$column == 3 && $column->[1] eq 'as') {
912
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
913
                    splice @$column, 1, 1;
914
                }
915
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
916
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
917
            }
cleanup
Yuki Kimoto authored on 2011-04-02
918
            unshift @$tables, @{$self->_search_tables($column)};
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
919
            push @sql, ($column, ',');
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
920
        }
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
921
        pop @sql if $sql[-1] eq ',';
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
922
    }
923
    else { push @sql, '*' }
924
    
925
    # Table
cleanup
Yuki Kimoto authored on 2011-03-30
926
    push @sql, 'from';
927
    if ($relation) {
928
        my $found = {};
929
        foreach my $table (@$tables) {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
930
            push @sql, ($self->_q($table), ',') unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
931
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
932
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
933
    }
cleanup
Yuki Kimoto authored on 2011-03-30
934
    else {
935
        my $main_table = $tables->[-1] || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
936
        push @sql, $self->_q($main_table);
cleanup
Yuki Kimoto authored on 2011-03-30
937
    }
938
    pop @sql if ($sql[-1] || '') eq ',';
cleanup
Yuki Kimoto authored on 2011-04-25
939
    croak "Not found table name " . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
940
      unless $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
941

            
cleanup
Yuki Kimoto authored on 2011-04-02
942
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
943
    unshift @$tables,
944
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
945
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
946
    # Where
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
947
    my $where_clause = '';
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
948
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
updated pod
Yuki Kimoto authored on 2011-06-21
949
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
950
        $where_clause = "where " . $where->[0];
951
        $where_param = $where->[1];
952
    }
953
    elsif (ref $where) {
cleanup
Yuki Kimoto authored on 2011-04-25
954
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
955
        $where_param = keys %$where_param
956
                     ? $self->merge_param($where_param, $where->param)
957
                     : $where->param;
cleanup
Yuki Kimoto authored on 2011-04-25
958
        
959
        # String where
960
        $where_clause = $where->to_string;
961
    }
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
962
    elsif ($where) { $where_clause = "where $where" }
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
963
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
964
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-04-02
965
    unshift @$tables, @{$self->_search_tables($where_clause)};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
966
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
967
    # Push join
968
    $self->_push_join(\@sql, $join, $tables);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
969
    
cleanup
Yuki Kimoto authored on 2011-03-09
970
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-04-02
971
    push @sql, $where_clause;
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
972
    
cleanup
Yuki Kimoto authored on 2011-03-08
973
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-04-02
974
    $self->_push_relation(\@sql, $tables, $relation, $where_clause eq '' ? 1 : 0);
cleanup
Yuki Kimoto authored on 2011-03-08
975
    
cleanup
Yuki Kimoto authored on 2011-04-02
976
    # Append
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
977
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
978
    
979
    # SQL
980
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
981
    
982
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
983
    my $result = $self->execute($sql, $where_param, table => $tables, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
984
    
985
    return $result;
986
}
987

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
988
sub setup_model {
989
    my $self = shift;
990
    
cleanup
Yuki Kimoto authored on 2011-04-02
991
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
992
    $self->each_column(
993
        sub {
994
            my ($self, $table, $column, $column_info) = @_;
995
            if (my $model = $self->models->{$table}) {
996
                push @{$model->columns}, $column;
997
            }
998
        }
999
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
1000
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
1001
}
1002

            
update pod
Yuki Kimoto authored on 2011-08-10
1003
sub show_datatype {
1004
    my ($self, $table) = @_;
1005
    croak "Table name must be specified" unless defined $table;
1006
    print "$table\n";
1007
    
1008
    my $result = $self->select(table => $table, where => "'0' <> '0'");
1009
    my $sth = $result->sth;
1010

            
1011
    my $columns = $sth->{NAME};
1012
    my $data_types = $sth->{TYPE};
1013
    
1014
    for (my $i = 0; $i < @$columns; $i++) {
1015
        my $column = $columns->[$i];
1016
        my $data_type = $data_types->[$i];
1017
        print "$column: $data_type\n";
1018
    }
1019
}
1020

            
1021
sub show_typename {
1022
    my ($self, $t) = @_;
1023
    croak "Table name must be specified" unless defined $t;
1024
    print "$t\n";
1025
    
1026
    $self->each_column(sub {
1027
        my ($self, $table, $column, $infos) = @_;
1028
        return unless $table eq $t;
1029
        my $typename = $infos->{TYPE_NAME};
1030
        print "$column: $typename\n";
1031
    });
1032
    
1033
    return $self;
1034
}
1035

            
test cleanup
Yuki Kimoto authored on 2011-08-15
1036
sub show_tables {
1037
    my $self = shift;
1038
    
1039
    my %tables;
1040
    $self->each_table(sub { $tables{$_[1]}++ });
1041
    print join("\n", sort keys %tables) . "\n";
1042
    return $self;
1043
}
1044

            
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1045
sub type_rule {
1046
    my $self = shift;
1047
    
1048
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
1049
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1050
        
1051
        # Into
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1052
        foreach my $i (1 .. 2) {
1053
            my $into = "into$i";
cleanup
Yuki Kimoto authored on 2011-08-16
1054
            my $exists_into = exists $type_rule->{$into};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1055
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1056
            $self->{type_rule} = $type_rule;
1057
            $self->{"_$into"} = {};
1058
            foreach my $type_name (keys %{$type_rule->{$into} || {}}) {
1059
                croak qq{type name of $into section must be lower case}
1060
                  if $type_name =~ /[A-Z]/;
1061
            }
cleanup
Yuki Kimoto authored on 2011-08-16
1062
            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1063
            $self->each_column(sub {
1064
                my ($dbi, $table, $column, $column_info) = @_;
1065
                
1066
                my $type_name = lc $column_info->{TYPE_NAME};
1067
                if ($type_rule->{$into} &&
1068
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1069
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1070
                    return unless exists $type_rule->{$into}->{$type_name};
1071
                    if  (defined $filter && ref $filter ne 'CODE') 
1072
                    {
1073
                        my $fname = $filter;
1074
                        croak qq{Filter "$fname" is not registered" } . _subname
1075
                          unless exists $self->filters->{$fname};
1076
                        
1077
                        $filter = $self->filters->{$fname};
1078
                    }
1079

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1080
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1081
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1082
                }
1083
            });
1084
        }
1085

            
1086
        # From
1087
        foreach my $i (1 .. 2) {
1088
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
1089
            foreach my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
1090
                croak qq{data type of from$i section must be lower case or number}
1091
                  if $data_type =~ /[A-Z]/;
1092
                my $fname = $type_rule->{"from$i"}{$data_type};
1093
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1094
                    croak qq{Filter "$fname" is not registered" } . _subname
1095
                      unless exists $self->filters->{$fname};
1096
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1097
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1098
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1099
            }
1100
        }
1101
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1102
        return $self;
1103
    }
1104
    
1105
    return $self->{type_rule} || {};
1106
}
1107

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1111
    # Arguments
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1112
    my $param;
1113
    $param = shift if @_ % 2;
1114
    my %args = @_;
cleanup
Yuki Kimoto authored on 2011-03-21
1115
    my $table = delete $args{table} || '';
cleanup
Yuki Kimoto authored on 2011-04-25
1116
    croak qq{"table" option must be specified } . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
1117
      unless $table;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1118
    my $p = delete $args{param} || {};
1119
    $param  ||= $p;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1120
    my $where = delete $args{where} || {};
1121
    my $where_param = delete $args{where_param} || {};
1122
    my $append = delete $args{append} || '';
cleanup
Yuki Kimoto authored on 2011-03-21
1123
    my $allow_update_all = delete $args{allow_update_all};
cleanup
Yuki Kimoto authored on 2011-06-08
1124
    my $id = delete $args{id};
1125
    my $primary_key = delete $args{primary_key};
1126
    croak "update method primary_key option " .
1127
          "must be specified when id is specified " . _subname
1128
      if defined $id && !defined $primary_key;
1129
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1130
    my $prefix = delete $args{prefix};
updated pod
Yuki Kimoto authored on 2011-09-02
1131
    my $wrap = delete $args{wrap};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1132
    my $timestamp = $args{timestamp};
1133
    
1134
    # Timestamp
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1135
    if ($timestamp && (my $update_timestamp = $self->update_timestamp)) {
1136
        my $columns = $update_timestamp->[0];
1137
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1138
        my $value = $update_timestamp->[1];
1139
        $value = $value->() if ref $value eq 'CODE';
1140
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1141
    }
1142

            
cleanup
yuki-kimoto authored on 2010-10-17
1143
    # Update clause
updated pod
Yuki Kimoto authored on 2011-09-02
1144
    my $update_clause = $self->update_param($param, {wrap => $wrap});
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1145

            
1146
    # Where
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1147
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1148
    my $where_clause = '';
updated pod
Yuki Kimoto authored on 2011-06-21
1149
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1150
        $where_clause = "where " . $where->[0];
1151
        $where_param = $where->[1];
1152
    }
1153
    elsif (ref $where) {
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1154
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1155
        $where_param = keys %$where_param
1156
                     ? $self->merge_param($where_param, $where->param)
1157
                     : $where->param;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1158
        
1159
        # String where
1160
        $where_clause = $where->to_string;
1161
    }
1162
    elsif ($where) { $where_clause = "where $where" }
cleanup
Yuki Kimoto authored on 2011-04-25
1163
    croak qq{"where" must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
1164
      if "$where_clause" eq '' && !$allow_update_all;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1165
    
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1166
    # Merge param
1167
    $param = $self->merge_param($param, $where_param) if keys %$where_param;
1168
    
cleanup
Yuki Kimoto authored on 2011-04-02
1169
    # Update statement
cleanup
Yuki Kimoto authored on 2011-01-27
1170
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1171
    push @sql, "update";
1172
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1173
    push @sql, $self->_q($table) . " $update_clause $where_clause";
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1174
    push @sql, $append if defined $append;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1175
    
cleanup
Yuki Kimoto authored on 2011-01-27
1176
    # SQL
1177
    my $sql = join(' ', @sql);
1178
    
cleanup
yuki-kimoto authored on 2010-10-17
1179
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
1180
    return $self->execute($sql, $param, table => $table, %args);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1181
}
1182

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1185
sub update_param {
updated pod
Yuki Kimoto authored on 2011-09-02
1186
    my ($self, $param, $opts) = @_;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1187
    
cleanup
Yuki Kimoto authored on 2011-04-02
1188
    # Create update parameter tag
updated pod
Yuki Kimoto authored on 2011-09-02
1189
    my $tag = $self->assign_param($param, $opts);
1190
    $tag = "set $tag" unless $opts->{no_set};
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1191

            
cleanup
Yuki Kimoto authored on 2011-04-02
1192
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1193
}
1194

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1195
sub update_timestamp {
1196
    my $self = shift;
1197
    
1198
    if (@_) {
1199
        $self->{update_timestamp} = [@_];
1200
        
1201
        return $self;
1202
    }
1203
    return $self->{update_timestamp};
1204
}
1205

            
sub module use DBIx::Custom ...
Yuki Kimoto authored on 2011-08-02
1206
sub where { DBIx::Custom::Where->new(dbi => shift, @_) }
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1207

            
updated pod
Yuki Kimoto authored on 2011-06-21
1208
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1209
    
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1210
    my ($self, $source, $after_build_sql) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1211
    
updated pod
Yuki Kimoto authored on 2011-06-21
1212
    # Cache
1213
    my $cache = $self->cache;
1214
    
1215
    # Query
1216
    my $query;
1217
    
1218
    # Get cached query
1219
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1220
        
updated pod
Yuki Kimoto authored on 2011-06-21
1221
        # Get query
1222
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1223
        
updated pod
Yuki Kimoto authored on 2011-06-21
1224
        # Create query
1225
        if ($q) {
1226
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1227
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1228
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1229
    }
1230
    
1231
    # Create query
1232
    unless ($query) {
1233

            
1234
        # Create query
1235
        my $builder = $self->query_builder;
1236
        $query = $builder->build_query($source);
1237

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

            
1244
        # Save query to cache
1245
        $self->cache_method->(
1246
            $self, $source,
1247
            {
1248
                sql     => $query->sql, 
1249
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1250
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1251
            }
1252
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1253
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1254

            
1255
    # Filter SQL
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1256
    if ($after_build_sql) {
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1257
        my $sql = $query->sql;
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1258
        $sql = $after_build_sql->($sql);
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1259
        $query->sql($sql);
1260
    }
1261
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1262
    # Save sql
1263
    $self->last_sql($query->sql);
1264
    
updated pod
Yuki Kimoto authored on 2011-06-21
1265
    # Prepare statement handle
1266
    my $sth;
1267
    eval { $sth = $self->dbh->prepare($query->{sql})};
1268
    
1269
    if ($@) {
1270
        $self->_croak($@, qq{. Following SQL is executed.\n}
1271
                        . qq{$query->{sql}\n} . _subname);
1272
    }
1273
    
1274
    # Set statement handle
1275
    $query->sth($sth);
1276
    
1277
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1278
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1279
    
1280
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1281
}
1282

            
cleanup
Yuki Kimoto authored on 2011-04-02
1283
sub _create_bind_values {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1284
    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1285
    
cleanup
Yuki Kimoto authored on 2011-04-02
1286
    # Create bind values
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1287
    my $bind = [];
removed reconnect method
yuki-kimoto authored on 2010-05-28
1288
    my $count = {};
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1289
    my $not_exists = {};
cleanup
Yuki Kimoto authored on 2011-01-12
1290
    foreach my $column (@$columns) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
1291
        
1292
        # Value
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1293
        my $value;
1294
        if(ref $params->{$column} eq 'ARRAY') {
1295
            my $i = $count->{$column} || 0;
1296
            $i += $not_exists->{$column} || 0;
1297
            my $found;
1298
            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1299
                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
1300
                    $not_exists->{$column}++;
1301
                }
1302
                else  {
1303
                    $value = $params->{$column}->[$k];
1304
                    $found = 1;
1305
                    last
1306
                }
1307
            }
1308
            next unless $found;
1309
        }
1310
        else { $value = $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1311
        
cleanup
Yuki Kimoto authored on 2011-01-12
1312
        # Filter
1313
        my $f = $filter->{$column} || $self->{default_out_filter} || '';
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1314
        $value = $f->($value) if $f;
1315
        
1316
        # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1317
        foreach my $i (1 .. 2) {
1318
            my $type_filter = $type_filters->{$i};
micro optimization
Yuki Kimoto authored on 2011-07-30
1319
            my $tf = $self->{"_into$i"}->{dot}->{$column} || $type_filter->{$column};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1320
            $value = $tf->($value) if $tf;
1321
        }
cleanup
kimoto.yuki@gmail.com authored on 2010-12-21
1322
        
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1323
        # Bind values
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
1324
        push @$bind, {value => $value, bind_type => $bind_type->{$column}};
removed reconnect method
yuki-kimoto authored on 2010-05-28
1325
        
1326
        # Count up 
1327
        $count->{$column}++;
1328
    }
1329
    
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1330
    return $bind;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1331
}
1332

            
cleanup
Yuki Kimoto authored on 2011-06-08
1333
sub _create_param_from_id {
1334
    my ($self, $id, $primary_keys) = @_;
improved error messages
Yuki Kimoto authored on 2011-04-18
1335
    
cleanup
Yuki Kimoto authored on 2011-06-08
1336
    # Create parameter
1337
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1338
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1339
        $id = [$id] unless ref $id;
1340
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1341
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1342
          unless !ref $id || ref $id eq 'ARRAY';
1343
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1344
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1345
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1346
        for(my $i = 0; $i < @$primary_keys; $i ++) {
cleanup
Yuki Kimoto authored on 2011-06-08
1347
           $param->{$primary_keys->[$i]} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1348
        }
1349
    }
1350
    
cleanup
Yuki Kimoto authored on 2011-06-08
1351
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1352
}
1353

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1354
sub _connect {
1355
    my $self = shift;
1356
    
1357
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1358
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1359
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1360
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1361
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1362
    croak qq{"dsn" must be specified } . _subname
1363
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1364
    my $user        = $self->user;
1365
    my $password    = $self->password;
1366
    my $dbi_option = {%{$self->dbi_options}, %{$self->dbi_option}};
added warnings
Yuki Kimoto authored on 2011-06-07
1367
    warn "dbi_options is DEPRECATED! use dbi_option instead\n"
1368
      if keys %{$self->dbi_options};
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1369
    
cleanup
Yuki Kimoto authored on 2011-08-16
1370
    $dbi_option = {%{$self->default_dbi_option}, %$dbi_option};
1371
    
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1372
    # Connect
cleanup
Yuki Kimoto authored on 2011-08-16
1373
    my $dbh;
1374
    eval {
1375
        $dbh = DBI->connect(
1376
            $dsn,
1377
            $user,
1378
            $password,
1379
            $dbi_option
1380
        );
1381
    };
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1382
    
1383
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1384
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1385
    
1386
    return $dbh;
1387
}
1388

            
cleanup
yuki-kimoto authored on 2010-10-17
1389
sub _croak {
1390
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1391
    
1392
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1393
    $append ||= "";
1394
    
1395
    # Verbose
1396
    if ($Carp::Verbose) { croak $error }
1397
    
1398
    # Not verbose
1399
    else {
1400
        
1401
        # Remove line and module infromation
1402
        my $at_pos = rindex($error, ' at ');
1403
        $error = substr($error, 0, $at_pos);
1404
        $error =~ s/\s+$//;
1405
        croak "$error$append";
1406
    }
1407
}
1408

            
prepare oracle test
Yuki Kimoto authored on 2011-08-15
1409
sub _driver { lc shift->{dbh}->{Driver}->{Name} }
1410

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1411
sub _need_tables {
1412
    my ($self, $tree, $need_tables, $tables) = @_;
1413
    
cleanup
Yuki Kimoto authored on 2011-04-02
1414
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1415
    foreach my $table (@$tables) {
1416
        if ($tree->{$table}) {
1417
            $need_tables->{$table} = 1;
1418
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1419
        }
1420
    }
1421
}
1422

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1423
sub _push_join {
1424
    my ($self, $sql, $join, $join_tables) = @_;
1425
    
cleanup
Yuki Kimoto authored on 2011-04-02
1426
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1427
    return unless @$join;
1428
    
cleanup
Yuki Kimoto authored on 2011-04-02
1429
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1430
    my $tree = {};
1431
    for (my $i = 0; $i < @$join; $i++) {
1432
        
cleanup
Yuki Kimoto authored on 2011-07-28
1433
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1434
        my $join_clause;;
1435
        my $option;
1436
        if (ref $join->[$i] eq 'HASH') {
1437
            $join_clause = $join->[$i]->{clause};
1438
            $option = {table => $join->[$i]->{table}};
1439
        }
1440
        else {
1441
            $join_clause = $join->[$i];
1442
            $option = {};
1443
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1444

            
1445
        # Find tables in join clause
added join new syntax
Yuki Kimoto authored on 2011-07-28
1446
        my $table1;
1447
        my $table2;
1448
        if (my $table = $option->{table}) {
1449
            $table1 = $table->[0];
1450
            $table2 = $table->[1];
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1451
        }
cleanup
Yuki Kimoto authored on 2011-07-28
1452
        else {
1453
            my $q = $self->_quote;
1454
            my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1455
            $j_clause =~ s/'.+?'//g;
1456
            my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1457
            $j_clause =~ s/[$q_re]//g;
cleanup
Yuki Kimoto authored on 2011-07-28
1458
            my $c = $self->safety_character;
1459
            my $join_re = qr/(?:^|\s)($c+)\.$c+\s+=\s+($c+)\.$c+/;
1460
            if ($j_clause =~ $join_re) {
1461
                $table1 = $1;
1462
                $table2 = $2;
1463
            }
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1464
        }
added join new syntax
Yuki Kimoto authored on 2011-07-28
1465
        croak qq{join clause must have two table name after "on" keyword. } .
1466
              qq{"$join_clause" is passed }  . _subname
1467
          unless defined $table1 && defined $table2;
1468
        croak qq{right side table of "$join_clause" must be unique }
1469
            . _subname
1470
          if exists $tree->{$table2};
1471
        croak qq{Same table "$table1" is specified} . _subname
1472
          if $table1 eq $table2;
1473
        $tree->{$table2}
1474
          = {position => $i, parent => $table1, join => $join_clause};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1475
    }
1476
    
cleanup
Yuki Kimoto authored on 2011-04-02
1477
    # Search need tables
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1478
    my $need_tables = {};
1479
    $self->_need_tables($tree, $need_tables, $join_tables);
1480
    my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} } keys %$need_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1481
    
1482
    # Add join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1483
    foreach my $need_table (@need_tables) {
1484
        push @$sql, $tree->{$need_table}{join};
1485
    }
1486
}
cleanup
Yuki Kimoto authored on 2011-03-08
1487

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1488
sub _quote {
1489
    my $self = shift;
1490
    
1491
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1492
         : defined $self->quote ? $self->quote
1493
         : '';
1494
}
1495

            
cleanup
Yuki Kimoto authored on 2011-07-29
1496
sub _q {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1497
    my ($self, $value, $quotemeta) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1498
    
1499
    my $quote = $self->_quote;
1500
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1501
    my $p;
1502
    if (defined $quote && length $quote > 1) {
1503
        $p = substr($quote, 1, 1);
1504
    }
1505
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1506
    
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1507
    if ($quotemeta) {
1508
        $q = quotemeta($q);
1509
        $p = quotemeta($p);
1510
    }
1511
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1512
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1513
}
1514

            
cleanup
Yuki Kimoto authored on 2011-04-02
1515
sub _remove_duplicate_table {
1516
    my ($self, $tables, $main_table) = @_;
1517
    
1518
    # Remove duplicate table
1519
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1520
    delete $tables{$main_table} if $main_table;
1521
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1522
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1523
    if (my $q = $self->_quote) {
1524
        $q = quotemeta($q);
1525
        $_ =~ s/[$q]//g for @$new_tables;
1526
    }
1527

            
1528
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1529
}
1530

            
cleanup
Yuki Kimoto authored on 2011-04-02
1531
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1532
    my ($self, $source) = @_;
1533
    
cleanup
Yuki Kimoto authored on 2011-04-02
1534
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1535
    my $tables = [];
1536
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1537
    my $q = $self->_quote;
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1538
    my $quoted_safety_character_re = $self->_q("?([$safety_character]+)", 1);
1539
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1540
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1541
    while ($source =~ /$table_re/g) {
1542
        push @$tables, $1;
1543
    }
1544
    
1545
    return $tables;
1546
}
1547

            
cleanup
Yuki Kimoto authored on 2011-04-02
1548
sub _where_to_obj {
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1549
    my ($self, $where) = @_;
1550
    
cleanup
Yuki Kimoto authored on 2011-04-02
1551
    my $obj;
1552
    
1553
    # Hash
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1554
    if (ref $where eq 'HASH') {
1555
        my $clause = ['and'];
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1556
        my $q = $self->_quote;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1557
        foreach my $column (keys %$where) {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1558
            my $table;
1559
            my $c;
1560
            if ($column =~ /(?:(.*?)\.)?(.*)/) {
1561
                $table = $1;
1562
                $c = $2;
1563
            }
1564
            
1565
            my $table_quote;
1566
            $table_quote = $self->_q($table) if defined $table;
1567
            my $column_quote = $self->_q($c);
1568
            $column_quote = $table_quote . '.' . $column_quote
1569
              if defined $table_quote;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1570
            push @$clause, "$column_quote = :$column" for keys %$where;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1571
        }
cleanup
Yuki Kimoto authored on 2011-04-02
1572
        $obj = $self->where(clause => $clause, param => $where);
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1573
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1574
    
1575
    # DBIx::Custom::Where object
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1576
    elsif (ref $where eq 'DBIx::Custom::Where') {
cleanup
Yuki Kimoto authored on 2011-04-02
1577
        $obj = $where;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1578
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1579
    
updated pod
Yuki Kimoto authored on 2011-06-21
1580
    # Array
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1581
    elsif (ref $where eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-04-02
1582
        $obj = $self->where(
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1583
            clause => $where->[0],
1584
            param  => $where->[1]
1585
        );
1586
    }
1587
    
cleanup
Yuki Kimoto authored on 2011-04-02
1588
    # Check where argument
improved error messages
Yuki Kimoto authored on 2011-04-18
1589
    croak qq{"where" must be hash reference or DBIx::Custom::Where object}
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
1590
        . qq{or array reference, which contains where clause and parameter}
cleanup
Yuki Kimoto authored on 2011-04-25
1591
        . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
1592
      unless ref $obj eq 'DBIx::Custom::Where';
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1593
    
cleanup
Yuki Kimoto authored on 2011-04-02
1594
    return $obj;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1595
}
1596

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

            
1600
    # Initialize filters
1601
    $self->{filter} ||= {};
micro optimization
Yuki Kimoto authored on 2011-07-30
1602
    $self->{filter}{on} = 1;
updated pod
Yuki Kimoto authored on 2011-06-21
1603
    $self->{filter}{out} ||= {};
1604
    $self->{filter}{in} ||= {};
1605
    $self->{filter}{end} ||= {};
1606
    
1607
    # Usage
1608
    my $usage = "Usage: \$dbi->apply_filter(" .
1609
                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1610
                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1611
    
1612
    # Apply filter
1613
    for (my $i = 0; $i < @cinfos; $i += 2) {
1614
        
1615
        # Column
1616
        my $column = $cinfos[$i];
1617
        if (ref $column eq 'ARRAY') {
1618
            foreach my $c (@$column) {
1619
                push @cinfos, $c, $cinfos[$i + 1];
1620
            }
1621
            next;
1622
        }
1623
        
1624
        # Filter infomation
1625
        my $finfo = $cinfos[$i + 1] || {};
1626
        croak "$usage (table: $table) " . _subname
1627
          unless  ref $finfo eq 'HASH';
1628
        foreach my $ftype (keys %$finfo) {
1629
            croak "$usage (table: $table) " . _subname
1630
              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1631
        }
1632
        
1633
        # Set filters
1634
        foreach my $way (qw/in out end/) {
1635
        
1636
            # Filter
1637
            my $filter = $finfo->{$way};
1638
            
1639
            # Filter state
1640
            my $state = !exists $finfo->{$way} ? 'not_exists'
1641
                      : !defined $filter        ? 'not_defined'
1642
                      : ref $filter eq 'CODE'   ? 'code'
1643
                      : 'name';
1644
            
1645
            # Filter is not exists
1646
            next if $state eq 'not_exists';
1647
            
1648
            # Check filter name
1649
            croak qq{Filter "$filter" is not registered } . _subname
1650
              if  $state eq 'name'
1651
               && ! exists $self->filters->{$filter};
1652
            
1653
            # Set filter
1654
            my $f = $state eq 'not_defined' ? undef
1655
                  : $state eq 'code'        ? $filter
1656
                  : $self->filters->{$filter};
1657
            $self->{filter}{$way}{$table}{$column} = $f;
1658
            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1659
            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1660
            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1661
        }
1662
    }
1663
    
1664
    return $self;
1665
}
1666

            
1667
# DEPRECATED!
1668
sub create_query {
1669
    warn "create_query is DEPRECATED! use query option of each method";
1670
    shift->_create_query(@_);
1671
}
1672

            
cleanup
Yuki Kimoto authored on 2011-06-13
1673
# DEPRECATED!
1674
sub apply_filter {
1675
    my $self = shift;
1676
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1677
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1678
    return $self->_apply_filter(@_);
1679
}
1680

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

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

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1688
    # Arguments
1689
    my $primary_keys = delete $args{primary_key};
1690
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1691
    my $where = delete $args{where};
1692
    my $param = delete $args{param};
1693
    
1694
    # Check arguments
1695
    foreach my $name (keys %args) {
1696
        croak qq{"$name" is wrong option } . _subname
1697
          unless $SELECT_AT_ARGS{$name};
1698
    }
1699
    
1700
    # Table
1701
    croak qq{"table" option must be specified } . _subname
1702
      unless $args{table};
1703
    my $table = ref $args{table} ? $args{table}->[-1] : $args{table};
1704
    
1705
    # Create where parameter
1706
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1707
    
1708
    return $self->select(where => $where_param, %args);
1709
}
1710

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

            
1716
    warn "delete_at is DEPRECATED! use update and id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1717
    
1718
    # Arguments
1719
    my $primary_keys = delete $args{primary_key};
1720
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1721
    my $where = delete $args{where};
1722
    
1723
    # Check arguments
1724
    foreach my $name (keys %args) {
1725
        croak qq{"$name" is wrong option } . _subname
1726
          unless $DELETE_AT_ARGS{$name};
1727
    }
1728
    
1729
    # Create where parameter
1730
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1731
    
1732
    return $self->delete(where => $where_param, %args);
1733
}
1734

            
cleanup
Yuki Kimoto authored on 2011-06-08
1735
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1736
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1737
sub update_at {
1738
    my $self = shift;
1739

            
1740
    warn "update_at is DEPRECATED! use update and id option instead";
1741
    
1742
    # Arguments
1743
    my $param;
1744
    $param = shift if @_ % 2;
1745
    my %args = @_;
1746
    my $primary_keys = delete $args{primary_key};
1747
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1748
    my $where = delete $args{where};
1749
    my $p = delete $args{param} || {};
1750
    $param  ||= $p;
1751
    
1752
    # Check arguments
1753
    foreach my $name (keys %args) {
1754
        croak qq{"$name" is wrong option } . _subname
1755
          unless $UPDATE_AT_ARGS{$name};
1756
    }
1757
    
1758
    # Create where parameter
1759
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1760
    
1761
    return $self->update(where => $where_param, param => $param, %args);
1762
}
1763

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1764
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1765
our %INSERT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1766
sub insert_at {
1767
    my $self = shift;
1768
    
1769
    warn "insert_at is DEPRECATED! use insert and id option instead";
1770
    
1771
    # Arguments
1772
    my $param;
1773
    $param = shift if @_ % 2;
1774
    my %args = @_;
1775
    my $primary_key = delete $args{primary_key};
1776
    $primary_key = [$primary_key] unless ref $primary_key;
1777
    my $where = delete $args{where};
1778
    my $p = delete $args{param} || {};
1779
    $param  ||= $p;
1780
    
1781
    # Check arguments
1782
    foreach my $name (keys %args) {
1783
        croak qq{"$name" is wrong option } . _subname
1784
          unless $INSERT_AT_ARGS{$name};
1785
    }
1786
    
1787
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-06-08
1788
    my $where_param = $self->_create_param_from_id($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1789
    $param = $self->merge_param($where_param, $param);
1790
    
1791
    return $self->insert(param => $param, %args);
1792
}
1793

            
added warnings
Yuki Kimoto authored on 2011-06-07
1794
# DEPRECATED!
1795
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1796
    my $self = shift;
1797
    
added warnings
Yuki Kimoto authored on 2011-06-07
1798
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1799
    
1800
    # Merge tag
1801
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1802
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1803
    
1804
    return $self;
1805
}
1806

            
1807
# DEPRECATED!
1808
sub register_tag_processor {
1809
    my $self = shift;
1810
    warn "register_tag_processor is DEPRECATED!";
1811
    # Merge tag
1812
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1813
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1814
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1815
}
1816

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1817
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
1818
has 'data_source';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1819
has dbi_options => sub { {} };
1820
has filter_check  => 1;
1821
has 'reserved_word_quote';
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1822

            
cleanup
Yuki Kimoto authored on 2011-01-25
1823
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1824
sub default_bind_filter {
1825
    my $self = shift;
1826
    
cleanup
Yuki Kimoto authored on 2011-06-13
1827
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1828
    
cleanup
Yuki Kimoto authored on 2011-01-12
1829
    if (@_) {
1830
        my $fname = $_[0];
1831
        
1832
        if (@_ && !$fname) {
1833
            $self->{default_out_filter} = undef;
1834
        }
1835
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1836
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1837
              unless exists $self->filters->{$fname};
1838
        
1839
            $self->{default_out_filter} = $self->filters->{$fname};
1840
        }
1841
        return $self;
1842
    }
1843
    
1844
    return $self->{default_out_filter};
1845
}
1846

            
cleanup
Yuki Kimoto authored on 2011-01-25
1847
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1848
sub default_fetch_filter {
1849
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1850

            
cleanup
Yuki Kimoto authored on 2011-06-13
1851
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1852
    
1853
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1854
        my $fname = $_[0];
1855

            
cleanup
Yuki Kimoto authored on 2011-01-12
1856
        if (@_ && !$fname) {
1857
            $self->{default_in_filter} = undef;
1858
        }
1859
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1860
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1861
              unless exists $self->filters->{$fname};
1862
        
1863
            $self->{default_in_filter} = $self->filters->{$fname};
1864
        }
1865
        
1866
        return $self;
1867
    }
1868
    
many changed
Yuki Kimoto authored on 2011-01-23
1869
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1870
}
1871

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1872
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1873
sub insert_param_tag {
1874
    warn "insert_param_tag is DEPRECATED! " .
1875
         "use insert_param instead!";
1876
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1877
}
1878

            
1879
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1880
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1881
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1882
         "use update_param instead";
1883
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1884
}
cleanup
Yuki Kimoto authored on 2011-03-08
1885
# DEPRECATED!
1886
sub _push_relation {
1887
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1888
    
1889
    if (keys %{$relation || {}}) {
1890
        push @$sql, $need_where ? 'where' : 'and';
1891
        foreach my $rcolumn (keys %$relation) {
1892
            my $table1 = (split (/\./, $rcolumn))[0];
1893
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1894
            push @$tables, ($table1, $table2);
1895
            push @$sql, ("$rcolumn = " . $relation->{$rcolumn},  'and');
1896
        }
1897
    }
1898
    pop @$sql if $sql->[-1] eq 'and';    
1899
}
1900

            
1901
# DEPRECATED!
1902
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1903
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1904
    
1905
    if (keys %{$relation || {}}) {
1906
        foreach my $rcolumn (keys %$relation) {
1907
            my $table1 = (split (/\./, $rcolumn))[0];
1908
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1909
            my $table1_exists;
1910
            my $table2_exists;
1911
            foreach my $table (@$tables) {
1912
                $table1_exists = 1 if $table eq $table1;
1913
                $table2_exists = 1 if $table eq $table2;
1914
            }
1915
            unshift @$tables, $table1 unless $table1_exists;
1916
            unshift @$tables, $table2 unless $table2_exists;
1917
        }
1918
    }
1919
}
1920

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1923
=head1 NAME
1924

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

            
fix heading typos
Terrence Brannon authored on 2011-08-17
1927
=head1 SYNOPSIS
cleanup
yuki-kimoto authored on 2010-08-05
1928

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1929
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1930
    
1931
    # Connect
1932
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1933
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1934
        user => 'ken',
1935
        password => '!LFKD%$&',
1936
        dbi_option => {mysql_enable_utf8 => 1}
1937
    );
cleanup
yuki-kimoto authored on 2010-08-05
1938

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1939
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1940
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1941
    
1942
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
1943
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
1944
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1945
    
1946
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
1947
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
1948

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1953
    # Select, more complex
1954
    my $result = $dbi->select(
1955
        table  => 'book',
1956
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
1957
            {book => [qw/title author/]},
1958
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1959
        ],
1960
        where  => {'book.author' => 'Ken'},
1961
        join => ['left outer join company on book.company_id = company.id'],
1962
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
1963
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1964
    
removed register_format()
yuki-kimoto authored on 2010-05-26
1965
    # Fetch
1966
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1967
        
removed register_format()
yuki-kimoto authored on 2010-05-26
1968
    }
1969
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1970
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
1971
    while (my $row = $result->fetch_hash) {
1972
        
1973
    }
1974
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1975
    # Execute SQL with parameter.
1976
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1977
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
1978
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1979
    );
1980
    
fix heading typos
Terrence Brannon authored on 2011-08-17
1981
=head1 DESCRIPTION
removed reconnect method
yuki-kimoto authored on 2010-05-28
1982

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1998
Named place holder support
1999

            
2000
=item *
2001

            
cleanup
Yuki Kimoto authored on 2011-07-29
2002
Model support
2003

            
2004
=item *
2005

            
2006
Connection manager support
2007

            
2008
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2009

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

            
2014
=item *
2015

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2016
Filtering by data type or column name
cleanup
Yuki Kimoto authored on 2011-07-29
2017

            
2018
=item *
2019

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2020
Create C<order by> clause flexibly
cleanup
Yuki Kimoto authored on 2011-07-29
2021

            
2022
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2023

            
fix heading typos
Terrence Brannon authored on 2011-08-17
2024
=head1 DOCUMENTATION
pod fix
Yuki Kimoto authored on 2011-01-21
2025

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2031
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2032
L<DBIx::Custom::Result>,
2033
L<DBIx::Custom::Query>,
2034
L<DBIx::Custom::Where>,
2035
L<DBIx::Custom::Model>,
2036
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2037

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

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

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

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

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

            
2051
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2052
        "dbi:mysql:database=$database",
2053
        $user,
2054
        $password,
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2055
        DBIx::Custom->new->default_dbi_option
2056
    );
2057
    
updated pod
Yuki Kimoto authored on 2011-06-21
2058
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2059

            
cleanup
Yuki Kimoto authored on 2011-08-16
2060
If C<connector> is set to 1 when connect method is called,
2061
L<DBIx::Connector> is automatically set to C<connector>
2062

            
2063
    my $dbi = DBIx::Custom->connect(
2064
      dsn => $dsn, user => $user, password => $password, connector => 1);
2065
    
2066
    my $connector = $dbi->connector; # DBIx::Connector
2067

            
2068
Note that L<DBIx::Connector> must be installed.
2069

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

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

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

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

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

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

            
2085
=head2 C<default_dbi_option>
2086

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2093
    {
2094
        RaiseError => 1,
2095
        PrintError => 0,
2096
        AutoCommit => 1,
2097
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2098

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

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

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

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

            
2108
    my $last_sql = $dbi->last_sql;
2109
    $dbi = $dbi->last_sql($last_sql);
2110

            
2111
Get last successed SQL executed by C<execute> method.
2112

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2120
=head2 C<password>
2121

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

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

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

            
test cleanup
Yuki Kimoto authored on 2011-08-10
2129
    my $builder = $dbi->query_builder;
added commit method
yuki-kimoto authored on 2010-05-27
2130

            
test cleanup
Yuki Kimoto authored on 2011-08-10
2131
Creat query builder. This is L<DBIx::Custom::QueryBuilder>.
cleanup
yuki-kimoto authored on 2010-08-05
2132

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2142
You can set quote pair.
2143

            
2144
    $dbi->quote('[]');
2145

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

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

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

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

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

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

            
cleanup test
Yuki Kimoto authored on 2011-08-10
2161
=head2 C<separator>
2162

            
2163
    my $separator = $self->separator;
2164
    $dbi = $self->separator($separator);
2165

            
2166
Separator whichi join table and column.
2167
This is used by C<column> and C<mycolumn> method.
2168

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2169
=head2 C<exclude_table>
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
2170

            
renamed system_table to excl...
Yuki Kimoto authored on 2011-08-10
2171
    my $exclude_table = $self->exclude_table;
2172
    $dbi = $self->exclude_table(qr/pg_/);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
2173

            
2174
Regex matching system table.
2175
this regex match is used by C<each_table> method and C<each_column> method
2176
System table is ignored.
2177
C<type_rule> method and C<setup_model> method call
renamed system_table to excl...
Yuki Kimoto authored on 2011-08-10
2178
C<each_table>, so if you set C<exclude_table> properly,
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
2179
The performance is up.
2180

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

            
2183
    my $tag_parse = $dbi->tag_parse(0);
2184
    $dbi = $dbi->tag_parse;
2185

            
2186
Enable DEPRECATED tag parsing functionality, default to 1.
2187
If you want to disable tag parsing functionality, set to 0.
2188

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

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2196
=head2 C<user_column_info>
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2197

            
2198
    my $user_column_info = $dbi->user_column_info;
2199
    $dbi = $dbi->user_column_info($user_column_info);
2200

            
2201
You can set the following data.
2202

            
2203
    [
2204
        {table => 'book', column => 'title', info => {...}},
2205
        {table => 'author', column => 'name', info => {...}}
2206
    ]
2207

            
2208
Usually, you can set return value of C<get_column_info>.
2209

            
2210
    my $user_column_info
2211
      = $dbi->get_column_info(exclude_table => qr/^system/);
2212
    $dbi->user_column_info($user_column_info);
2213

            
2214
If C<user_column_info> is set, C<each_column> use C<user_column_info>
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2215
to find column info. this is very fast.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2216

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2217
=head2 C<user_table_info>
added test
Yuki Kimoto authored on 2011-08-16
2218

            
2219
    my $user_table_info = $dbi->user_table_info;
2220
    $dbi = $dbi->user_table_info($user_table_info);
2221

            
2222
You can set the following data.
2223

            
2224
    [
2225
        {table => 'book', info => {...}},
2226
        {table => 'author', info => {...}}
2227
    ]
2228

            
2229
Usually, you can set return value of C<get_table_info>.
2230

            
2231
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2232
    $dbi->user_table_info($user_table_info);
2233

            
2234
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2235
to find table info.
2236

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2243
=head2 C<available_datatype>
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2244

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2245
    print $dbi->available_datatype;
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2246

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2250
=head2 C<available_typename>
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2251

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
2252
    print $dbi->available_typename;
added EXPERIMENTAL available...
Yuki Kimoto authored on 2011-06-14
2253

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2257
=head2 C<assign_param>
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2258

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

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

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

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

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

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

            
2271
Create column clause. The follwoing column clause is created.
2272

            
2273
    book.author as "book.author",
2274
    book.title as "book.title"
2275

            
cleanup test
Yuki Kimoto authored on 2011-08-10
2276
You can change separator by C<separator> attribute.
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2277

            
cleanup
Yuki Kimoto authored on 2011-06-13
2278
    # Separator is double underbar
2279
    $dbi->separator('__');
2280
    
2281
    book.author as "book__author",
2282
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2283

            
cleanup
Yuki Kimoto authored on 2011-06-13
2284
    # Separator is hyphen
2285
    $dbi->separator('-');
2286
    
2287
    book.author as "book-author",
2288
    book.title as "book-title"
2289
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2290
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2291

            
update pod
Yuki Kimoto authored on 2011-03-13
2292
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2293
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2294
        user => 'ken',
2295
        password => '!LFKD%$&',
2296
        dbi_option => {mysql_enable_utf8 => 1}
2297
    );
2298

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2305
=head2 C<count>
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
2306

            
2307
    my $count = $model->count(table => 'book');
2308

            
2309
Get rows count.
2310

            
2311
Options is same as C<select> method's ones.
2312

            
2313
=head2 C<create_model>
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2314

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2315
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2316
        table => 'book',
2317
        primary_key => 'id',
2318
        join => [
2319
            'inner join company on book.comparny_id = company.id'
2320
        ],
2321
    );
2322

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

            
2326
   $dbi->model('book')->select(...);
2327

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

            
2330
    my $dbh = $dbi->dbh;
2331

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

            
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2335
=head2 C<delete>
2336

            
2337
    $dbi->delete(table => 'book', where => {title => 'Perl'});
2338

            
2339
Execute delete statement.
2340

            
2341
The following opitons are available.
2342

            
2343
=over 4
2344

            
2345
=item C<append>
2346

            
2347
Same as C<select> method's C<append> option.
2348

            
2349
=item C<filter>
2350

            
2351
Same as C<execute> method's C<filter> option.
2352

            
2353
=item C<id>
2354

            
2355
    id => 4
2356
    id => [4, 5]
2357

            
2358
ID corresponding to C<primary_key>.
2359
You can delete rows by C<id> and C<primary_key>.
2360

            
2361
    $dbi->delete(
2362
        parimary_key => ['id1', 'id2'],
2363
        id => [4, 5],
2364
        table => 'book',
2365
    );
2366

            
2367
The above is same as the followin one.
2368

            
2369
    $dbi->delete(where => {id1 => 4, id2 => 5}, table => 'book');
2370

            
2371
=item C<prefix>
2372

            
2373
    prefix => 'some'
2374

            
2375
prefix before table name section.
2376

            
2377
    delete some from book
2378

            
2379
=item C<query>
2380

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2383
=item C<after_build_sql>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2384

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2385
Same as C<execute> method's C<after_build_sql> option.
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2386

            
2387
=item C<table>
2388

            
2389
    table => 'book'
2390

            
2391
Table name.
2392

            
2393
=item C<where>
2394

            
2395
Same as C<select> method's C<where> option.
2396

            
2397
=item C<primary_key>
2398

            
2399
See C<id> option.
2400

            
2401
=item C<bind_type>
2402

            
2403
Same as C<execute> method's C<bind_type> option.
2404

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2405
=item C<type_rule_off>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2406

            
2407
Same as C<execute> method's C<type_rule_off> option.
2408

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2409
=item C<type_rule1_off>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2410

            
2411
    type_rule1_off => 1
2412

            
2413
Same as C<execute> method's C<type_rule1_off> option.
2414

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2415
=item C<type_rule2_off>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2416

            
2417
    type_rule2_off => 1
2418

            
2419
Same as C<execute> method's C<type_rule2_off> option.
2420

            
2421
=back
2422

            
2423
=head2 C<delete_all>
2424

            
2425
    $dbi->delete_all(table => $table);
2426

            
2427
Execute delete statement for all rows.
2428
Options is same as C<delete>.
2429

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2430
=head2 C<each_column>
2431

            
2432
    $dbi->each_column(
2433
        sub {
2434
            my ($dbi, $table, $column, $column_info) = @_;
2435
            
2436
            my $type = $column_info->{TYPE_NAME};
2437
            
2438
            if ($type eq 'DATE') {
2439
                # ...
2440
            }
2441
        }
2442
    );
2443

            
2444
Iterate all column informations of all table from database.
2445
Argument is callback when one column is found.
2446
Callback receive four arguments, dbi object, table name,
2447
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2448

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

            
2451
    $dbi->each_table(
2452
        sub {
2453
            my ($dbi, $table, $table_info) = @_;
2454
            
2455
            my $table_name = $table_info->{TABLE_NAME};
2456
        }
2457
    );
2458

            
2459
Iterate all table informationsfrom database.
2460
Argument is callback when one table is found.
2461
Callback receive three arguments, dbi object, table name,
2462
table information.
2463

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

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

            
2471
    my $result = $dbi->execute(
2472
      "select * from book where title = :book.title and author like :book.author",
2473
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2474
    );
2475

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2482
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2483
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2484
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2485
    select * from book where title = :title and author like :author
2486
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2487
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2488
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2489

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2493
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2494
    select * from book where :title{=} and :author{like}
2495
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2496
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2497
    select * from where title = ? and author like ?;
2498

            
fixed named placeholder bug ...
Yuki Kimoto authored on 2011-08-01
2499
Note that colons in time format such as 12:13:15 is exeption,
2500
it is not parsed as named placeholder.
2501
If you want to use colon generally, you must escape it by C<\\>
2502

            
2503
    select * from where title = "aa\\:bb";
2504

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

            
2507
=over 4
2508

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2509
=item C<bind_type>
2510

            
2511
Specify database bind data type.
2512

            
2513
    bind_type => [image => DBI::SQL_BLOB]
2514
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2515

            
2516
This is used to bind parameter by C<bind_param> of statment handle.
2517

            
2518
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2519

            
update pod
Yuki Kimoto authored on 2011-03-13
2520
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2521
    
2522
    filter => {
2523
        title  => sub { uc $_[0] }
2524
        author => sub { uc $_[0] }
2525
    }
update pod
Yuki Kimoto authored on 2011-03-13
2526

            
updated pod
Yuki Kimoto authored on 2011-06-09
2527
    # Filter name
2528
    filter => {
2529
        title  => 'upper_case',
2530
        author => 'upper_case'
2531
    }
2532
        
2533
    # At once
2534
    filter => [
2535
        [qw/title author/]  => sub { uc $_[0] }
2536
    ]
2537

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

            
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2543
=item C<id>
2544

            
2545
    id => 4
2546
    id => [4, 5]
2547

            
2548
ID corresponding to C<primary_key>.
2549
You can delete rows by C<id> and C<primary_key>.
2550

            
2551
    $dbi->execute(
2552
        "select * from book where id1 = :id1 and id2 = :id2",
2553
        {},
2554
        parimary_key => ['id1', 'id2'],
2555
        id => [4, 5],
2556
    );
2557

            
2558
The above is same as the followin one.
2559

            
2560
    $dbi->execute(
2561
        "select * from book where id1 = :id1 and id2 = :id2",
2562
        {id1 => 4, id2 => 5}
2563
    );
2564

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

            
2567
    query => 1
2568

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

            
2572
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2573
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2574
    my $columns = $query->columns;
2575
    
2576
If you want to execute SQL fast, you can do the following way.
2577

            
2578
    my $query;
2579
    foreach my $row (@$rows) {
2580
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2581
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2582
    }
2583

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

            
2587
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
2588
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2589
    
2590
    my $query;
2591
    my $sth;
2592
    foreach my $row (@$rows) {
2593
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2594
      $sth ||= $query->sth;
2595
      $sth->execute(map { $row->{$_} } sort keys %$row);
2596
    }
2597

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

            
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2602
=item C<primary_key>
2603

            
2604
See C<id> option.
2605

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2606
=item C<after_build_sql> 
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2607

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2608
You can filter sql after the sql is build.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2609

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2610
    after_build_sql => $code_ref
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2611

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2612
The following one is one example.
2613

            
2614
    $dbi->select(
2615
        table => 'book',
2616
        column => 'distinct(name)',
2617
        after_build_sql => sub {
2618
            "select count(*) from ($_[0]) as t1"
2619
        }
2620
    );
2621

            
2622
The following SQL is executed.
2623

            
2624
    select count(*) from (select distinct(name) from book) as t1;
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2625

            
updated pod
Yuki Kimoto authored on 2011-06-09
2626
=item C<table>
2627
    
2628
    table => 'author'
2629

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2637
    # Same
2638
    $dbi->execute(
2639
      "select * from book where title = :book.title and author = :book.author",
2640
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2641

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2642
=item C<table_alias>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
2643

            
2644
    table_alias => {user => 'hiker'}
2645

            
2646
Table alias. Key is real table name, value is alias table name.
2647
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2648
on alias table name.
2649

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2650
=item C<type_rule_off>
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2651

            
2652
    type_rule_off => 1
2653

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2656
=item C<type_rule1_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2657

            
2658
    type_rule1_off => 1
2659

            
2660
Turn C<into1> type rule off.
2661

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2662
=item C<type_rule2_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2663

            
2664
    type_rule2_off => 1
2665

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2670
=head2 C<get_column_info>
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2671

            
2672
    my $tables = $self->get_column_info(exclude_table => qr/^system_/);
2673

            
2674
get column infomation except for one which match C<exclude_table> pattern.
2675

            
2676
    [
2677
        {table => 'book', column => 'title', info => {...}},
2678
        {table => 'author', column => 'name' info => {...}}
2679
    ]
2680

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2681
=head2 C<get_table_info>
added test
Yuki Kimoto authored on 2011-08-16
2682

            
2683
    my $tables = $self->get_table_info(exclude => qr/^system_/);
update pod
Yuki Kimoto authored on 2011-03-13
2684

            
added test
Yuki Kimoto authored on 2011-08-16
2685
get table infomation except for one which match C<exclude> pattern.
2686

            
2687
    [
2688
        {table => 'book', info => {...}},
2689
        {table => 'author', info => {...}}
2690
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2691

            
added test
Yuki Kimoto authored on 2011-08-16
2692
You can set this value to C<user_table_info>.
update pod
Yuki Kimoto authored on 2011-03-13
2693

            
cleanup
yuki-kimoto authored on 2010-10-17
2694
=head2 C<insert>
2695

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

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

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

            
2704
    {date => \"NOW()"}
2705

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

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

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

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

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2714
=item C<bind_type>
2715

            
2716
Same as C<execute> method's C<bind_type> option.
2717

            
update pod
Yuki Kimoto authored on 2011-03-13
2718
=item C<filter>
2719

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

            
2722
=item C<id>
2723

            
updated document
Yuki Kimoto authored on 2011-06-09
2724
    id => 4
2725
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2726

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2730
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2731
        {title => 'Perl', author => 'Ken'}
2732
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2733
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2734
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2735
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2736

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

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

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

            
2746
    prefix => 'or replace'
2747

            
2748
prefix before table name section
2749

            
2750
    insert or replace into book
2751

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

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

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

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

            
2761
Same as C<execute> method's C<query> option.
2762

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2763
=item C<after_build_sql>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2764

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2765
Same as C<execute> method's C<after_build_sql> option.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2766

            
updated document
Yuki Kimoto authored on 2011-06-09
2767
=item C<table>
2768

            
2769
    table => 'book'
2770

            
2771
Table name.
2772

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2773
=item C<type_rule_off>
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2774

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2777
=item C<timestamp>
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
2778

            
2779
    timestamp => 1
2780

            
2781
If this value is set to 1,
2782
automatically created timestamp column is set based on
2783
C<timestamp> attribute's C<insert> value.
2784

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2785
=item C<type_rule1_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2786

            
2787
    type_rule1_off => 1
2788

            
2789
Same as C<execute> method's C<type_rule1_off> option.
2790

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2791
=item C<type_rule2_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2792

            
2793
    type_rule2_off => 1
2794

            
2795
Same as C<execute> method's C<type_rule2_off> option.
2796

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2797
=item C<wrap>
updated pod
Yuki Kimoto authored on 2011-09-02
2798

            
2799
    wrap => {price => sub { "max($_[0])" }}
2800

            
2801
placeholder wrapped string.
2802

            
2803
If the following statement
2804

            
2805
    $dbi->insert({price => 100}, table => 'book',
2806
      {price => sub { "$_[0] + 5" }});
2807

            
2808
is executed, the following SQL is executed.
2809

            
2810
    insert into book price values ( ? + 5 );
2811

            
update pod
Yuki Kimoto authored on 2011-03-13
2812
=back
2813

            
2814
=over 4
2815

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2831
    lib / MyModel.pm
2832
        / MyModel / book.pm
2833
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2834

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

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

            
2839
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2840
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2841
    
2842
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2843

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2848
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2849
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2850
    
2851
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2852

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2855
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2856
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2857
    
2858
    1;
2859
    
updated pod
Yuki Kimoto authored on 2011-06-21
2860
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2861

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2869
=head2 C<insert_timestamp>
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2870

            
2871
    $dbi->insert_timestamp(
2872
      [qw/created_at updated_at/] => sub { localtime });
2873

            
2874
Parameter for timestamp columns when C<insert> method is executed
2875
with C<timestamp> option.
2876

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2877
If multiple column are specified, same value is used.
2878

            
2879
=head2 C<mapper>
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
2880

            
2881
    my $mapper = $dbi->mapper(param => $param);
2882

            
2883
Create a new L<DBIx::Custom::Mapper> object.
2884

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

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

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

            
2891
    {key1 => [1, 1], key2 => 2}
2892

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

            
2895
    $dbi->method(
2896
        update_or_insert => sub {
2897
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2898
            
2899
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2900
        },
2901
        find_or_create   => sub {
2902
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2903
            
2904
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2905
        }
2906
    );
2907

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

            
2910
    $dbi->update_or_insert;
2911
    $dbi->find_or_create;
2912

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

            
2915
    my $model = $dbi->model('book');
2916

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

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

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

            
2923
Create column clause for myself. The follwoing column clause is created.
2924

            
2925
    book.author as author,
2926
    book.title as title
2927

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2930
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2931
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2932
        user => 'ken',
2933
        password => '!LFKD%$&',
2934
        dbi_option => {mysql_enable_utf8 => 1}
2935
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2936

            
2937
Create a new L<DBIx::Custom> object.
2938

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

            
2941
    my $not_exists = $dbi->not_exists;
2942

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2946
=head2 C<order>
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
2947

            
2948
    my $order = $dbi->order;
2949

            
2950
Create a new L<DBIx::Custom::Order> object.
2951

            
cleanup
yuki-kimoto authored on 2010-10-17
2952
=head2 C<register_filter>
2953

            
update pod
Yuki Kimoto authored on 2011-03-13
2954
    $dbi->register_filter(
2955
        # Time::Piece object to database DATE format
2956
        tp_to_date => sub {
2957
            my $tp = shift;
2958
            return $tp->strftime('%Y-%m-%d');
2959
        },
2960
        # database DATE format to Time::Piece object
2961
        date_to_tp => sub {
2962
           my $date = shift;
2963
           return Time::Piece->strptime($date, '%Y-%m-%d');
2964
        }
2965
    );
cleanup
yuki-kimoto authored on 2010-10-17
2966
    
update pod
Yuki Kimoto authored on 2011-03-13
2967
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2968

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2969
=head2 C<type_rule>
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2970

            
2971
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2972
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2973
            date => sub { ... },
2974
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2975
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2976
        into2 => {
2977
            date => sub { ... },
2978
            datetime => sub { ... }
2979
        },
2980
        from1 => {
2981
            # DATE
2982
            9 => sub { ... },
2983
            # DATETIME or TIMESTAMP
2984
            11 => sub { ... },
2985
        }
2986
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2987
            # DATE
2988
            9 => sub { ... },
2989
            # DATETIME or TIMESTAMP
2990
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2991
        }
2992
    );
2993

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3009
=over 4
3010

            
3011
=item 1. column name
3012

            
3013
    issue_date
3014
    issue_datetime
3015

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

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

            
3020
    book.issue_date
3021
    book.issue_datetime
3022

            
3023
=back
3024

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
3025
You get all type name used in database by C<available_typename>.
update pod
Yuki Kimoto authored on 2011-06-15
3026

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
3027
    print $dbi->available_typename;
update pod
Yuki Kimoto authored on 2011-06-15
3028

            
updated pod
Yuki Kimoto authored on 2011-06-21
3029
In C<from1> and C<from2> you specify data type, not type name.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3030
C<from2> is executed after C<from1>.
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
3031
You get all data type by C<available_datatype>.
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3032

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
3033
    print $dbi->available_datatype;
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3034

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

            
3037
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3038
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3039
            [qw/DATE DATETIME/] => sub { ... },
3040
        ],
3041
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3042

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
3045
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3046
        table  => 'book',
3047
        column => ['author', 'title'],
3048
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
3049
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3050
    
updated document
Yuki Kimoto authored on 2011-06-09
3051
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3052

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

            
3055
=over 4
3056

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3061
Append statement to last of SQL.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3062

            
3063
=item C<bind_type>
3064

            
3065
Same as C<execute> method's C<bind_type> option.
updated document
Yuki Kimoto authored on 2011-06-09
3066
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3067
=item C<column>
3068
    
updated document
Yuki Kimoto authored on 2011-06-09
3069
    column => 'author'
3070
    column => ['author', 'title']
3071

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3080
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
3081
        {book => [qw/author title/]},
3082
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
3083
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
3084

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

            
3087
    book.author as "book.author",
3088
    book.title as "book.title",
3089
    person.name as "person.name",
3090
    person.age as "person.age"
3091

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

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

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

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

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

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

            
3107
=item C<id>
3108

            
3109
    id => 4
3110
    id => [4, 5]
3111

            
3112
ID corresponding to C<primary_key>.
3113
You can select rows by C<id> and C<primary_key>.
3114

            
3115
    $dbi->select(
3116
        parimary_key => ['id1', 'id2'],
3117
        id => [4, 5],
3118
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3119
    );
3120

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3123
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3124
        where => {id1 => 4, id2 => 5},
3125
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3126
    );
3127
    
updated document
Yuki Kimoto authored on 2011-06-09
3128
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3129

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

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

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

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

            
3142
    prefix => 'SQL_CALC_FOUND_ROWS'
3143

            
3144
Prefix of column cluase
3145

            
3146
    select SQL_CALC_FOUND_ROWS title, author from book;
3147

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

            
3150
    join => [
3151
        'left outer join company on book.company_id = company_id',
3152
        'left outer join location on company.location_id = location.id'
3153
    ]
3154
        
3155
Join clause. If column cluase or where clause contain table name like "company.name",
3156
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3157

            
3158
    $dbi->select(
3159
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3160
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3161
        where => {'company.name' => 'Orange'},
3162
        join => [
3163
            'left outer join company on book.company_id = company.id',
3164
            'left outer join location on company.location_id = location.id'
3165
        ]
3166
    );
3167

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3171
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3172
    from book
3173
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3174
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3175

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3176
You can specify two table by yourself. This is useful when join parser can't parse
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3177
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3178

            
3179
    $dbi->select(
3180
        table => 'book',
3181
        column => ['company.location_id as location_id'],
3182
        where => {'company.name' => 'Orange'},
3183
        join => [
3184
            {
3185
                clause => 'left outer join location on company.location_id = location.id',
3186
                table => ['company', 'location']
3187
            }
3188
        ]
3189
    );
3190

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

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

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3202
=item C<after_build_sql>
updated pod
Yuki Kimoto authored on 2011-06-08
3203

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3204
Same as C<execute> method's C<after_build_sql> option
updated pod
Yuki Kimoto authored on 2011-06-08
3205

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3210
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3211

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3212
=item C<type_rule_off>
updated pod
Yuki Kimoto authored on 2011-06-08
3213

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3216
=item C<type_rule1_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3217

            
3218
    type_rule1_off => 1
3219

            
3220
Same as C<execute> method's C<type_rule1_off> option.
3221

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3222
=item C<type_rule2_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3223

            
3224
    type_rule2_off => 1
3225

            
3226
Same as C<execute> method's C<type_rule2_off> option.
3227

            
updated document
Yuki Kimoto authored on 2011-06-09
3228
=item C<where>
3229
    
3230
    # Hash refrence
3231
    where => {author => 'Ken', 'title' => 'Perl'}
3232
    
3233
    # DBIx::Custom::Where object
3234
    where => $dbi->where(
3235
        clause => ['and', 'author = :author', 'title like :title'],
3236
        param  => {author => 'Ken', title => '%Perl%'}
3237
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3238
    
3239
    # Array reference 1 (array reference, hash referenc). same as above
3240
    where => [
3241
        ['and', 'author = :author', 'title like :title'],
3242
        {author => 'Ken', title => '%Perl%'}
3243
    ];    
3244
    
3245
    # Array reference 2 (String, hash reference)
3246
    where => [
3247
        'title like :title',
3248
        {title => '%Perl%'}
3249
    ]
3250
    
3251
    # String
3252
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3253

            
updated document
Yuki Kimoto authored on 2011-06-09
3254
Where clause.
3255
    
update pod
Yuki Kimoto authored on 2011-03-12
3256
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3257

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

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

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

            
3264
If you want to set constant value to row data, use scalar reference
3265
as parameter value.
3266

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
3271
=over 4
3272

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

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

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3277
=item C<bind_type>
3278

            
3279
Same as C<execute> method's C<bind_type> option.
3280

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3287
    id => 4
3288
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3289

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3293
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3294
        {title => 'Perl', author => 'Ken'}
3295
        parimary_key => ['id1', 'id2'],
3296
        id => [4, 5],
3297
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3298
    );
update pod
Yuki Kimoto authored on 2011-03-13
3299

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3302
    $dbi->update(
3303
        {title => 'Perl', author => 'Ken'}
3304
        where => {id1 => 4, id2 => 5},
3305
        table => 'book'
3306
    );
update pod
Yuki Kimoto authored on 2011-03-13
3307

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

            
3310
    prefix => 'or replace'
3311

            
3312
prefix before table name section
3313

            
3314
    update or replace book
3315

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

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

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3327
=item C<after_build_sql>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3328

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3329
Same as C<execute> method's C<after_build_sql> option.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3330

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3337
=item C<timestamp>
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
3338

            
3339
    timestamp => 1
3340

            
3341
If this value is set to 1,
3342
automatically updated timestamp column is set based on
3343
C<timestamp> attribute's C<update> value.
3344

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3345
=item C<type_rule_off>
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
3346

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3349
=item C<type_rule1_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3350

            
3351
    type_rule1_off => 1
3352

            
3353
Same as C<execute> method's C<type_rule1_off> option.
3354

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3355
=item C<type_rule2_off>
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3356

            
3357
    type_rule2_off => 1
3358

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

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3361
=item C<where>
3362

            
3363
Same as C<select> method's C<where> option.
3364

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3365
=item C<wrap>
updated pod
Yuki Kimoto authored on 2011-09-02
3366

            
3367
    wrap => {price => sub { "max($_[0])" }}
3368

            
3369
placeholder wrapped string.
3370

            
3371
If the following statement
3372

            
3373
    $dbi->update({price => 100}, table => 'book',
3374
      {price => sub { "$_[0] + 5" }});
3375

            
3376
is executed, the following SQL is executed.
3377

            
3378
    update book set price =  ? + 5;
3379

            
updated pod
Yuki Kimoto authored on 2011-06-08
3380
=back
update pod
Yuki Kimoto authored on 2011-03-13
3381

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

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

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

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

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

            
3393
Create update parameter tag.
3394

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3397
=head2 C<update_timestamp>
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
3398

            
3399
    $dbi->update_timestamp(updated_at => sub { localtime });
3400

            
3401
Parameter for timestamp columns when C<update> method is executed
3402
with C<timestamp> option.
3403

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

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

            
3411
Create a new L<DBIx::Custom::Where> object.
3412

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

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3420
=head2 C<show_datatype>
update pod
Yuki Kimoto authored on 2011-08-10
3421

            
3422
    $dbi->show_datatype($table);
3423

            
3424
Show data type of the columns of specified table.
3425

            
3426
    book
3427
    title: 5
3428
    issue_date: 91
3429

            
3430
This data type is used in C<type_rule>'s C<from1> and C<from2>.
3431

            
- removed EXPERIMENTAL the f...
Yuki Kimoto authored on 2011-09-12
3432
=head2 C<show_tables>
test cleanup
Yuki Kimoto authored on 2011-08-15
3433

            
3434
    $dbi->show_tables;
3435

            
3436
Show tables.
3437

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3438
=head2 C<show_typename>
update pod
Yuki Kimoto authored on 2011-08-10
3439

            
3440
    $dbi->show_typename($table);
3441

            
3442
Show type name of the columns of specified table.
3443

            
3444
    book
3445
    title: varchar
3446
    issue_date: date
3447

            
3448
This type name is used in C<type_rule>'s C<into1> and C<into2>.
3449

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
3450
=head1 ENVIRONMENTAL VARIABLES
3451

            
3452
=head2 C<DBIX_CUSTOM_DEBUG>
3453

            
3454
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3455
executed SQL and bind values are printed to STDERR.
3456

            
improved debug message
Yuki Kimoto authored on 2011-05-23
3457
=head2 C<DBIX_CUSTOM_DEBUG_ENCODING>
3458

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

            
fix heading typos
Terrence Brannon authored on 2011-08-17
3461
=head1 DEPRECATED FUNCTIONALITY
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3462

            
3463
L<DBIx::Custom>
3464

            
3465
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3466
    data_source # will be removed at 2017/1/1
3467
    dbi_options # will be removed at 2017/1/1
3468
    filter_check # will be removed at 2017/1/1
3469
    reserved_word_quote # will be removed at 2017/1/1
3470
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3471
    
3472
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3473
    create_query # will be removed at 2017/1/1
3474
    apply_filter # will be removed at 2017/1/1
3475
    select_at # will be removed at 2017/1/1
3476
    delete_at # will be removed at 2017/1/1
3477
    update_at # will be removed at 2017/1/1
3478
    insert_at # will be removed at 2017/1/1
3479
    register_tag # will be removed at 2017/1/1
3480
    default_bind_filter # will be removed at 2017/1/1
3481
    default_fetch_filter # will be removed at 2017/1/1
3482
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3483
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3484
    register_tag_processor # will be removed at 2017/1/1
3485
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3486
    
3487
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3488
    select method relation option # will be removed at 2017/1/1
3489
    select method param option # will be removed at 2017/1/1
3490
    select method column option [COLUMN, as => ALIAS] format
3491
      # will be removed at 2017/1/1
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3492
    execute method's sqlfilter option # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3493
    
3494
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3495
    execute("select * from {= title}"); # execute method's
3496
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3497
                                        # will be removed at 2017/1/1
3498
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3499

            
3500
L<DBIx::Custom::Model>
3501

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3502
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3503
    filter # will be removed at 2017/1/1
3504
    name # will be removed at 2017/1/1
3505
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3506

            
3507
L<DBIx::Custom::Query>
3508
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3509
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3510
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3511
    table # will be removed at 2017/1/1
3512
    filters # will be removed at 2017/1/1
3513
    
3514
    # Methods
3515
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3516

            
3517
L<DBIx::Custom::QueryBuilder>
3518
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3519
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3520
    tags # will be removed at 2017/1/1
3521
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3522
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3523
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3524
    register_tag # will be removed at 2017/1/1
3525
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3526
    
3527
    # Others
3528
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3529
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3530

            
3531
L<DBIx::Custom::Result>
3532
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3533
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3534
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3535
    
3536
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3537
    end_filter # will be removed at 2017/1/1
3538
    remove_end_filter # will be removed at 2017/1/1
3539
    remove_filter # will be removed at 2017/1/1
3540
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3541

            
3542
L<DBIx::Custom::Tag>
3543

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

            
fix heading typos
Terrence Brannon authored on 2011-08-17
3546
=head1 BACKWARDS COMPATIBILITY POLICY
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3547

            
3548
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3549
except for attribute method.
3550
You can check all DEPRECATED functionalities by document.
3551
DEPRECATED functionality is removed after five years,
3552
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
3553
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3554

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

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

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

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

            
3563
C<< <kimoto.yuki at gmail.com> >>
3564

            
3565
L<http://github.com/yuki-kimoto/DBIx-Custom>
3566

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3567
=head1 AUTHOR
3568

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

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

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

            
3575
This program is free software; you can redistribute it and/or modify it
3576
under the same terms as Perl itself.
3577

            
3578
=cut