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

            
fixed where clause parsing b...
Yuki Kimoto authored on 2011-11-01
4
our $VERSION = '0.1743';
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 EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
22
has [qw/connector dsn password quote user exclude_table user_table_info
23
        user_column_info/],
removed from cache() and cac...
Yuki Kimoto authored on 2011-03-29
24
    cache => 0,
many changed
Yuki Kimoto authored on 2011-01-23
25
    cache_method => sub {
26
        sub {
27
            my $self = shift;
28
            
29
            $self->{_cached} ||= {};
30
            
31
            if (@_ > 1) {
update pod
Yuki Kimoto authored on 2011-03-13
32
                $self->{_cached}{$_[0]} = $_[1];
many changed
Yuki Kimoto authored on 2011-01-23
33
            }
34
            else {
update pod
Yuki Kimoto authored on 2011-03-13
35
                return $self->{_cached}{$_[0]};
many changed
Yuki Kimoto authored on 2011-01-23
36
            }
37
        }
update pod
Yuki Kimoto authored on 2011-03-13
38
    },
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
39
    option => sub { {} },
40
    default_option => sub {
update pod
Yuki Kimoto authored on 2011-03-13
41
        {
42
            RaiseError => 1,
43
            PrintError => 0,
44
            AutoCommit => 1
45
        }
46
    },
fix tests
Yuki Kimoto authored on 2011-01-13
47
    filters => sub {
48
        {
49
            encode_utf8 => sub { encode_utf8($_[0]) },
50
            decode_utf8 => sub { decode_utf8($_[0]) }
51
        }
update pod
Yuki Kimoto authored on 2011-03-13
52
    },
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
53
    last_sql => '',
update pod
Yuki Kimoto authored on 2011-03-13
54
    models => sub { {} },
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
55
    now => sub {
56
        sub {
57
            my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
58
            $mon++;
59
            $year += 1900;
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
60
            my $now = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
61
              $year, $mon, $mday, $hour, $min, $sec);
62
            return $now;
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
63
        }
64
    },
cleanup
Yuki Kimoto authored on 2011-08-13
65
    query_builder => sub {
66
        my $self = shift;
67
        my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
68
        weaken $builder->{dbi};
69
        return $builder;
70
    },
update pod
Yuki Kimoto authored on 2011-03-13
71
    result_class  => 'DBIx::Custom::Result',
72
    safety_character => '\w',
cleanup test
Yuki Kimoto authored on 2011-08-10
73
    separator => '.',
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
74
    stash => sub { {} },
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
75
    tag_parse => 1;
cleanup
yuki-kimoto authored on 2010-10-17
76

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
77
sub available_datatype {
test cleanup
Yuki Kimoto authored on 2011-08-10
78
    my $self = shift;
79
    
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
80
    my $data_types = '';
cleanup
Yuki Kimoto authored on 2011-10-21
81
    for my $i (-1000 .. 1000) {
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
82
         my $type_info = $self->dbh->type_info($i);
83
         my $data_type = $type_info->{DATA_TYPE};
84
         my $type_name = $type_info->{TYPE_NAME};
85
         $data_types .= "$data_type ($type_name)\n"
86
           if defined $data_type;
87
    }
88
    return "Data Type maybe equal to Type Name" unless $data_types;
89
    $data_types = "Data Type (Type name)\n" . $data_types;
90
    return $data_types;
91
}
92

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

            
added helper method
yuki-kimoto authored on 2010-10-17
108
our $AUTOLOAD;
109
sub AUTOLOAD {
110
    my $self = shift;
111

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
129
sub assign_clause {
updated pod
Yuki Kimoto authored on 2011-09-02
130
    my ($self, $param, $opts) = @_;
131
    
132
    my $wrap = $opts->{wrap} || {};
micro optimization
Yuki Kimoto authored on 2011-10-23
133
    my $safety = $self->{safety_character} || $self->safety_character;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
134
    my $qp = $self->q('');
fixed some quoted bug
Yuki Kimoto authored on 2011-10-22
135
    my $q = substr($qp, 0, 1) || '';
136
    my $p = substr($qp, 1, 1) || '';
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
137
    
micro optimization
Yuki Kimoto authored on 2011-10-23
138
    # Check unsafety keys
139
    unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
140
        for my $column (keys %$param) {
141
            croak qq{"$column" is not safety column name } . _subname
142
              unless $column =~ /^[$safety\.]+$/;
143
        }
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
144
    }
145
    
micro optimization
Yuki Kimoto authored on 2011-10-23
146
    # Assign clause (performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
147
    join(
148
      ', ',
149
      map {
150
          ref $param->{$_} eq 'SCALAR' ? "$q$_$p = " . ${$param->{$_}}
151
          : $wrap->{$_} ? "$q$_$p = " . $wrap->{$_}->(":$_")
152
          : "$q$_$p = :$_";
153
      } sort keys %$param
154
    );
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
155
}
156

            
cleanup
Yuki Kimoto authored on 2011-03-21
157
sub column {
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
158
    my $self = shift;
159
    my $option = pop if ref $_[-1] eq 'HASH';
160
    my $real_table = shift;
161
    my $columns = shift;
162
    my $table = $option->{alias} || $real_table;
163
    
164
    # Columns
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-10-26
165
    unless (defined $columns) {
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
166
        $columns ||= $self->model($real_table)->columns;
167
    }
added helper method
yuki-kimoto authored on 2010-10-17
168
    
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
169
    # Separator
170
    my $separator = $self->separator;
171
    
cleanup
Yuki Kimoto authored on 2011-04-02
172
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-21
173
    my @column;
cleanup
Yuki Kimoto authored on 2011-04-02
174
    $columns ||= [];
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
175
    push @column, $self->q($table) . "." . $self->q($_) .
176
      " as " . $self->q("${table}${separator}$_")
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
177
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
178
    
179
    return join (', ', @column);
added helper method
yuki-kimoto authored on 2010-10-17
180
}
181

            
packaging one directory
yuki-kimoto authored on 2009-11-16
182
sub connect {
cleanup
Yuki Kimoto authored on 2011-08-16
183
    my $self = ref $_[0] ? shift : shift->new(@_);
184
    
185
    my $connector = $self->connector;
186
    
187
    if (!ref $connector && $connector) {
188
        require DBIx::Connector;
189
        
190
        my $dsn = $self->dsn;
191
        my $user = $self->user;
192
        my $password = $self->password;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
193
        my $option = $self->_option;
cleanup
Yuki Kimoto authored on 2011-08-16
194
        my $connector = DBIx::Connector->new($dsn, $user, $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
195
          {%{$self->default_option} , %$option});
cleanup
Yuki Kimoto authored on 2011-08-16
196
        $self->connector($connector);
197
    }
removed register_format()
yuki-kimoto authored on 2010-05-26
198
    
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
199
    # Connect
200
    $self->dbh;
update document
yuki-kimoto authored on 2010-01-30
201
    
packaging one directory
yuki-kimoto authored on 2009-11-16
202
    return $self;
203
}
204

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
244
sub delete {
245
    my ($self, %opt) = @_;
246
    warn "delete method where_param option is DEPRECATED!"
247
      if $opt{where_param};
248
    
cleanup
Yuki Kimoto authored on 2011-10-21
249
    # Don't allow delete all rows
cleanup
Yuki Kimoto authored on 2011-10-21
250
    croak qq{delete method where or id option must be specified } . _subname
251
      if !$opt{where} && !defined $opt{id} && !$opt{allow_delete_all};
252
    
253
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
254
    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
cleanup
Yuki Kimoto authored on 2011-10-25
255
      delete $opt{id}, $opt{primary_key}, $opt{table});
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
256

            
cleanup
Yuki Kimoto authored on 2011-04-02
257
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-10-21
258
    my $sql = "delete ";
cleanup
Yuki Kimoto authored on 2011-10-21
259
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
260
    $sql .= "from " . $self->q($opt{table}) . " $w->{clause} ";
packaging one directory
yuki-kimoto authored on 2009-11-16
261
    
262
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
263
    $opt{statement} = 'delete';
cleanup
Yuki Kimoto authored on 2011-10-25
264
    $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
265
}
266

            
cleanup
Yuki Kimoto authored on 2011-11-01
267
sub delete_all { shift->delete(@_, allow_delete_all => 1) }
packaging one directory
yuki-kimoto authored on 2009-11-16
268

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
271
sub create_model {
272
    my $self = shift;
273
    
cleanup
Yuki Kimoto authored on 2011-10-21
274
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
275
    my $opt = ref $_[0] eq 'HASH' ? $_[0] : {@_};
276
    $opt->{dbi} = $self;
277
    my $model_class = delete $opt->{model_class} || 'DBIx::Custom::Model';
278
    my $model_name  = delete $opt->{name};
279
    my $model_table = delete $opt->{table};
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
280
    $model_name ||= $model_table;
281
    
cleanup
Yuki Kimoto authored on 2011-04-02
282
    # Create model
cleanup
Yuki Kimoto authored on 2011-10-21
283
    my $model = $model_class->new($opt);
cleanup
Yuki Kimoto authored on 2011-08-13
284
    weaken $model->{dbi};
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
285
    $model->name($model_name) unless $model->name;
286
    $model->table($model_table) unless $model->table;
287
    
micro optimization
Yuki Kimoto authored on 2011-07-30
288
    # Apply filter(DEPRECATED logic)
289
    if ($model->{filter}) {
290
        my $filter = ref $model->filter eq 'HASH'
291
                   ? [%{$model->filter}]
292
                   : $model->filter;
293
        $filter ||= [];
294
        warn "DBIx::Custom::Model filter method is DEPRECATED!"
295
          if @$filter;
296
        $self->_apply_filter($model->table, @$filter);
297
    }
298
    
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
299
    # Set model
300
    $self->model($model->name, $model);
301
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
302
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
303
}
304

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

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
308
    my $user_column_info = $self->user_column_info;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
309
    
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
310
    if ($user_column_info) {
311
        $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
312
    }
313
    else {
314
    
315
        my $re = $self->exclude_table || $options{exclude_table};
316
        # Tables
317
        my %tables;
318
        $self->each_table(sub { $tables{$_[1]}++ });
added SQL Server test
Yuki Kimoto authored on 2011-08-14
319

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
320
        # Iterate all tables
321
        my @tables = sort keys %tables;
322
        for (my $i = 0; $i < @tables; $i++) {
323
            my $table = $tables[$i];
324
            
325
            # Iterate all columns
326
            my $sth_columns;
327
            eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
328
            next if $@;
329
            while (my $column_info = $sth_columns->fetchrow_hashref) {
330
                my $column = $column_info->{COLUMN_NAME};
331
                $self->$cb($table, $column, $column_info);
332
            }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
333
        }
334
    }
335
}
336

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
337
sub each_table {
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
338
    my ($self, $cb, %option) = @_;
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
339
    
cleanup test
Yuki Kimoto authored on 2011-08-16
340
    my $user_table_infos = $self->user_table_info;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
341
    
added test
Yuki Kimoto authored on 2011-08-16
342
    # Iterate tables
343
    if ($user_table_infos) {
344
        $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
345
    }
346
    else {
347
        my $re = $self->exclude_table || $option{exclude};
348
        my $sth_tables = $self->dbh->table_info;
349
        while (my $table_info = $sth_tables->fetchrow_hashref) {
350
            
351
            # Table
352
            my $table = $table_info->{TABLE_NAME};
353
            next if defined $re && $table =~ /$re/;
354
            $self->$cb($table, $table_info);
355
        }
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
356
    }
357
}
358

            
cleanup
Yuki Kimoto authored on 2011-04-02
359
sub execute {
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
360
    my $self = shift;
cleanup
Yuki Kimoto authored on 2011-10-20
361
    my $sql = shift;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
362

            
363
    # Options
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
364
    my $param;
365
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
366
    my %opt = @_;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
367
    warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
368
    $param ||= $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-10-21
369
    my $tables = $opt{table} || [];
cleanup
Yuki Kimoto authored on 2011-04-02
370
    $tables = [$tables] unless ref $tables eq 'ARRAY';
micro optimization
Yuki Kimoto authored on 2011-10-23
371
    my $filter = ref $opt{filter} eq 'ARRAY' ?
372
      _array_to_hash($opt{filter}) : $opt{filter};
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
373
    
micro optimization and
Yuki Kimoto authored on 2011-10-25
374
    # Merge second parameter
375
    my @cleanup;
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
376
    my $saved_param;
micro optimization and
Yuki Kimoto authored on 2011-10-25
377
    if (ref $param eq 'ARRAY') {
378
        my $param2 = $param->[1];
379
        $param = $param->[0];
380
        for my $column (keys %$param2) {
381
            if (!exists $param->{$column}) {
382
                $param->{$column} = $param2->{$column};
383
                push @cleanup, $column;
384
            }
385
            else {
386
                delete $param->{$_} for @cleanup;
387
                @cleanup = ();
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
388
                $saved_param  = $param;
micro optimization and
Yuki Kimoto authored on 2011-10-25
389
                $param = $self->merge_param($param, $param2);
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
390
                delete $saved_param->{$_} for (@{$opt{cleanup} || []});
micro optimization and
Yuki Kimoto authored on 2011-10-25
391
                last;
392
            }
393
        }
394
    }
395
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
396
    # Append
397
    $sql .= $opt{append} if defined $opt{append} && !ref $sql;
398
    
399
    # Query
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
400
    my $query;
micro optimization and
Yuki Kimoto authored on 2011-10-25
401
    if (ref $sql) {
402
        $query = $sql;
403
        warn "execute method receiving query object as first parameter is DEPRECATED!" .
404
             "because this is very buggy.";
405
    }
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
406
    else {
407
        $query = $opt{reuse}->{$sql} if $opt{reuse};
408
        $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter})
