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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
4
our $VERSION = '0.1723';
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

            
simplified arguments check
Yuki Kimoto authored on 2011-07-11
375
our %VALID_ARGS = map { $_ => 1 } qw/append allow_delete_all
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} || {};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
403
    my $sqlfilter = $args{sqlfilter};
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
404
    my $id = delete $args{id};
405
    my $primary_key = delete $args{primary_key};
406
    croak "insert method primary_key option " .
407
          "must be specified when id is specified " . _subname
408
      if defined $id && !defined $primary_key;
409
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
410

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1999
=item *
2000

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

            
2003
=item *
2004

            
2005
Connection manager support
2006

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

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

            
2013
=item *
2014

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

            
2017
=item *
2018

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2084
=head2 C<default_dbi_option>
2085

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2200
You can set the following data.
2201

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

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

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

            
2213
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
2214
to find column info. this is very fast.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2215

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

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

            
2221
You can set the following data.
2222

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2308
Get rows count.
2309

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

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

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

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

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

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

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

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

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

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

            
2338
Execute delete statement.
2339

            
2340
The following opitons are available.
2341

            
2342
=over 4
2343

            
2344
=item C<append>
2345

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

            
2348
=item C<filter>
2349

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

            
2352
=item C<id>
2353

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

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

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

            
2366
The above is same as the followin one.
2367

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

            
2370
=item C<prefix>
2371

            
2372
    prefix => 'some'
2373

            
2374
prefix before table name section.
2375

            
2376
    delete some from book
2377

            
2378
=item C<query>
2379

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2382
=item C<sqlfilter>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2383

            
2384
Same as C<execute> method's C<sqlfilter> option.
2385

            
2386
=item C<table>
2387

            
2388
    table => 'book'
2389

            
2390
Table name.
2391

            
2392
=item C<where>
2393

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

            
2396
=item C<primary_key>
2397

            
2398
See C<id> option.
2399

            
2400
=item C<bind_type>
2401

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

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

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

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

            
2410
    type_rule1_off => 1
2411

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

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

            
2416
    type_rule2_off => 1
2417

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

            
2420
=back
2421

            
2422
=head2 C<delete_all>
2423

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2506
=over 4
2507

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

            
2510
Specify database bind data type.
2511

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

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

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

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

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

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

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

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

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

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

            
2557
The above is same as the followin one.
2558

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

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

            
2566
    query => 1
2567

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

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

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

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

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

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

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

            
2603
See C<id> option.
2604

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2605
=item C<sqlfilter> 
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2606

            
2607
SQL filter function.
2608

            
2609
    sqlfilter => $code_ref
2610

            
2611
This option is generally for Oracle and SQL Server paging process.
2612
    
2613
    my $limit = sub {
2614
        my ($sql, $count, $offset) = @_;
2615
        
2616
        my $min = $offset + 1;
2617
        my $max = $offset + $count;
2618
        
2619
        $sql = "select * from ( $sql ) as t where rnum >= $min rnum <= $max";
2620
        
2621
        return $sql;
2622
    }
2623
    $dbi->select(... column => ['ROWNUM rnom'], sqlfilter => sub {
2624
        my $sql = shift;
2625
        return $limit->($sql, 100, 50);
2626
    })
2627

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

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

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

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

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

            
2646
    table_alias => {user => 'hiker'}
2647

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

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

            
2654
    type_rule_off => 1
2655

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

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

            
2660
    type_rule1_off => 1
2661

            
2662
Turn C<into1> type rule off.
2663

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

            
2666
    type_rule2_off => 1
2667

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

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

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

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

            
2676
get column infomation except for one which match C<exclude_table> pattern.
2677

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2696
=head2 C<insert>
2697

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

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

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

            
2706
    {date => \"NOW()"}
2707

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

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

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

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

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

            
2718
Same as C<execute> method's C<bind_type> option.
2719

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

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

            
2724
=item C<id>
2725

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

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

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

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

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

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

            
2748
    prefix => 'or replace'
2749

            
2750
prefix before table name section
2751

            
2752
    insert or replace into book
2753

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

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

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

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

            
2763
Same as C<execute> method's C<query> option.
2764

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2765
=item C<sqlfilter>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2766

            
2767
Same as C<execute> method's C<sqlfilter> option.
2768

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

            
2771
    table => 'book'
2772

            
2773
Table name.
2774

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

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

            
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
2779
=item C<timestamp EXPERIMENTAL>
2780

            
2781
    timestamp => 1
2782

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

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

            
2789
    type_rule1_off => 1
2790

            
2791
Same as C<execute> method's C<type_rule1_off> option.
2792

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

            
2795
    type_rule2_off => 1
2796

            
2797
Same as C<execute> method's C<type_rule2_off> option.
2798

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

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

            
2803
placeholder wrapped string.
2804

            
2805
If the following statement
2806

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

            
2810
is executed, the following SQL is executed.
2811

            
2812
    insert into book price values ( ? + 5 );
2813

            
update pod
Yuki Kimoto authored on 2011-03-13
2814
=back
2815

            
2816
=over 4
2817

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2818
=head2 C<insert_param>
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
    my $insert_param = $dbi->insert_param({title => 'a', age => 2});
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
Create insert parameters.
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2823

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2871
=head2 C<insert_timestamp EXPERIMENTAL>
2872

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

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

            
- removed EXPERIMENTAL map_p...
Yuki Kimoto authored on 2011-09-12
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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3202
=item C<sqlfilter>
updated pod
Yuki Kimoto authored on 2011-06-08
3203

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3204
Same as C<execute> method's C<sqlfilter> 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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3327
=item C<sqlfilter>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3328

            
3329
Same as C<execute> method's C<sqlfilter> option.
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

            
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
3337
=item C<timestamp EXPERIMENTAL>
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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
3397
=head2 C<insert_timestamp EXPERIMENTAL>
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

            
test cleanup
Yuki Kimoto authored on 2011-08-15
3432
=head2 C<show_tables EXPERIMETNAL>
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
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3492
    
3493
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3494
    execute("select * from {= title}"); # execute method's
3495
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3496
                                        # will be removed at 2017/1/1
3497
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3498

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
3577
=cut