409
          unless $query;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
410
        $query->statement($opt{statement} || '');
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
411
        $opt{reuse}->{$sql} = $query if $opt{reuse};
412
    }
413
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
414
    # Save query
micro optimization
Yuki Kimoto authored on 2011-10-23
415
    $self->{last_sql} = $query->{sql};
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
416

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
417
    # Return query
418
    return $query if $opt{query};
micro optimization
Yuki Kimoto authored on 2011-07-30
419
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
420
    # Merge query filter(DEPRECATED!)
DBIx::Custom::Query filter m...
Yuki Kimoto authored on 2011-07-30
421
    $filter ||= $query->{filter} || {};
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
422
    
cleanup
Yuki Kimoto authored on 2011-04-02
423
    # Tables
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
424
    unshift @$tables, @{$query->{tables} || []};
micro optimization
Yuki Kimoto authored on 2011-07-30
425
    my $main_table = @{$tables}[-1];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
426

            
427
    # Merge id to parameter
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
428
    if (defined $opt{id}) {
execute method id option is ...
Yuki Kimoto authored on 2011-10-27
429
        my $statement = $query->statement;
430
        warn "execute method id option is DEPRECATED!" unless $statement;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
431
        croak "execute id option must be specified with primary_key option"
432
          unless $opt{primary_key};
433
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
434
        $opt{id} = [$opt{id}] unless ref $opt{id};
435
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
436
           my $key = $opt{primary_key}->[$i];
437
           $key = "$main_table.$key" if $statement eq 'update' ||
438
             $statement eq 'delete' || $statement eq 'select';
439
           next if exists $param->{$key};
440
           $param->{$key} = $opt{id}->[$i];
micro optimization and
Yuki Kimoto authored on 2011-10-25
441
           push @cleanup, $key;1
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
442
        }
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
443
    }
micro optimization
Yuki Kimoto authored on 2011-07-30
444
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
445
    # Cleanup tables(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
446
    $tables = $self->_remove_duplicate_table($tables, $main_table)
447
      if @$tables > 1;
cleanup
Yuki Kimoto authored on 2011-04-02
448
    
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
449
    # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
450
    my $type_filters = {};
micro optimization
Yuki Kimoto authored on 2011-10-23
451
    if ($self->{_type_rule_is_called}) {
452
        unless ($opt{type_rule_off}) {
453
            my $type_rule_off_parts = {
454
                1 => $opt{type_rule1_off},
455
                2 => $opt{type_rule2_off}
456
            };
457
            for my $i (1, 2) {
458
                unless ($type_rule_off_parts->{$i}) {
459
                    $type_filters->{$i} = {};
460
                    my $table_alias = $opt{table_alias} || {};
461
                    for my $alias (keys %$table_alias) {
462
                        my $table = $table_alias->{$alias};
463
                        
464
                        for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
465
                            $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
466
                        }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
467
                    }
micro optimization
Yuki Kimoto authored on 2011-10-23
468
                    $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
469
                      if $main_table;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
470
                }
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
471
            }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
472
        }
473
    }
cleanup
Yuki Kimoto authored on 2011-04-02
474
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
475
    # Applied filter(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
476
    if ($self->{filter}{on}) {
477
        my $applied_filter = {};
cleanup
Yuki Kimoto authored on 2011-10-21
478
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-07-30
479
            $applied_filter = {
480
                %$applied_filter,
481
                %{$self->{filter}{out}->{$table} || {}}
482
            }
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
483
        }
micro optimization
Yuki Kimoto authored on 2011-07-30
484
        $filter = {%$applied_filter, %$filter};
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
485
    }
486
    
cleanup
Yuki Kimoto authored on 2011-04-02
487
    # Replace filter name to code
cleanup
Yuki Kimoto authored on 2011-10-21
488
    for my $column (keys %$filter) {
cleanup
Yuki Kimoto authored on 2011-04-02
489
        my $name = $filter->{$column};
490
        if (!defined $name) {
491
            $filter->{$column} = undef;
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
492
        }
cleanup
Yuki Kimoto authored on 2011-04-02
493
        elsif (ref $name ne 'CODE') {
cleanup
Yuki Kimoto authored on 2011-04-25
494
          croak qq{Filter "$name" is not registered" } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
495
            unless exists $self->filters->{$name};
496
          $filter->{$column} = $self->filters->{$name};
cleanup
Yuki Kimoto authored on 2010-12-21
497
        }
498
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
499
    
cleanup
Yuki Kimoto authored on 2011-04-02
500
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
501
    my ($bind, $bind_types) = $self->_create_bind_values($param, $query->columns,
502
      $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
503

            
cleanup
yuki-kimoto authored on 2010-10-17
504
    # Execute
micro optimization
Yuki Kimoto authored on 2011-10-23
505
    my $sth = $query->{sth};
cleanup
yuki-kimoto authored on 2010-10-17
506
    my $affected;
cleanup
Yuki Kimoto authored on 2011-03-21
507
    eval {
micro optimization
Yuki Kimoto authored on 2011-10-23
508
        if ($opt{bind_type} || $opt{type}) {
509
            $sth->bind_param($_ + 1, $bind->[$_],
510
                $bind_types->[$_] ? $bind_types->[$_] : ())
511
              for (0 .. @$bind - 1);
512
            $affected = $sth->execute;
513
        }
514
        else {
515
            $affected = $sth->execute(@$bind);
516
        }
cleanup
Yuki Kimoto authored on 2011-03-21
517
    };
improved error messages
Yuki Kimoto authored on 2011-04-18
518
    
micro optimization
Yuki Kimoto authored on 2011-07-30
519
    $self->_croak($@, qq{. Following SQL is executed.\n}
520
      . qq{$query->{sql}\n} . _subname) if $@;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
521

            
522
    # Remove id from parameter
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
523
    delete $param->{$_} for (@cleanup, @{$opt{cleanup} || []});
cleanup
yuki-kimoto authored on 2010-10-17
524
    
improved debug message
Yuki Kimoto authored on 2011-05-23
525
    # DEBUG message
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
526
    if ($ENV{DBIX_CUSTOM_DEBUG}) {
527
        warn "SQL:\n" . $query->sql . "\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
528
        my @output;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
529
        for my $value (@$bind) {
improved debug message
Yuki Kimoto authored on 2011-05-23
530
            $value = 'undef' unless defined $value;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
531
            $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
improved debug message
Yuki Kimoto authored on 2011-05-23
532
              if utf8::is_utf8($value);
533
            push @output, $value;
534
        }
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
535
        warn "Bind values: " . join(', ', @output) . "\n\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
536
    }
added environment variable D...
Yuki Kimoto authored on 2011-04-02
537
    
micro optimization
Yuki Kimoto authored on 2011-10-23
538
    # Not select statement
539
    return $affected unless $sth->{NUM_OF_FIELDS};
540

            
541
    # Filter(DEPRECATED!)
542
    my $infilter = {};
543
    if ($self->{filter}{on}) {
544
        $infilter->{in}  = {};
545
        $infilter->{end} = {};
546
        push @$tables, $main_table if $main_table;
547
        for my $table (@$tables) {
548
            for my $way (qw/in end/) {
549
                $infilter->{$way} = {%{$infilter->{$way}},
550
                  %{$self->{filter}{$way}{$table} || {}}};
cleanup
Yuki Kimoto authored on 2011-04-02
551
            }
cleanup
Yuki Kimoto authored on 2011-01-12
552
        }
cleanup
yuki-kimoto authored on 2010-10-17
553
    }
micro optimization
Yuki Kimoto authored on 2011-10-23
554
    
555
    # Result
556
    my $result = $self->result_class->new(
557
        sth => $sth,
558
        dbi => $self,
559
        default_filter => $self->{default_in_filter},
560
        filter => $infilter->{in} || {},
561
        end_filter => $infilter->{end} || {},
562
        type_rule => {
563
            from1 => $self->type_rule->{from1},
564
            from2 => $self->type_rule->{from2}
565
        },
566
    );
567
    $result;
cleanup
yuki-kimoto authored on 2010-10-17
568
}
569

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

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

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
602
sub helper {
603
    my $self = shift;
604
    
605
    # Register method
606
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
607
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
608
    
609
    return $self;
610
}
611

            
cleanup
yuki-kimoto authored on 2010-10-17
612
sub insert {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
613
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
614
    
cleanup
Yuki Kimoto authored on 2011-10-21
615
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
616
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
617
    my %opt = @_;
micro optimization
Yuki Kimoto authored on 2011-10-23
618
    warn "insert method param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
619
    $param ||= delete $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
620
    
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
621
    # Timestamp(DEPRECATED!)
cleanup
Yuki Kimoto authored on 2011-10-21
622
    if ($opt{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
623
        warn "insert timestamp option is DEPRECATED! use created_at with now attribute";
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
624
        my $columns = $insert_timestamp->[0];
625
        $columns = [$columns] unless ref $columns eq 'ARRAY';
626
        my $value = $insert_timestamp->[1];
627
        $value = $value->() if ref $value eq 'CODE';
628
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
629
    }
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
630

            
631
    # Created time and updated time
632
    my @timestamp_cleanup;
633
    if (defined $opt{created_at} || defined $opt{updated_at}) {
- insert method created_at a...
Yuki Kimoto authored on 2011-10-27
634
        my $now = $self->now;
635
        $now = $now->() if ref $now eq 'CODE';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
636
        if (defined $opt{created_at}) {
637
            $param->{$opt{created_at}} = $now;
638
            push @timestamp_cleanup, $opt{created_at};
639
        }
640
        if (defined $opt{updated_at}) {
641
            $param->{$opt{updated_at}} = $now;
642
            push @timestamp_cleanup, $opt{updated_at};
643
        }
644
    }
cleanup
Yuki Kimoto authored on 2011-10-21
645
    
646
    # Merge id to parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
647
    my @cleanup;
micro optimization and
Yuki Kimoto authored on 2011-10-25
648
    my $id_param = {};
micro optimization
Yuki Kimoto authored on 2011-10-23
649
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
650
        croak "insert id option must be specified with primary_key option"
micro optimization
Yuki Kimoto authored on 2011-10-23
651
          unless $opt{primary_key};
652
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
653
        $opt{id} = [$opt{id}] unless ref $opt{id};
654
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
655
           my $key = $opt{primary_key}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
656
           next if exists $param->{$key};
micro optimization
Yuki Kimoto authored on 2011-10-23
657
           $param->{$key} = $opt{id}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
658
           push @cleanup, $key;
micro optimization
Yuki Kimoto authored on 2011-10-23
659
        }
660
    }
cleanup
Yuki Kimoto authored on 2011-10-21
661
    
cleanup
Yuki Kimoto authored on 2011-04-02
662
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-10-21
663
    my $sql = "insert ";
cleanup
Yuki Kimoto authored on 2011-10-21
664
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
665
    $sql .= "into " . $self->q($opt{table}) . " "
cleanup
Yuki Kimoto authored on 2011-10-21
666
      . $self->values_clause($param, {wrap => $opt{wrap}}) . " ";
micro optimization
Yuki Kimoto authored on 2011-10-23
667

            
668
    # Remove id from parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
669
    delete $param->{$_} for @cleanup;
packaging one directory
yuki-kimoto authored on 2009-11-16
670
    
671
    # Execute query
micro optimization
Yuki Kimoto authored on 2011-10-23
672
    $opt{statement} = 'insert';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
673
    $opt{cleanup} = \@timestamp_cleanup;
micro optimization
Yuki Kimoto authored on 2011-10-23
674
    $self->execute($sql, $param, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
675
}
676

            
micro optimization
Yuki Kimoto authored on 2011-10-23
677
sub _merge_id_to_param {
678
    my ($self, $id, $primary_keys, $param) = @_;
679
    
680
    # Create parameter
681
    $id = [$id] unless ref $id;
682
    
683
    return $param;
684
}
685

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
686
sub insert_timestamp {
687
    my $self = shift;
688
    
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
689
    warn "insert_timestamp method is DEPRECATED! use now attribute";
690
    
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
691
    if (@_) {
692
        $self->{insert_timestamp} = [@_];
693
        
694
        return $self;
695
    }
696
    return $self->{insert_timestamp};
697
}
698

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
699
sub include_model {
700
    my ($self, $name_space, $model_infos) = @_;
701
    
cleanup
Yuki Kimoto authored on 2011-04-02
702
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
703
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
704
    
705
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
706
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
707

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

            
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
764
sub like_value { sub { "%$_[0]%" } }
765

            
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
766
sub mapper {
767
    my $self = shift;
768
    return DBIx::Custom::Mapper->new(@_);
769
}
770

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
771
sub merge_param {
772
    my ($self, @params) = @_;
773
    
cleanup
Yuki Kimoto authored on 2011-04-02
774
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
775
    my $merge = {};
cleanup
Yuki Kimoto authored on 2011-10-21
776
    for my $param (@params) {
777
        for my $column (keys %$param) {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
778
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
779
            
780
            if (exists $merge->{$column}) {
781
                $merge->{$column} = [$merge->{$column}]
782
                  unless ref $merge->{$column} eq 'ARRAY';
783
                push @{$merge->{$column}},
784
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
785
            }
786
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
787
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
788
            }
789
        }
790
    }
791
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
792
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
793
}
794

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

            
cleanup
Yuki Kimoto authored on 2011-03-21
812
sub mycolumn {
813
    my ($self, $table, $columns) = @_;
814
    
cleanup
Yuki Kimoto authored on 2011-04-02
815
    # Create column clause
816
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
817
    $columns ||= [];
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
818
    push @column, $self->q($table) . "." . $self->q($_) .
819
      " as " . $self->q($_)
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
820
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
821
    
822
    return join (', ', @column);
823
}
824

            
added dbi_options attribute
kimoto authored on 2010-12-20
825
sub new {
826
    my $self = shift->SUPER::new(@_);
827
    
cleanup
Yuki Kimoto authored on 2011-04-02
828
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
829
    my @attrs = keys %$self;
cleanup
Yuki Kimoto authored on 2011-10-21
830
    for my $attr (@attrs) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
831
        croak qq{Invalid attribute: "$attr" } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
832
          unless $self->can($attr);
833
    }
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
834

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

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

            
855
sub order {
856
    my $self = shift;
857
    return DBIx::Custom::Order->new(dbi => $self, @_);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
858
}
859

            
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
860
sub q {
861
    my ($self, $value, $quotemeta) = @_;
862
    
863
    my $quote = $self->{reserved_word_quote}
864
      || $self->{quote} || $self->quote || '';
865
    return "$quote$value$quote"
866
      if !$quotemeta && ($quote eq '`' || $quote eq '"');
867
    
868
    my $q = substr($quote, 0, 1) || '';
869
    my $p;
870
    if (defined $quote && length $quote > 1) {
871
        $p = substr($quote, 1, 1);
872
    }
873
    else { $p = $q }
874
    
875
    if ($quotemeta) {
876
        $q = quotemeta($q);
877
        $p = quotemeta($p);
878
    }
879
    
880
    return "$q$value$p";
881
}
882

            
cleanup
yuki-kimoto authored on 2010-10-17
883
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
884
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
885
    
886
    # Register filter
887
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
888
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
889
    
cleanup
Yuki Kimoto authored on 2011-04-02
890
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
891
}
packaging one directory
yuki-kimoto authored on 2009-11-16
892

            
893
sub select {
cleanup
Yuki Kimoto authored on 2011-10-21
894
    my ($self, %opt) = @_;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
895

            
cleanup
Yuki Kimoto authored on 2011-10-21
896
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
897
    my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
898
               : defined $opt{table} ? [$opt{table}]
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
899
               : [];
cleanup
Yuki Kimoto authored on 2011-10-21
900
    $opt{table} = $tables;
cleanup
Yuki Kimoto authored on 2011-10-21
901
    my $where_param = $opt{where_param} || delete $opt{param} || {};
select method where_param op...
Yuki Kimoto authored on 2011-10-25
902
    warn "select method where_param option is DEPRECATED!"
903
      if $opt{where_param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
904
    
cleanup
Yuki Kimoto authored on 2011-03-09
905
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
906
    if ($opt{relation}) {
907
        warn "select() relation option is DEPRECATED!";
908
        $self->_add_relation_table($tables, $opt{relation});
909
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
910
    
cleanup
Yuki Kimoto authored on 2011-04-02
911
    # Select statement
micro optimization
Yuki Kimoto authored on 2011-09-30
912
    my $sql = 'select ';
packaging one directory
yuki-kimoto authored on 2009-11-16
913
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
914
    # Prefix
cleanup
Yuki Kimoto authored on 2011-10-21
915
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
916
    
cleanup
Yuki Kimoto authored on 2011-10-21
917
    # Column
cleanup
Yuki Kimoto authored on 2011-10-21
918
    if (defined $opt{column}) {
919
        my $columns
920
          = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
cleanup
Yuki Kimoto authored on 2011-10-21
921
        for my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
922
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
923
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
924
            }
925
            elsif (ref $column eq 'ARRAY') {
- insert method created_at a...
Yuki Kimoto authored on 2011-10-27
926
                warn "select column option [COLUMN => ALIAS] syntax is DEPRECATED!" .
927
                  "use q method to quote the value";
- select method column optio...
Yuki Kimoto authored on 2011-07-11
928
                if (@$column == 3 && $column->[1] eq 'as') {
929
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
930
                    splice @$column, 1, 1;
931
                }
932
                
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
933
                $column = join(' ', $column->[0], 'as', $self->q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
934
            }
cleanup
Yuki Kimoto authored on 2011-04-02
935
            unshift @$tables, @{$self->_search_tables($column)};
micro optimization
Yuki Kimoto authored on 2011-09-30
936
            $sql .= "$column, ";
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
937
        }
micro optimization
Yuki Kimoto authored on 2011-09-30
938
        $sql =~ s/, $/ /;
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
939
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
940
    else { $sql .= '* ' }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
941
    
942
    # Table
micro optimization
Yuki Kimoto authored on 2011-09-30
943
    $sql .= 'from ';
cleanup
Yuki Kimoto authored on 2011-10-21
944
    if ($opt{relation}) {
cleanup
Yuki Kimoto authored on 2011-03-30
945
        my $found = {};
cleanup
Yuki Kimoto authored on 2011-10-21
946
        for my $table (@$tables) {
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
947
            $sql .= $self->q($table) . ', ' unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
948
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
949
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
950
    }
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
951
    else { $sql .= $self->q($tables->[-1] || '') . ' ' }
micro optimization
Yuki Kimoto authored on 2011-09-30
952
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2011-10-21
953
    croak "select method table option must be specified " . _subname
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-10-26
954
      unless defined $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
955

            
cleanup
Yuki Kimoto authored on 2011-04-02
956
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
957
    unshift @$tables,
958
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
959
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
960
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
961
    my $w = $self->_where_clause_and_param($opt{where}, $where_param,
962
      delete $opt{id}, $opt{primary_key}, $tables->[-1]);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
963
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
964
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-10-21
965
    unshift @$tables, @{$self->_search_tables($w->{clause})};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
966
    
cleanup
Yuki Kimoto authored on 2011-10-21
967
    # Join statement
cleanup
Yuki Kimoto authored on 2011-10-21
968
    $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
969
    
cleanup
Yuki Kimoto authored on 2011-03-09
970
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-10-21
971
    $sql .= "$w->{clause} ";
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
972
    
cleanup
Yuki Kimoto authored on 2011-03-08
973
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
974
    $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
cleanup
Yuki Kimoto authored on 2011-10-21
975
      if $opt{relation};
cleanup
Yuki Kimoto authored on 2011-03-08
976
    
packaging one directory
yuki-kimoto authored on 2009-11-16
977
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
978
    $opt{statement} = 'select';
cleanup
Yuki Kimoto authored on 2011-10-21
979
    my $result = $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
980
    
micro optimization
Yuki Kimoto authored on 2011-10-23
981
    $result;
packaging one directory
yuki-kimoto authored on 2009-11-16
982
}
983

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

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

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

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

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

            
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1041
sub type_rule {
1042
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-23
1043

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1109
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1110
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
1111
    my %opt = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1112
    warn "update param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
1113
    warn "update method where_param option is DEPRECATED!"
1114
      if $opt{where_param};
cleanup
Yuki Kimoto authored on 2011-10-21
1115
    $param ||= $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1116
    
cleanup
Yuki Kimoto authored on 2011-10-21
1117
    # Don't allow update all rows
1118
    croak qq{update method where option must be specified } . _subname
1119
      if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1120
    
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1121
    # Timestamp(DEPRECATED!)
cleanup
Yuki Kimoto authored on 2011-10-21
1122
    if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
1123
        warn "update timestamp option is DEPRECATED! use updated_at and now method";
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1124
        my $columns = $update_timestamp->[0];
1125
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1126
        my $value = $update_timestamp->[1];
1127
        $value = $value->() if ref $value eq 'CODE';
1128
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1129
    }
1130

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1131
    # Created time and updated time
1132
    my @timestamp_cleanup;
1133
    if (defined $opt{updated_at}) {
- insert method created_at a...
Yuki Kimoto authored on 2011-10-27
1134
        my $now = $self->now;
1135
        $now = $now->() if ref $now eq 'CODE';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1136
        $param->{$opt{updated_at}} = $self->now->();
1137
        push @timestamp_cleanup, $opt{updated_at};
1138
    }
1139

            
cleanup
Yuki Kimoto authored on 2011-10-21
1140
    # Assign clause
cleanup
Yuki Kimoto authored on 2011-10-21
1141
    my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
cleanup
Yuki Kimoto authored on 2011-10-21
1142
    
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1143
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
1144
    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
1145
      delete $opt{id}, $opt{primary_key}, $opt{table});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1146
    
cleanup
Yuki Kimoto authored on 2011-04-02
1147
    # Update statement
cleanup
Yuki Kimoto authored on 2011-10-21
1148
    my $sql = "update ";
1149
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1150
    $sql .= $self->q($opt{table}) . " set $assign_clause $w->{clause} ";
cleanup
Yuki Kimoto authored on 2011-01-27
1151
    
cleanup
yuki-kimoto authored on 2010-10-17
1152
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
1153
    $opt{statement} = 'update';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1154
    $opt{cleanup} = \@timestamp_cleanup;
micro optimization and
Yuki Kimoto authored on 2011-10-25
1155
    $self->execute($sql, [$param, $w->{param}], %opt);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1156
}
1157

            
cleanup
Yuki Kimoto authored on 2011-11-01
1158
sub update_all { shift->update(@_, allow_update_all => 1) };
cleanup
yuki-kimoto authored on 2010-10-17
1159

            
cleanup
Yuki Kimoto authored on 2011-10-21
1160
sub update_or_insert {
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
1161
    my ($self, $param, %opt) = @_;
1162
    croak "update_or_insert method need primary_key and id option "
1163
      unless defined $opt{id} && defined $opt{primary_key};
1164
    my $statement_opt = $opt{option} || {};
1165
    my $row = $self->select(%opt, %{$statement_opt->{select} || {}})->one;
1166
    return $row ? $self->update($param, %opt, %{$statement_opt->{update} || {}})
1167
                : $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
cleanup
Yuki Kimoto authored on 2011-10-21
1168
}
1169

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1170
sub update_timestamp {
1171
    my $self = shift;
1172
    
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
1173
    warn "update_timestamp method is DEPRECATED! use now method";
1174
    
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1175
    if (@_) {
1176
        $self->{update_timestamp} = [@_];
1177
        
1178
        return $self;
1179
    }
1180
    return $self->{update_timestamp};
1181
}
1182

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1183
sub values_clause {
1184
    my ($self, $param, $opts) = @_;
1185
    
1186
    my $wrap = $opts->{wrap} || {};
1187
    
1188
    # Create insert parameter tag
micro optimization
Yuki Kimoto authored on 2011-10-23
1189
    my $safety = $self->{safety_character} || $self->safety_character;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1190
    my $qp = $self->q('');
fixed some quoted bug
Yuki Kimoto authored on 2011-10-22
1191
    my $q = substr($qp, 0, 1) || '';
1192
    my $p = substr($qp, 1, 1) || '';
improved performance
Yuki Kimoto authored on 2011-10-22
1193
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1194
    # Check unsafety keys
1195
    unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
1196
        for my $column (keys %$param) {
1197
            croak qq{"$column" is not safety column name } . _subname
1198
              unless $column =~ /^[$safety\.]+$/;
1199
        }
1200
    }
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1201
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1202
    # values clause(performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
1203
    '(' .
1204
    join(
1205
      ', ',
1206
      map { "$q$_$p" } sort keys %$param
1207
    ) .
1208
    ') values (' .
1209
    join(
1210
      ', ',
1211
      map {
1212
          ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1213
          $wrap->{$_} ? $wrap->{$_}->(":$_") :
1214
          ":$_";
1215
      } sort keys %$param
1216
    ) .
1217
    ')'
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1218
}
1219

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1222
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1223
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1224
    my ($self, $source, $after_build_sql) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1225
    
updated pod
Yuki Kimoto authored on 2011-06-21
1226
    # Cache
1227
    my $cache = $self->cache;
1228
    
1229
    # Query
1230
    my $query;
1231
    
1232
    # Get cached query
1233
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1234
        
updated pod
Yuki Kimoto authored on 2011-06-21
1235
        # Get query
1236
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1237
        
updated pod
Yuki Kimoto authored on 2011-06-21
1238
        # Create query
1239
        if ($q) {
1240
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1241
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1242
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1243
    }
1244
    
1245
    # Create query
1246
    unless ($query) {
1247

            
1248
        # Create query
1249
        my $builder = $self->query_builder;
1250
        $query = $builder->build_query($source);
1251

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

            
1258
        # Save query to cache
1259
        $self->cache_method->(
1260
            $self, $source,
1261
            {
1262
                sql     => $query->sql, 
1263
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1264
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1265
            }
1266
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1267
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1268

            
1269
    # Filter SQL
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1270
    if ($after_build_sql) {
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1271
        my $sql = $query->sql;
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1272
        $sql = $after_build_sql->($sql);
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1273
        $query->sql($sql);
1274
    }
1275
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1276
    # Save sql
1277
    $self->last_sql($query->sql);
1278
    
updated pod
Yuki Kimoto authored on 2011-06-21
1279
    # Prepare statement handle
1280
    my $sth;
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1281
    eval { $sth = $self->dbh->prepare($query->{sql}) };
updated pod
Yuki Kimoto authored on 2011-06-21
1282
    
1283
    if ($@) {
1284
        $self->_croak($@, qq{. Following SQL is executed.\n}
1285
                        . qq{$query->{sql}\n} . _subname);
1286
    }
1287
    
1288
    # Set statement handle
1289
    $query->sth($sth);
1290
    
1291
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1292
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1293
    
1294
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1295
}
1296

            
cleanup
Yuki Kimoto authored on 2011-04-02
1297
sub _create_bind_values {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1298
    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1299
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1300
    $bind_type = _array_to_hash($bind_type) if ref $bind_type eq 'ARRAY';
1301
    
cleanup
Yuki Kimoto authored on 2011-04-02
1302
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
1303
    my @bind;
1304
    my @types;
1305
    my %count;
1306
    my %not_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1307
    for my $column (@$columns) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
1308
        
micro optimization
Yuki Kimoto authored on 2011-10-23
1309
        # Bind value
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1310
        if(ref $params->{$column} eq 'ARRAY') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1311
            my $i = $count{$column} || 0;
1312
            $i += $not_exists{$column} || 0;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1313
            my $found;
1314
            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1315
                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1316
                    $not_exists{$column}++;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1317
                }
1318
                else  {
micro optimization
Yuki Kimoto authored on 2011-10-23
1319
                    push @bind, $params->{$column}->[$k];
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1320
                    $found = 1;
1321
                    last
1322
                }
1323
            }
1324
            next unless $found;
1325
        }
micro optimization
Yuki Kimoto authored on 2011-10-23
1326
        else { push @bind, $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1327
        
cleanup
Yuki Kimoto authored on 2011-01-12
1328
        # Filter
micro optimization
Yuki Kimoto authored on 2011-10-23
1329
        if (my $f = $filter->{$column} || $self->{default_out_filter} || '') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1330
            $bind[-1] = $f->($bind[-1]);
micro optimization
Yuki Kimoto authored on 2011-10-23
1331
        }
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1332
        
1333
        # Type rule
micro optimization
Yuki Kimoto authored on 2011-10-23
1334
        if ($self->{_type_rule_is_called}) {
1335
            my $tf1 = $self->{"_into1"}->{dot}->{$column}
1336
              || $type_filters->{1}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1337
            $bind[-1] = $tf1->($bind[-1]) if $tf1;
micro optimization
Yuki Kimoto authored on 2011-10-23
1338
            my $tf2 = $self->{"_into2"}->{dot}->{$column}
1339
              || $type_filters->{2}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1340
            $bind[-1] = $tf2->($bind[-1]) if $tf2;
micro optimization
Yuki Kimoto authored on 2011-10-23
1341
        }
micro optimization
Yuki Kimoto authored on 2011-10-22
1342
       
micro optimization
Yuki Kimoto authored on 2011-10-23
1343
        # Bind types
micro optimization
Yuki Kimoto authored on 2011-10-23
1344
        push @types, $bind_type->{$column};
removed reconnect method
yuki-kimoto authored on 2010-05-28
1345
        
1346
        # Count up 
micro optimization
Yuki Kimoto authored on 2011-10-23
1347
        $count{$column}++;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1348
    }
1349
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1350
    return (\@bind, \@types);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1351
}
1352

            
cleanup
Yuki Kimoto authored on 2011-10-21
1353
sub _id_to_param {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1354
    my ($self, $id, $primary_keys, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1355
    
1356
    # Check primary key
cleanup
Yuki Kimoto authored on 2011-10-21
1357
    croak "primary_key option " .
1358
          "must be specified with id option " . _subname
1359
      unless defined $primary_keys;
1360
    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
improved error messages
Yuki Kimoto authored on 2011-04-18
1361
    
cleanup
Yuki Kimoto authored on 2011-06-08
1362
    # Create parameter
1363
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1364
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1365
        $id = [$id] unless ref $id;
1366
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1367
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1368
          unless !ref $id || ref $id eq 'ARRAY';
1369
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1370
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1371
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1372
        for(my $i = 0; $i < @$primary_keys; $i ++) {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1373
           my $key = $primary_keys->[$i];
1374
           $key = "$table." . $key if $table;
1375
           $param->{$key} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1376
        }
1377
    }
1378
    
cleanup
Yuki Kimoto authored on 2011-06-08
1379
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1380
}
1381

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1382
sub _connect {
1383
    my $self = shift;
1384
    
1385
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1386
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1387
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1388
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1389
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1390
    croak qq{"dsn" must be specified } . _subname
1391
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1392
    my $user        = $self->user;
1393
    my $password    = $self->password;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1394
    my $option = $self->_option;
1395
    $option = {%{$self->default_option}, %$option};
cleanup
Yuki Kimoto authored on 2011-08-16
1396
    
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1397
    # Connect
cleanup
Yuki Kimoto authored on 2011-08-16
1398
    my $dbh;
1399
    eval {
1400
        $dbh = DBI->connect(
1401
            $dsn,
1402
            $user,
1403
            $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1404
            $option
cleanup
Yuki Kimoto authored on 2011-08-16
1405
        );
1406
    };
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1407
    
1408
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1409
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1410
    
1411
    return $dbh;
1412
}
1413

            
cleanup
yuki-kimoto authored on 2010-10-17
1414
sub _croak {
1415
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1416
    
1417
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1418
    $append ||= "";
1419
    
1420
    # Verbose
1421
    if ($Carp::Verbose) { croak $error }
1422
    
1423
    # Not verbose
1424
    else {
1425
        
1426
        # Remove line and module infromation
1427
        my $at_pos = rindex($error, ' at ');
1428
        $error = substr($error, 0, $at_pos);
1429
        $error =~ s/\s+$//;
1430
        croak "$error$append";
1431
    }
1432
}
1433

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1436
sub _need_tables {
1437
    my ($self, $tree, $need_tables, $tables) = @_;
1438
    
cleanup
Yuki Kimoto authored on 2011-04-02
1439
    # Get needed tables
cleanup
Yuki Kimoto authored on 2011-10-21
1440
    for my $table (@$tables) {
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1441
        if ($tree->{$table}) {
1442
            $need_tables->{$table} = 1;
1443
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1444
        }
1445
    }
1446
}
1447

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1448
sub _option {
1449
    my $self = shift;
1450
    my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1451
    warn "dbi_options is DEPRECATED! use option instead\n"
1452
      if keys %{$self->dbi_options};
1453
    warn "dbi_option is DEPRECATED! use option instead\n"
1454
      if keys %{$self->dbi_option};
1455
    return $option;
1456
}
1457

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1458
sub _push_join {
1459
    my ($self, $sql, $join, $join_tables) = @_;
1460
    
cleanup
Yuki Kimoto authored on 2011-10-21
1461
    $join = [$join] unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-10-21
1462
    
cleanup
Yuki Kimoto authored on 2011-04-02
1463
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1464
    return unless @$join;
1465
    
cleanup
Yuki Kimoto authored on 2011-04-02
1466
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1467
    my $tree = {};
1468
    for (my $i = 0; $i < @$join; $i++) {
1469
        
cleanup
Yuki Kimoto authored on 2011-07-28
1470
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1471
        my $join_clause;;
1472
        my $option;
1473
        if (ref $join->[$i] eq 'HASH') {
1474
            $join_clause = $join->[$i]->{clause};
1475
            $option = {table => $join->[$i]->{table}};
1476
        }
1477
        else {
1478
            $join_clause = $join->[$i];
1479
            $option = {};
1480
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1481

            
1482
        # Find tables in join clause
added join new syntax
Yuki Kimoto authored on 2011-07-28
1483
        my $table1;
1484
        my $table2;
1485
        if (my $table = $option->{table}) {
1486
            $table1 = $table->[0];
1487
            $table2 = $table->[1];
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1488
        }
cleanup
Yuki Kimoto authored on 2011-07-28
1489
        else {
1490
            my $q = $self->_quote;
1491
            my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1492
            $j_clause =~ s/'.+?'//g;
1493
            my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1494
            $j_clause =~ s/[$q_re]//g;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1495
            
1496
            my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
cleanup
Yuki Kimoto authored on 2011-07-28
1497
            my $c = $self->safety_character;
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1498
            my $join_re = qr/($c+)\.$c+[^$c].*?($c+)\.$c+/sm;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1499
            for my $clause (@j_clauses) {
1500
                if ($clause =~ $join_re) {
1501
                    $table1 = $1;
1502
                    $table2 = $2;
1503
                    last;
1504
                }                
cleanup
Yuki Kimoto authored on 2011-07-28
1505
            }
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1506
        }
added join new syntax
Yuki Kimoto authored on 2011-07-28
1507
        croak qq{join clause must have two table name after "on" keyword. } .
1508
              qq{"$join_clause" is passed }  . _subname
1509
          unless defined $table1 && defined $table2;
1510
        croak qq{right side table of "$join_clause" must be unique }
1511
            . _subname
1512
          if exists $tree->{$table2};
1513
        croak qq{Same table "$table1" is specified} . _subname
1514
          if $table1 eq $table2;
1515
        $tree->{$table2}
1516
          = {position => $i, parent => $table1, join => $join_clause};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1517
    }
1518
    
cleanup
Yuki Kimoto authored on 2011-04-02
1519
    # Search need tables
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1520
    my $need_tables = {};
1521
    $self->_need_tables($tree, $need_tables, $join_tables);
cleanup
Yuki Kimoto authored on 2011-10-21
1522
    my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} }
1523
      keys %$need_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1524
    
1525
    # Add join clause
cleanup
Yuki Kimoto authored on 2011-10-21
1526
    $$sql .= $tree->{$_}{join} . ' ' for @need_tables;
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1527
}
cleanup
Yuki Kimoto authored on 2011-03-08
1528

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1529
sub _quote {
1530
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-22
1531
    return $self->{reserved_word_quote} || $self->quote || '';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1532
}
1533

            
cleanup
Yuki Kimoto authored on 2011-04-02
1534
sub _remove_duplicate_table {
1535
    my ($self, $tables, $main_table) = @_;
1536
    
1537
    # Remove duplicate table
1538
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1539
    delete $tables{$main_table} if $main_table;
1540
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1541
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1542
    if (my $q = $self->_quote) {
1543
        $q = quotemeta($q);
1544
        $_ =~ s/[$q]//g for @$new_tables;
1545
    }
1546

            
1547
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1548
}
1549

            
cleanup
Yuki Kimoto authored on 2011-04-02
1550
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1551
    my ($self, $source) = @_;
1552
    
cleanup
Yuki Kimoto authored on 2011-04-02
1553
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1554
    my $tables = [];
1555
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1556
    my $q = $self->_quote;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1557
    my $quoted_safety_character_re = $self->q("?([$safety_character]+)", 1);
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1558
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1559
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1560
    while ($source =~ /$table_re/g) {
1561
        push @$tables, $1;
1562
    }
1563
    
1564
    return $tables;
1565
}
1566

            
cleanup
Yuki Kimoto authored on 2011-10-21
1567
sub _where_clause_and_param {
cleanup
Yuki Kimoto authored on 2011-10-25
1568
    my ($self, $where, $where_param, $id, $primary_key, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-25
1569

            
cleanup
Yuki Kimoto authored on 2011-10-21
1570
    $where ||= {};
cleanup
Yuki Kimoto authored on 2011-10-25
1571
    $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
cleanup
Yuki Kimoto authored on 2011-10-25
1572
    $where_param ||= {};
cleanup
Yuki Kimoto authored on 2011-10-21
1573
    my $w = {};
1574
    my $where_clause = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1575

            
cleanup
Yuki Kimoto authored on 2011-10-25
1576
    my $obj;
1577
    
cleanup
Yuki Kimoto authored on 2011-10-21
1578
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1579
        $w->{clause} = "where " . $where->[0];
1580
        $w->{param} = $where->[1];
1581
    }
1582
    elsif (ref $where) {
cleanup
Yuki Kimoto authored on 2011-10-25
1583

            
1584
        if (ref $where eq 'HASH') {
1585
            my $clause = ['and'];
cleanup
Yuki Kimoto authored on 2011-11-01
1586
            my $column_join = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1587
            for my $column (keys %$where) {
cleanup
Yuki Kimoto authored on 2011-11-01
1588
                $column_join .= $column;
cleanup
Yuki Kimoto authored on 2011-10-25
1589
                my $table;
1590
                my $c;
1591
                if ($column =~ /(?:(.*?)\.)?(.*)/) {
1592
                    $table = $1;
1593
                    $c = $2;
1594
                }
1595
                
1596
                my $table_quote;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1597
                $table_quote = $self->q($table) if defined $table;
1598
                my $column_quote = $self->q($c);
cleanup
Yuki Kimoto authored on 2011-10-25
1599
                $column_quote = $table_quote . '.' . $column_quote
1600
                  if defined $table_quote;
cleanup
Yuki Kimoto authored on 2011-11-01
1601
                push @$clause, "$column_quote = :$column";
cleanup
Yuki Kimoto authored on 2011-10-25
1602
            }
cleanup
Yuki Kimoto authored on 2011-11-01
1603

            
1604
            # Check unsafety column
1605
            my $safety = $self->safety_character;
1606
            unless ($column_join =~ /^[$safety\.]+$/) {
1607
                for my $column (keys %$where) {
1608
                    croak qq{"$column" is not safety column name } . _subname
1609
                      unless $column =~ /^[$safety\.]+$/;
1610
                }
1611
            }
1612
            
cleanup
Yuki Kimoto authored on 2011-10-25
1613
            $obj = $self->where(clause => $clause, param => $where);
1614
        }
cleanup
Yuki Kimoto authored on 2011-11-01
1615
        elsif (ref $where eq 'DBIx::Custom::Where') { $obj = $where }
cleanup
Yuki Kimoto authored on 2011-10-25
1616
        elsif (ref $where eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-11-01
1617
            $obj = $self->where(clause => $where->[0], param => $where->[1]);
cleanup
Yuki Kimoto authored on 2011-10-25
1618
        }
1619
        
1620
        # Check where argument
1621
        croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1622
            . qq{or array reference, which contains where clause and parameter}
1623
            . _subname
1624
          unless ref $obj eq 'DBIx::Custom::Where';
1625

            
1626
        $w->{param} = keys %$where_param
1627
                    ? $self->merge_param($where_param, $obj->param)
1628
                    : $obj->param;
1629
        $w->{clause} = $obj->to_string;
cleanup
Yuki Kimoto authored on 2011-10-21
1630
    }
1631
    elsif ($where) {
1632
        $w->{clause} = "where $where";
cleanup
Yuki Kimoto authored on 2011-10-25
1633
        $w->{param} = $where_param;
cleanup
Yuki Kimoto authored on 2011-10-21
1634
    }
1635
    
1636
    return $w;
1637
}
1638

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

            
1642
    # Initialize filters
1643
    $self->{filter} ||= {};
micro optimization
Yuki Kimoto authored on 2011-07-30
1644
    $self->{filter}{on} = 1;
updated pod
Yuki Kimoto authored on 2011-06-21
1645
    $self->{filter}{out} ||= {};
1646
    $self->{filter}{in} ||= {};
1647
    $self->{filter}{end} ||= {};
1648
    
1649
    # Usage
1650
    my $usage = "Usage: \$dbi->apply_filter(" .
1651
                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1652
                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1653
    
1654
    # Apply filter
1655
    for (my $i = 0; $i < @cinfos; $i += 2) {
1656
        
1657
        # Column
1658
        my $column = $cinfos[$i];
1659
        if (ref $column eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-10-21
1660
            for my $c (@$column) {
updated pod
Yuki Kimoto authored on 2011-06-21
1661
                push @cinfos, $c, $cinfos[$i + 1];
1662
            }
1663
            next;
1664
        }
1665
        
1666
        # Filter infomation
1667
        my $finfo = $cinfos[$i + 1] || {};
1668
        croak "$usage (table: $table) " . _subname
1669
          unless  ref $finfo eq 'HASH';
cleanup
Yuki Kimoto authored on 2011-10-21
1670
        for my $ftype (keys %$finfo) {
updated pod
Yuki Kimoto authored on 2011-06-21
1671
            croak "$usage (table: $table) " . _subname
1672
              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1673
        }
1674
        
1675
        # Set filters
cleanup
Yuki Kimoto authored on 2011-10-21
1676
        for my $way (qw/in out end/) {
updated pod
Yuki Kimoto authored on 2011-06-21
1677
        
1678
            # Filter
1679
            my $filter = $finfo->{$way};
1680
            
1681
            # Filter state
1682
            my $state = !exists $finfo->{$way} ? 'not_exists'
1683
                      : !defined $filter        ? 'not_defined'
1684
                      : ref $filter eq 'CODE'   ? 'code'
1685
                      : 'name';
1686
            
1687
            # Filter is not exists
1688
            next if $state eq 'not_exists';
1689
            
1690
            # Check filter name
1691
            croak qq{Filter "$filter" is not registered } . _subname
1692
              if  $state eq 'name'
1693
               && ! exists $self->filters->{$filter};
1694
            
1695
            # Set filter
1696
            my $f = $state eq 'not_defined' ? undef
1697
                  : $state eq 'code'        ? $filter
1698
                  : $self->filters->{$filter};
1699
            $self->{filter}{$way}{$table}{$column} = $f;
1700
            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1701
            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1702
            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1703
        }
1704
    }
1705
    
1706
    return $self;
1707
}
1708

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1709
# DEPRECATED!
1710
has 'data_source';
1711
has dbi_options => sub { {} };
1712
has filter_check  => 1;
1713
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1714
has dbi_option => sub { {} };
1715
has default_dbi_option => sub {
1716
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1717
    return shift->default_option;
1718
};
1719

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1720
# DEPRECATED!
1721
sub method {
1722
    warn "method is DEPRECATED! use helper instead";
1723
    return shift->helper(@_);
1724
}
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1725

            
1726
# DEPRECATED!
1727
sub assign_param {
1728
    my $self = shift;
1729
    warn "assing_param is DEPRECATED! use assign_clause instead";
1730
    return $self->assign_clause(@_);
1731
}
1732

            
1733
# DEPRECATED
1734
sub update_param {
1735
    my ($self, $param, $opts) = @_;
1736
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1737
    warn "update_param is DEPRECATED! use assign_clause instead.";
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1738
    
1739
    # Create update parameter tag
1740
    my $tag = $self->assign_clause($param, $opts);
1741
    $tag = "set $tag" unless $opts->{no_set};
1742

            
1743
    return $tag;
1744
}
1745

            
updated pod
Yuki Kimoto authored on 2011-06-21
1746
# DEPRECATED!
1747
sub create_query {
1748
    warn "create_query is DEPRECATED! use query option of each method";
1749
    shift->_create_query(@_);
1750
}
1751

            
cleanup
Yuki Kimoto authored on 2011-06-13
1752
# DEPRECATED!
1753
sub apply_filter {
1754
    my $self = shift;
1755
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1756
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1757
    return $self->_apply_filter(@_);
1758
}
1759

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1760
# DEPRECATED!
1761
sub select_at {
cleanup
Yuki Kimoto authored on 2011-10-21
1762
    my ($self, %opt) = @_;
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1763

            
cleanup
Yuki Kimoto authored on 2011-10-21
1764
    warn "select_at is DEPRECATED! use select method id option instead";
updated pod
Yuki Kimoto authored on 2011-06-08
1765

            
cleanup
Yuki Kimoto authored on 2011-10-21
1766
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1767
    my $primary_keys = delete $opt{primary_key};
1768
    my $where = delete $opt{where};
1769
    my $param = delete $opt{param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1770
    
1771
    # Table
1772
    croak qq{"table" option must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1773
      unless $opt{table};
1774
    my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1775
    
1776
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1777
    my $where_param = $self->_id_to_param($where, $primary_keys);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1778
    
cleanup
Yuki Kimoto authored on 2011-10-21
1779
    return $self->select(where => $where_param, %opt);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1780
}
1781

            
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1782
# DEPRECATED!
1783
sub delete_at {
cleanup
Yuki Kimoto authored on 2011-10-21
1784
    my ($self, %opt) = @_;
updated pod
Yuki Kimoto authored on 2011-06-08
1785

            
cleanup
Yuki Kimoto authored on 2011-10-21
1786
    warn "delete_at is DEPRECATED! use delete method id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1787
    
cleanup
Yuki Kimoto authored on 2011-10-21
1788
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1789
    my $primary_keys = delete $opt{primary_key};
1790
    my $where = delete $opt{where};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1791
    
1792
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1793
    my $where_param = $self->_id_to_param($where, $primary_keys);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1794
    
cleanup
Yuki Kimoto authored on 2011-10-21
1795
    return $self->delete(where => $where_param, %opt);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1796
}
1797

            
cleanup
Yuki Kimoto authored on 2011-06-08
1798
# DEPRECATED!
1799
sub update_at {
1800
    my $self = shift;
1801

            
cleanup
Yuki Kimoto authored on 2011-10-21
1802
    warn "update_at is DEPRECATED! use update method id option instead";
cleanup
Yuki Kimoto authored on 2011-06-08
1803
    
cleanup
Yuki Kimoto authored on 2011-10-21
1804
    # Options
cleanup
Yuki Kimoto authored on 2011-06-08
1805
    my $param;
1806
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1807
    my %opt = @_;
1808
    my $primary_keys = delete $opt{primary_key};
1809
    my $where = delete $opt{where};
1810
    my $p = delete $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-06-08
1811
    $param  ||= $p;
1812
    
1813
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1814
    my $where_param = $self->_id_to_param($where, $primary_keys);
cleanup
Yuki Kimoto authored on 2011-06-08
1815
    
cleanup
Yuki Kimoto authored on 2011-10-21
1816
    return $self->update(where => $where_param, param => $param, %opt);
cleanup
Yuki Kimoto authored on 2011-06-08
1817
}
1818

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1819
# DEPRECATED!
1820
sub insert_at {
1821
    my $self = shift;
1822
    
cleanup
Yuki Kimoto authored on 2011-10-21
1823
    warn "insert_at is DEPRECATED! use insert method id option instead";
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1824
    
cleanup
Yuki Kimoto authored on 2011-10-21
1825
    # Options
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1826
    my $param;
1827
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1828
    my %opt = @_;
1829
    my $primary_key = delete $opt{primary_key};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1830
    $primary_key = [$primary_key] unless ref $primary_key;
cleanup
Yuki Kimoto authored on 2011-10-21
1831
    my $where = delete $opt{where};
1832
    my $p = delete $opt{param} || {};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1833
    $param  ||= $p;
1834
    
1835
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1836
    my $where_param = $self->_id_to_param($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1837
    $param = $self->merge_param($where_param, $param);
1838
    
cleanup
Yuki Kimoto authored on 2011-10-21
1839
    return $self->insert(param => $param, %opt);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1840
}
1841

            
added warnings
Yuki Kimoto authored on 2011-06-07
1842
# DEPRECATED!
1843
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1844
    my $self = shift;
1845
    
added warnings
Yuki Kimoto authored on 2011-06-07
1846
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1847
    
1848
    # Merge tag
1849
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1850
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1851
    
1852
    return $self;
1853
}
1854

            
1855
# DEPRECATED!
1856
sub register_tag_processor {
1857
    my $self = shift;
1858
    warn "register_tag_processor is DEPRECATED!";
1859
    # Merge tag
1860
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1861
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1862
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1863
}
1864

            
cleanup
Yuki Kimoto authored on 2011-01-25
1865
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1866
sub default_bind_filter {
1867
    my $self = shift;
1868
    
cleanup
Yuki Kimoto authored on 2011-06-13
1869
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1870
    
cleanup
Yuki Kimoto authored on 2011-01-12
1871
    if (@_) {
1872
        my $fname = $_[0];
1873
        
1874
        if (@_ && !$fname) {
1875
            $self->{default_out_filter} = undef;
1876
        }
1877
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1878
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1879
              unless exists $self->filters->{$fname};
1880
        
1881
            $self->{default_out_filter} = $self->filters->{$fname};
1882
        }
1883
        return $self;
1884
    }
1885
    
1886
    return $self->{default_out_filter};
1887
}
1888

            
cleanup
Yuki Kimoto authored on 2011-01-25
1889
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1890
sub default_fetch_filter {
1891
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1892

            
cleanup
Yuki Kimoto authored on 2011-06-13
1893
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1894
    
1895
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1896
        my $fname = $_[0];
1897

            
cleanup
Yuki Kimoto authored on 2011-01-12
1898
        if (@_ && !$fname) {
1899
            $self->{default_in_filter} = undef;
1900
        }
1901
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1902
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1903
              unless exists $self->filters->{$fname};
1904
        
1905
            $self->{default_in_filter} = $self->filters->{$fname};
1906
        }
1907
        
1908
        return $self;
1909
    }
1910
    
many changed
Yuki Kimoto authored on 2011-01-23
1911
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1912
}
1913

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1914
# DEPRECATED!
1915
sub insert_param {
1916
    my $self = shift;
1917
    warn "insert_param is DEPRECATED! use values_clause instead";
1918
    return $self->values_clause(@_);
1919
}
1920

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1921
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1922
sub insert_param_tag {
1923
    warn "insert_param_tag is DEPRECATED! " .
1924
         "use insert_param instead!";
1925
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1926
}
1927

            
1928
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1929
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1930
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1931
         "use update_param instead";
1932
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1933
}
cleanup
Yuki Kimoto authored on 2011-03-08
1934
# DEPRECATED!
1935
sub _push_relation {
1936
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1937
    
1938
    if (keys %{$relation || {}}) {
micro optimization
Yuki Kimoto authored on 2011-09-30
1939
        $$sql .= $need_where ? 'where ' : 'and ';
cleanup
Yuki Kimoto authored on 2011-10-21
1940
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1941
            my $table1 = (split (/\./, $rcolumn))[0];
1942
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1943
            push @$tables, ($table1, $table2);
micro optimization
Yuki Kimoto authored on 2011-09-30
1944
            $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
cleanup
Yuki Kimoto authored on 2011-03-08
1945
        }
1946
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
1947
    $$sql =~ s/and $/ /;
cleanup
Yuki Kimoto authored on 2011-03-08
1948
}
1949

            
1950
# DEPRECATED!
1951
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1952
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1953
    
1954
    if (keys %{$relation || {}}) {
cleanup
Yuki Kimoto authored on 2011-10-21
1955
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1956
            my $table1 = (split (/\./, $rcolumn))[0];
1957
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1958
            my $table1_exists;
1959
            my $table2_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1960
            for my $table (@$tables) {
cleanup
Yuki Kimoto authored on 2011-03-08
1961
                $table1_exists = 1 if $table eq $table1;
1962
                $table2_exists = 1 if $table eq $table2;
1963
            }
1964
            unshift @$tables, $table1 unless $table1_exists;
1965
            unshift @$tables, $table2 unless $table2_exists;
1966
        }
1967
    }
1968
}
1969

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1972
=head1 NAME
1973

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
1974
DBIx::Custom - DBI extension to execute insert, update, delete, and select easily
removed reconnect method
yuki-kimoto authored on 2010-05-28
1975

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

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1978
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1979
    
1980
    # Connect
1981
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1982
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1983
        user => 'ken',
1984
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1985
        option => {mysql_enable_utf8 => 1}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1986
    );
cleanup
yuki-kimoto authored on 2010-08-05
1987

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1988
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1989
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1990
    
1991
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
1992
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
1993
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1994
    
1995
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
1996
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
1997

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2002
    # Select, more complex
2003
    my $result = $dbi->select(
2004
        table  => 'book',
2005
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
2006
            {book => [qw/title author/]},
2007
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2008
        ],
2009
        where  => {'book.author' => 'Ken'},
2010
        join => ['left outer join company on book.company_id = company.id'],
2011
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
2012
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2013
    
removed register_format()
yuki-kimoto authored on 2010-05-26
2014
    # Fetch
2015
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2016
        
removed register_format()
yuki-kimoto authored on 2010-05-26
2017
    }
2018
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2019
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
2020
    while (my $row = $result->fetch_hash) {
2021
        
2022
    }
2023
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2024
    # Execute SQL with parameter.
2025
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2026
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
2027
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2028
    );
2029
    
fix heading typos
Terrence Brannon authored on 2011-08-17
2030
=head1 DESCRIPTION
removed reconnect method
yuki-kimoto authored on 2010-05-28
2031

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2047
Named place holder support
2048

            
2049
=item *
2050

            
cleanup
Yuki Kimoto authored on 2011-07-29
2051
Model support
2052

            
2053
=item *
2054

            
2055
Connection manager support
2056

            
2057
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2058

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

            
2063
=item *
2064

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

            
2067
=item *
2068

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

            
2071
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2072

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2080
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2081
L<DBIx::Custom::Result>,
2082
L<DBIx::Custom::Query>,
2083
L<DBIx::Custom::Where>,
2084
L<DBIx::Custom::Model>,
2085
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2086

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

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

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

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

            
2097
This is L<DBIx::Connector> example. Please pass
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2098
C<default_option> to L<DBIx::Connector> C<new> method.
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2099

            
2100
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2101
        "dbi:mysql:database=$database",
2102
        $user,
2103
        $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2104
        DBIx::Custom->new->default_option
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2105
    );
2106
    
updated pod
Yuki Kimoto authored on 2011-06-21
2107
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2108

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

            
2112
    my $dbi = DBIx::Custom->connect(
2113
      dsn => $dsn, user => $user, password => $password, connector => 1);
2114
    
2115
    my $connector = $dbi->connector; # DBIx::Connector
2116

            
2117
Note that L<DBIx::Connector> must be installed.
2118

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

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

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

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2126
=head2 C<default_option>
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
2127

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2128
    my $default_option = $dbi->default_option;
2129
    $dbi = $dbi->default_option($default_option);
add default_dbi_option()
Yuki Kimoto authored on 2011-02-19
2130

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2134
    {
2135
        RaiseError => 1,
2136
        PrintError => 0,
2137
        AutoCommit => 1,
2138
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2139

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2140
=head2 C<exclude_table>
2141

            
2142
    my $exclude_table = $dbi->exclude_table;
2143
    $dbi = $dbi->exclude_table(qr/pg_/);
2144

            
2145
Excluded table regex.
2146
C<each_column>, C<each_table>, C<type_rule>,
2147
and C<setup_model> methods ignore matching tables.
2148

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

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

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

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

            
2158
    my $last_sql = $dbi->last_sql;
2159
    $dbi = $dbi->last_sql($last_sql);
2160

            
2161
Get last successed SQL executed by C<execute> method.
2162

            
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2163
=head2 C<now EXPERIMENTAL>
2164

            
2165
    my $now = $dbi->now;
2166
    $dbi = $dbi->now($now);
2167

            
2168
Code reference which return time now, default to the following code reference.
2169

            
2170
    sub {
2171
        my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2172
        $mon++;
2173
        $year += 1900;
2174
        return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2175
    }
2176

            
2177
This return the time like "2011-10-14 05:05:27".
2178

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

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

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2186
=head2 C<option>
2187

            
2188
    my $option = $dbi->option;
2189
    $dbi = $dbi->option($option);
2190

            
2191
L<DBI> option, used when C<connect> method is executed.
2192
Each value in option override the value of C<default_option>.
2193

            
cleanup
yuki-kimoto authored on 2010-10-17
2194
=head2 C<password>
2195

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2216
You can set quote pair.
2217

            
2218
    $dbi->quote('[]');
2219

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2229
    my $safety_character = $dbi->safety_character;
2230
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2231

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2237
    my $separator = $dbi->separator;
2238
    $dbi = $dbi->separator('-');
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
2239

            
2240
Separator which join table name and column name.
2241
This have effect to C<column> and C<mycolumn> method,
2242
and C<select> method's column option.
cleanup test
Yuki Kimoto authored on 2011-08-10
2243

            
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
2244
Default to C<.>.
cleanup test
Yuki Kimoto authored on 2011-08-10
2245

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

            
2248
    my $tag_parse = $dbi->tag_parse(0);
2249
    $dbi = $dbi->tag_parse;
2250

            
2251
Enable DEPRECATED tag parsing functionality, default to 1.
2252
If you want to disable tag parsing functionality, set to 0.
2253

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

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

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

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

            
2263
    my $user_column_info = $dbi->user_column_info;
2264
    $dbi = $dbi->user_column_info($user_column_info);
2265

            
improved join clause parsing
Yuki Kimoto authored on 2011-09-30
2266
You can set the date like the following one.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2267

            
2268
    [
2269
        {table => 'book', column => 'title', info => {...}},
2270
        {table => 'author', column => 'name', info => {...}}
2271
    ]
2272

            
improved join clause parsing
Yuki Kimoto authored on 2011-09-30
2273
Usually, you set return value of C<get_column_info>.
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2274

            
2275
    my $user_column_info
2276
      = $dbi->get_column_info(exclude_table => qr/^system/);
2277
    $dbi->user_column_info($user_column_info);
2278

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

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

            
2284
    my $user_table_info = $dbi->user_table_info;
2285
    $dbi = $dbi->user_table_info($user_table_info);
2286

            
2287
You can set the following data.
2288

            
2289
    [
2290
        {table => 'book', info => {...}},
2291
        {table => 'author', info => {...}}
2292
    ]
2293

            
2294
Usually, you can set return value of C<get_table_info>.
2295

            
2296
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2297
    $dbi->user_table_info($user_table_info);
2298

            
2299
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2300
to find table info.
2301

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

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

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

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

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

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

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2322
=head2 C<assign_clause>
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2323

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2324
    my $assign_clause = $dbi->assign_clause({title => 'a', age => 2});
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2325

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2326
Create assign clause
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2327

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2330
This is used to create update clause.
2331

            
2332
    "update book set " . $dbi->assign_clause({title => 'a', age => 2});
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
2333

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

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

            
2338
Create column clause. The follwoing column clause is created.
2339

            
2340
    book.author as "book.author",
2341
    book.title as "book.title"
2342

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2345
    # Separator is hyphen
2346
    $dbi->separator('-');
2347
    
2348
    book.author as "book-author",
2349
    book.title as "book-title"
2350
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2351
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2352

            
update pod
Yuki Kimoto authored on 2011-03-13
2353
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2354
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2355
        user => 'ken',
2356
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2357
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2358
    );
2359

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

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

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

            
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
2368
    my $count = $dbi->count(table => 'book');
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
2369

            
2370
Get rows count.
2371

            
2372
Options is same as C<select> method's ones.
2373

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2376
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2377
        table => 'book',
2378
        primary_key => 'id',
2379
        join => [
2380
            'inner join company on book.comparny_id = company.id'
2381
        ],
2382
    );
2383

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

            
2387
   $dbi->model('book')->select(...);
2388

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

            
2391
    my $dbh = $dbi->dbh;
2392

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

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

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

            
2400
Execute delete statement.
2401

            
2402
The following opitons are available.
2403

            
cleanup
Yuki Kimoto authored on 2011-10-20
2404
B<OPTIONS>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2405

            
cleanup
Yuki Kimoto authored on 2011-10-20
2406
C<delete> method use all of C<execute> method's options,
2407
and use the following new ones.
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2408

            
cleanup
Yuki Kimoto authored on 2011-10-20
2409
=over 4
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2410

            
2411
=item C<id>
2412

            
2413
    id => 4
2414
    id => [4, 5]
2415

            
2416
ID corresponding to C<primary_key>.
2417
You can delete rows by C<id> and C<primary_key>.
2418

            
2419
    $dbi->delete(
fixed pod
Yuki Kimoto authored on 2011-10-20
2420
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2421
        id => [4, 5],
2422
        table => 'book',
2423
    );
2424

            
2425
The above is same as the followin one.
2426

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

            
2429
=item C<prefix>
2430

            
2431
    prefix => 'some'
2432

            
2433
prefix before table name section.
2434

            
2435
    delete some from book
2436

            
2437
=item C<table>
2438

            
2439
    table => 'book'
2440

            
2441
Table name.
2442

            
2443
=item C<where>
2444

            
2445
Same as C<select> method's C<where> option.
2446

            
2447
=back
2448

            
2449
=head2 C<delete_all>
2450

            
2451
    $dbi->delete_all(table => $table);
2452

            
2453
Execute delete statement for all rows.
2454
Options is same as C<delete>.
2455

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

            
2458
    $dbi->each_column(
2459
        sub {
2460
            my ($dbi, $table, $column, $column_info) = @_;
2461
            
2462
            my $type = $column_info->{TYPE_NAME};
2463
            
2464
            if ($type eq 'DATE') {
2465
                # ...
2466
            }
2467
        }
2468
    );
2469

            
improved pod
Yuki Kimoto authored on 2011-10-14
2470
Iterate all column informations in database.
2471
Argument is callback which is executed when one column is found.
2472
Callback receive four arguments. C<DBIx::Custom object>, C<table name>,
2473
C<column name>, and C<column information>.
2474

            
2475
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2476
infromation, you can improve the performance of C<each_column> in
2477
the following way.
2478

            
2479
    my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
2480
    $dbi->user_column_info($column_info);
2481
    $dbi->each_column(sub { ... });
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2482

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

            
2485
    $dbi->each_table(
2486
        sub {
2487
            my ($dbi, $table, $table_info) = @_;
2488
            
2489
            my $table_name = $table_info->{TABLE_NAME};
2490
        }
2491
    );
2492

            
improved pod
Yuki Kimoto authored on 2011-10-14
2493
Iterate all table informationsfrom in database.
2494
Argument is callback which is executed when one table is found.
2495
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2496
C<table information>.
2497

            
2498
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2499
infromation, you can improve the performance of C<each_table> in
2500
the following way.
2501

            
2502
    my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
2503
    $dbi->user_table_info($table_info);
2504
    $dbi->each_table(sub { ... });
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
2505

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

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

            
2513
    my $result = $dbi->execute(
2514
      "select * from book where title = :book.title and author like :book.author",
2515
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2516
    );
2517

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2524
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2525
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2526
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2527
    select * from book where title = :title and author like :author
2528
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2529
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2530
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2531

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2532
You can specify operator with named placeholder
fixed pod
Yuki Kimoto authored on 2011-10-20
2533
by C<name{operator}> syntax.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2534

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2535
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2536
    select * from book where :title{=} and :author{like}
2537
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2538
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2539
    select * from where title = ? and author like ?;
2540

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

            
2545
    select * from where title = "aa\\:bb";
2546

            
cleanup
Yuki Kimoto authored on 2011-10-20
2547
B<OPTIONS>
2548

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

            
2551
=over 4
2552

            
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2553
=item C<after_build_sql> 
2554

            
2555
You can filter sql after the sql is build.
2556

            
2557
    after_build_sql => $code_ref
2558

            
2559
The following one is one example.
2560

            
2561
    $dbi->select(
2562
        table => 'book',
2563
        column => 'distinct(name)',
2564
        after_build_sql => sub {
2565
            "select count(*) from ($_[0]) as t1"
2566
        }
2567
    );
2568

            
2569
The following SQL is executed.
2570

            
2571
    select count(*) from (select distinct(name) from book) as t1;
2572

            
cleanup
Yuki Kimoto authored on 2011-10-20
2573
=item C<append>
2574

            
2575
    append => 'order by name'
2576

            
2577
Append some statement after SQL.
2578

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

            
2581
Specify database bind data type.
2582

            
2583
    bind_type => [image => DBI::SQL_BLOB]
2584
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2585

            
2586
This is used to bind parameter by C<bind_param> of statment handle.
2587

            
2588
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2589

            
update pod
Yuki Kimoto authored on 2011-03-13
2590
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2591
    
2592
    filter => {
2593
        title  => sub { uc $_[0] }
2594
        author => sub { uc $_[0] }
2595
    }
update pod
Yuki Kimoto authored on 2011-03-13
2596

            
updated pod
Yuki Kimoto authored on 2011-06-09
2597
    # Filter name
2598
    filter => {
2599
        title  => 'upper_case',
2600
        author => 'upper_case'
2601
    }
2602
        
2603
    # At once
2604
    filter => [
2605
        [qw/title author/]  => sub { uc $_[0] }
2606
    ]
2607

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

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

            
2615
    query => 1
2616

            
2617
C<execute> method return L<DBIx::Custom::Query> object, not executing SQL.
micro optimization and
Yuki Kimoto authored on 2011-10-25
2618
You can check SQL, column, or get statment handle.
updated pod
Yuki Kimoto authored on 2011-06-21
2619

            
2620
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2621
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2622
    my $columns = $query->columns;
2623
    
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2624
=item C<primary_key>
2625

            
cleanup
Yuki Kimoto authored on 2011-10-20
2626
    primary_key => 'id'
2627
    primary_key => ['id1', 'id2']
2628

            
execute method id option is ...
Yuki Kimoto authored on 2011-10-27
2629
Priamry key. This is used for C<id> option.
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2630

            
updated pod
Yuki Kimoto authored on 2011-06-09
2631
=item C<table>
2632
    
2633
    table => 'author'
2634

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2649
    table_alias => {user => 'worker'}
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
2650

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

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2655
=item C<reuse EXPERIMENTAL>
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2656
    
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
2657
    reuse => $hash_ref
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2658

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2659
Reuse query object if the hash reference variable is set.
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2660
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2661
    my $queries = {};
2662
    $dbi->execute($sql, $param, reuse => $queries);
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2663

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2664
This will improved performance when you want to execute same query repeatedly
2665
because generally creating query object is slow.
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2666

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

            
2669
    type_rule_off => 1
2670

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

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

            
2675
    type_rule1_off => 1
2676

            
2677
Turn C<into1> type rule off.
2678

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

            
2681
    type_rule2_off => 1
2682

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

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

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

            
improved pod
Yuki Kimoto authored on 2011-10-14
2689
    my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2690

            
2691
get column infomation except for one which match C<exclude_table> pattern.
2692

            
2693
    [
2694
        {table => 'book', column => 'title', info => {...}},
2695
        {table => 'author', column => 'name' info => {...}}
2696
    ]
2697

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

            
improved pod
Yuki Kimoto authored on 2011-10-14
2700
    my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
update pod
Yuki Kimoto authored on 2011-03-13
2701

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

            
2704
    [
2705
        {table => 'book', info => {...}},
2706
        {table => 'author', info => {...}}
2707
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2708

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2711
=head2 C<helper>
2712

            
2713
    $dbi->helper(
2714
        find_or_create   => sub {
2715
            my $self = shift;
2716
            
2717
            # Process
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
2718
        },
2719
        ...
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2720
    );
2721

            
2722
Register helper. These helper is called directly from L<DBIx::Custom> object.
2723

            
2724
    $dbi->find_or_create;
2725

            
cleanup
yuki-kimoto authored on 2010-10-17
2726
=head2 C<insert>
2727

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

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

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

            
2736
    {date => \"NOW()"}
2737

            
cleanup
Yuki Kimoto authored on 2011-10-20
2738
B<options>
2739

            
cleanup
Yuki Kimoto authored on 2011-10-20
2740
C<insert> method use all of C<execute> method's options,
cleanup
Yuki Kimoto authored on 2011-10-20
2741
and use the following new ones.
update pod
Yuki Kimoto authored on 2011-03-13
2742

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

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2745
=item C<created_at EXPERIMETNAL>
2746

            
2747
    created_at => 'created_datetime'
2748

            
2749
Created timestamp column name. time when row is created is set to the column.
2750
default time format is "YYYY-mm-dd HH:MM:SS", which can be changed by
2751
C<now> attribute.
2752

            
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2753
=item C<id>
2754

            
updated document
Yuki Kimoto authored on 2011-06-09
2755
    id => 4
2756
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2757

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2761
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2762
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
2763
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2764
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2765
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2766
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2767

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

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

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

            
2777
    prefix => 'or replace'
2778

            
2779
prefix before table name section
2780

            
2781
    insert or replace into book
2782

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

            
2785
    table => 'book'
2786

            
2787
Table name.
2788

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2789
=item C<updated_at EXPERIMENTAL>
2790

            
2791
This option is same as C<update> method C<updated_at> option.
2792

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

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

            
2797
placeholder wrapped string.
2798

            
2799
If the following statement
2800

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

            
2804
is executed, the following SQL is executed.
2805

            
2806
    insert into book price values ( ? + 5 );
2807

            
update pod
Yuki Kimoto authored on 2011-03-13
2808
=back
2809

            
2810
=over 4
2811

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2819
    lib / MyModel.pm
2820
        / MyModel / book.pm
2821
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2822

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

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

            
2827
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2828
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2829
    
2830
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2831

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2836
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2837
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2838
    
2839
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2840

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2843
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2844
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2845
    
2846
    1;
2847
    
updated pod
Yuki Kimoto authored on 2011-06-21
2848
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2849

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2857
=head2 C<like_value>
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
2858

            
2859
    my $like_value = $dbi->like_value
2860

            
cleanup
Yuki Kimoto authored on 2011-10-20
2861
Code reference which return a value for the like value.
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
2862

            
2863
    sub { "%$_[0]%" }
2864

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2865
=head2 C<mapper>
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
2866

            
2867
    my $mapper = $dbi->mapper(param => $param);
2868

            
2869
Create a new L<DBIx::Custom::Mapper> object.
2870

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2875
Merge parameters. The following new parameter is created.
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2876

            
2877
    {key1 => [1, 1], key2 => 2}
2878

            
cleanup
Yuki Kimoto authored on 2011-10-20
2879
If same keys contains, the value is converted to array reference.
2880

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

            
2883
    my $model = $dbi->model('book');
2884

            
cleanup
Yuki Kimoto authored on 2011-10-20
2885
Get a L<DBIx::Custom::Model> object
2886
create by C<create_model> or C<include_model>
update pod
Yuki Kimoto authored on 2011-03-13
2887

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2890
    my $column = $dbi->mycolumn(book => ['author', 'title']);
cleanup
Yuki Kimoto authored on 2011-03-21
2891

            
2892
Create column clause for myself. The follwoing column clause is created.
2893

            
2894
    book.author as author,
2895
    book.title as title
2896

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2899
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2900
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2901
        user => 'ken',
2902
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2903
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2904
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2905

            
2906
Create a new L<DBIx::Custom> object.
2907

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

            
2910
    my $not_exists = $dbi->not_exists;
2911

            
update pod
Yuki Kimoto authored on 2011-03-13
2912
DBIx::Custom::NotExists object, indicating the column is not exists.
cleanup
Yuki Kimoto authored on 2011-10-20
2913
This is used in C<param> of L<DBIx::Custom::Where> .
experimental extended select...
Yuki Kimoto authored on 2011-01-17
2914

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

            
2917
    my $order = $dbi->order;
2918

            
2919
Create a new L<DBIx::Custom::Order> object.
2920

            
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
2921
=head2 C<q EXPERIMENTAL>
2922

            
2923
    my $quooted = $dbi->q("title");
2924

            
2925
Quote string by value of C<quote>.
2926

            
cleanup
yuki-kimoto authored on 2010-10-17
2927
=head2 C<register_filter>
2928

            
update pod
Yuki Kimoto authored on 2011-03-13
2929
    $dbi->register_filter(
2930
        # Time::Piece object to database DATE format
2931
        tp_to_date => sub {
2932
            my $tp = shift;
2933
            return $tp->strftime('%Y-%m-%d');
2934
        },
2935
        # database DATE format to Time::Piece object
2936
        date_to_tp => sub {
2937
           my $date = shift;
2938
           return Time::Piece->strptime($date, '%Y-%m-%d');
2939
        }
2940
    );
cleanup
yuki-kimoto authored on 2010-10-17
2941
    
update pod
Yuki Kimoto authored on 2011-03-13
2942
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2943

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2946
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2947
        table  => 'book',
2948
        column => ['author', 'title'],
2949
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2950
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2951
    
updated document
Yuki Kimoto authored on 2011-06-09
2952
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2953

            
cleanup
Yuki Kimoto authored on 2011-10-20
2954
B<OPTIONS>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2955

            
cleanup
Yuki Kimoto authored on 2011-10-20
2956
C<select> method use all of C<execute> method's options,
2957
and use the following new ones.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2958

            
cleanup
Yuki Kimoto authored on 2011-10-20
2959
=over 4
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2960

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2961
=item C<column>
2962
    
updated document
Yuki Kimoto authored on 2011-06-09
2963
    column => 'author'
2964
    column => ['author', 'title']
2965

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2974
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2975
        {book => [qw/author title/]},
2976
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2977
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2978

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

            
2981
    book.author as "book.author",
2982
    book.title as "book.title",
2983
    person.name as "person.name",
2984
    person.age as "person.age"
2985

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2997
=item C<id>
2998

            
2999
    id => 4
3000
    id => [4, 5]
3001

            
3002
ID corresponding to C<primary_key>.
3003
You can select rows by C<id> and C<primary_key>.
3004

            
3005
    $dbi->select(
fixed pod
Yuki Kimoto authored on 2011-10-20
3006
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3007
        id => [4, 5],
3008
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3009
    );
3010

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3013
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3014
        where => {id1 => 4, id2 => 5},
3015
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3016
    );
3017
    
cleanup
Yuki Kimoto authored on 2011-10-20
3018
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3019

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

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

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

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

            
3032
    prefix => 'SQL_CALC_FOUND_ROWS'
3033

            
3034
Prefix of column cluase
3035

            
3036
    select SQL_CALC_FOUND_ROWS title, author from book;
3037

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

            
3040
    join => [
3041
        'left outer join company on book.company_id = company_id',
3042
        'left outer join location on company.location_id = location.id'
3043
    ]
3044
        
3045
Join clause. If column cluase or where clause contain table name like "company.name",
3046
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3047

            
3048
    $dbi->select(
3049
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3050
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3051
        where => {'company.name' => 'Orange'},
3052
        join => [
3053
            'left outer join company on book.company_id = company.id',
3054
            'left outer join location on company.location_id = location.id'
3055
        ]
3056
    );
3057

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3061
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3062
    from book
3063
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3064
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3065

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3066
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
3067
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3068

            
3069
    $dbi->select(
3070
        table => 'book',
3071
        column => ['company.location_id as location_id'],
3072
        where => {'company.name' => 'Orange'},
3073
        join => [
3074
            {
3075
                clause => 'left outer join location on company.location_id = location.id',
3076
                table => ['company', 'location']
3077
            }
3078
        ]
3079
    );
3080

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3085
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3086

            
updated document
Yuki Kimoto authored on 2011-06-09
3087
=item C<where>
3088
    
3089
    # Hash refrence
3090
    where => {author => 'Ken', 'title' => 'Perl'}
3091
    
3092
    # DBIx::Custom::Where object
3093
    where => $dbi->where(
3094
        clause => ['and', 'author = :author', 'title like :title'],
3095
        param  => {author => 'Ken', title => '%Perl%'}
3096
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3097
    
3098
    # Array reference 1 (array reference, hash referenc). same as above
3099
    where => [
3100
        ['and', 'author = :author', 'title like :title'],
3101
        {author => 'Ken', title => '%Perl%'}
3102
    ];    
3103
    
3104
    # Array reference 2 (String, hash reference)
3105
    where => [
3106
        'title like :title',
3107
        {title => '%Perl%'}
3108
    ]
3109
    
3110
    # String
3111
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3112

            
cleanup
Yuki Kimoto authored on 2011-10-20
3113
Where clause. See L<DBIx::Custom::Where>.
updated document
Yuki Kimoto authored on 2011-06-09
3114
    
update pod
Yuki Kimoto authored on 2011-03-12
3115
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3116

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3117
=head2 C<setup_model>
3118

            
3119
    $dbi->setup_model;
3120

            
3121
Setup all model objects.
3122
C<columns> of model object is automatically set, parsing database information.
3123

            
3124
=head2 C<type_rule>
3125

            
3126
    $dbi->type_rule(
3127
        into1 => {
3128
            date => sub { ... },
3129
            datetime => sub { ... }
3130
        },
3131
        into2 => {
3132
            date => sub { ... },
3133
            datetime => sub { ... }
3134
        },
3135
        from1 => {
3136
            # DATE
3137
            9 => sub { ... },
3138
            # DATETIME or TIMESTAMP
3139
            11 => sub { ... },
3140
        }
3141
        from2 => {
3142
            # DATE
3143
            9 => sub { ... },
3144
            # DATETIME or TIMESTAMP
3145
            11 => sub { ... },
3146
        }
3147
    );
3148

            
3149
Filtering rule when data is send into and get from database.
3150
This has a little complex problem.
3151

            
3152
In C<into1> and C<into2> you can specify
3153
type name as same as type name defined
3154
by create table, such as C<DATETIME> or C<DATE>.
3155

            
3156
Note that type name and data type don't contain upper case.
3157
If these contain upper case charactor, you convert it to lower case.
3158

            
3159
C<into2> is executed after C<into1>.
3160

            
3161
Type rule of C<into1> and C<into2> is enabled on the following
3162
column name.
3163

            
3164
=over 4
3165

            
3166
=item 1. column name
3167

            
3168
    issue_date
3169
    issue_datetime
3170

            
3171
This need C<table> option in each method.
3172

            
3173
=item 2. table name and column name, separator is dot
3174

            
3175
    book.issue_date
3176
    book.issue_datetime
3177

            
3178
=back
3179

            
3180
You get all type name used in database by C<available_typename>.
3181

            
3182
    print $dbi->available_typename;
3183

            
3184
In C<from1> and C<from2> you specify data type, not type name.
3185
C<from2> is executed after C<from1>.
3186
You get all data type by C<available_datatype>.
3187

            
3188
    print $dbi->available_datatype;
3189

            
3190
You can also specify multiple types at once.
3191

            
3192
    $dbi->type_rule(
3193
        into1 => [
3194
            [qw/DATE DATETIME/] => sub { ... },
3195
        ],
3196
    );
3197

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

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

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

            
3204
If you want to set constant value to row data, use scalar reference
3205
as parameter value.
3206

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
3209
B<OPTIONS>
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3210

            
cleanup
Yuki Kimoto authored on 2011-10-20
3211
C<update> method use all of C<execute> method's options,
3212
and use the following new ones.
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3213

            
cleanup
Yuki Kimoto authored on 2011-10-20
3214
=over 4
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3215

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3218
    id => 4
3219
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3220

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3224
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3225
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
3226
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3227
        id => [4, 5],
3228
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3229
    );
update pod
Yuki Kimoto authored on 2011-03-13
3230

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3233
    $dbi->update(
3234
        {title => 'Perl', author => 'Ken'}
3235
        where => {id1 => 4, id2 => 5},
3236
        table => 'book'
3237
    );
update pod
Yuki Kimoto authored on 2011-03-13
3238

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

            
3241
    prefix => 'or replace'
3242

            
3243
prefix before table name section
3244

            
3245
    update or replace book
3246

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

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

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

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

            
3255
Same as C<select> method's C<where> option.
3256

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

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

            
3261
placeholder wrapped string.
3262

            
3263
If the following statement
3264

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

            
3268
is executed, the following SQL is executed.
3269

            
3270
    update book set price =  ? + 5;
3271

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
3272
=item C<updated_at EXPERIMETNAL>
3273

            
3274
    updated_at => 'updated_datetime'
3275

            
3276
Updated timestamp column name. time when row is updated is set to the column.
3277
default time format is C<YYYY-mm-dd HH:MM:SS>, which can be changed by
3278
C<now> attribute.
3279

            
updated pod
Yuki Kimoto authored on 2011-06-08
3280
=back
update pod
Yuki Kimoto authored on 2011-03-13
3281

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

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

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

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3289
=head2 C<update_or_insert EXPERIMENTAL>
3290
    
3291
    # ID
3292
    $dbi->update_or_insert(
3293
        {title => 'Perl'},
3294
        table => 'book',
3295
        id => 1,
3296
        primary_key => 'id',
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3297
        option => {
3298
            select => {
3299
                 append => 'for update'
3300
            }
3301
        }
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3302
    );
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3303

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3304
Update or insert.
3305

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3306
C<update_or_insert> method execute C<select> method first to find row.
3307
If the row is exists, C<update> is executed.
3308
If not, C<insert> is executed.
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3309

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3310
C<OPTIONS>
3311

            
3312
C<update_or_insert> method use all common option
3313
in C<select>, C<update>, C<delete>, and has the following new ones.
3314

            
3315
=over 4
3316

            
3317
=item C<option>
3318

            
3319
    option => {
3320
        select => {
3321
            append => '...'
3322
        },
3323
        insert => {
3324
            prefix => '...'
3325
        },
3326
        update => {
3327
            filter => {}
3328
        }
3329
    }
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3330

            
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
3331
If you want to pass option to each method,
3332
you can use C<option> option.
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3333

            
3334
=over 4
3335

            
3336
=item C<select_option>
3337

            
3338
    select_option => {append => 'for update'}
3339

            
3340
select method option,
3341
select method is used to check the row is already exists.
3342

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

            
3345
    $dbi->show_datatype($table);
3346

            
3347
Show data type of the columns of specified table.
3348

            
3349
    book
3350
    title: 5
3351
    issue_date: 91
3352

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

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

            
3357
    $dbi->show_tables;
3358

            
3359
Show tables.
3360

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

            
3363
    $dbi->show_typename($table);
3364

            
3365
Show type name of the columns of specified table.
3366

            
3367
    book
3368
    title: varchar
3369
    issue_date: date
3370

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3373
=head2 C<values_clause>
3374

            
3375
    my $values_clause = $dbi->values_clause({title => 'a', age => 2});
3376

            
3377
Create values clause.
3378

            
3379
    (title, author) values (title = :title, age = :age);
3380

            
3381
You can use this in insert statement.
3382

            
3383
    my $insert_sql = "insert into book $values_clause";
3384

            
3385
=head2 C<where>
3386

            
3387
    my $where = $dbi->where(
3388
        clause => ['and', 'title = :title', 'author = :author'],
3389
        param => {title => 'Perl', author => 'Ken'}
3390
    );
3391

            
3392
Create a new L<DBIx::Custom::Where> object.
3393

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

            
3396
=head2 C<DBIX_CUSTOM_DEBUG>
3397

            
3398
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3399
executed SQL and bind values are printed to STDERR.
3400

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

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

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

            
3407
L<DBIx::Custom>
3408

            
3409
    # Attribute methods
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
3410
    default_dbi_option # will be removed 2017/1/1
3411
    dbi_option # will be removed 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3412
    data_source # will be removed at 2017/1/1
3413
    dbi_options # will be removed at 2017/1/1
3414
    filter_check # will be removed at 2017/1/1
3415
    reserved_word_quote # will be removed at 2017/1/1
3416
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3417
    
3418
    # Methods
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
3419
    update_timestamp # will be removed at 2017/1/1
3420
    insert_timestamp # will be removed at 2017/1/1
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3421
    method # will be removed at 2017/1/1
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
3422
    assign_param # will be removed at 2017/1/1
3423
    update_param # will be removed at 2017/1/1
3424
    insert_param # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3425
    create_query # will be removed at 2017/1/1
3426
    apply_filter # will be removed at 2017/1/1
3427
    select_at # will be removed at 2017/1/1
3428
    delete_at # will be removed at 2017/1/1
3429
    update_at # will be removed at 2017/1/1
3430
    insert_at # will be removed at 2017/1/1
3431
    register_tag # will be removed at 2017/1/1
3432
    default_bind_filter # will be removed at 2017/1/1
3433
    default_fetch_filter # will be removed at 2017/1/1
3434
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3435
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3436
    register_tag_processor # will be removed at 2017/1/1
3437
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3438
    
3439
    # Options
- insert method created_at a...
Yuki Kimoto authored on 2011-10-27
3440
    select column option [COLUMN => ALIAS] syntax # will be removed 2017/1/1
execute method id option is ...
Yuki Kimoto authored on 2011-10-27
3441
    execute method id option # will be removed 2017/1/1
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
3442
    update timestamp option # will be removed 2017/1/1
3443
    insert timestamp option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3444
    select method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3445
    delete method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3446
    update method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3447
    insert method param option # will be removed at 2017/1/1
insert method's id option is...
Yuki Kimoto authored on 2011-10-10
3448
    insert method id option # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3449
    select method relation option # will be removed at 2017/1/1
3450
    select method column option [COLUMN, as => ALIAS] format
3451
      # will be removed at 2017/1/1
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3452
    execute method's sqlfilter option # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3453
    
3454
    # Others
micro optimization and
Yuki Kimoto authored on 2011-10-25
3455
    execute($query, ...) # execute method receiving query object.
3456
                         # this is removed at 2017/1/1
cleanup
Yuki Kimoto authored on 2011-07-28
3457
    execute("select * from {= title}"); # execute method's
3458
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3459
                                        # will be removed at 2017/1/1
3460
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3461

            
3462
L<DBIx::Custom::Model>
3463

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3464
    # Attribute methods
DBIx::Custom::Model execute ...
Yuki Kimoto authored on 2011-11-01
3465
    execute # will be removed at 2017/1/1
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3466
    method # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3467
    filter # will be removed at 2017/1/1
3468
    name # will be removed at 2017/1/1
3469
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3470

            
3471
L<DBIx::Custom::Query>
3472
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3473
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3474
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3475
    table # will be removed at 2017/1/1
3476
    filters # will be removed at 2017/1/1
3477
    
3478
    # Methods
3479
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3480

            
3481
L<DBIx::Custom::QueryBuilder>
3482
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3483
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3484
    tags # will be removed at 2017/1/1
3485
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3486
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3487
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3488
    register_tag # will be removed at 2017/1/1
3489
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3490
    
3491
    # Others
3492
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3493
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3494

            
3495
L<DBIx::Custom::Result>
3496
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3497
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3498
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3499
    
3500
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3501
    end_filter # will be removed at 2017/1/1
3502
    remove_end_filter # will be removed at 2017/1/1
3503
    remove_filter # will be removed at 2017/1/1
3504
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3505

            
3506
L<DBIx::Custom::Tag>
3507

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

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

            
3512
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3513
except for attribute method.
3514
You can check all DEPRECATED functionalities by document.
3515
DEPRECATED functionality is removed after five years,
3516
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
3517
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3518

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

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

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

            
3525
C<< <kimoto.yuki at gmail.com> >>
3526

            
3527
L<http://github.com/yuki-kimoto/DBIx-Custom>
3528

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3529
=head1 AUTHOR
3530

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

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

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

            
3537
This program is free software; you can redistribute it and/or modify it
3538
under the same terms as Perl itself.
3539

            
3540
=cut