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

            
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
4
our $VERSION = '0.1745';
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 => '.',
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
74
    stash => sub { {} };
cleanup
yuki-kimoto authored on 2010-10-17
75

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
676
sub insert_timestamp {
677
    my $self = shift;
678
    
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
679
    warn "insert_timestamp method is DEPRECATED! use now attribute";
680
    
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
681
    if (@_) {
682
        $self->{insert_timestamp} = [@_];
683
        
684
        return $self;
685
    }
686
    return $self->{insert_timestamp};
687
}
688

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

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

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

            
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
756
sub mapper {
757
    my $self = shift;
758
    return DBIx::Custom::Mapper->new(@_);
759
}
760

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

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
876
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
877
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
878
    
879
    # Register filter
880
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
881
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
882
    
cleanup
Yuki Kimoto authored on 2011-04-02
883
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
884
}
packaging one directory
yuki-kimoto authored on 2009-11-16
885

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

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

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

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
977
sub setup_model {
978
    my $self = shift;
979
    
cleanup
Yuki Kimoto authored on 2011-04-02
980
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
981
    $self->each_column(
982
        sub {
983
            my ($self, $table, $column, $column_info) = @_;
984
            if (my $model = $self->models->{$table}) {
985
                push @{$model->columns}, $column;
986
            }
987
        }
988
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
989
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
990
}
991

            
update pod
Yuki Kimoto authored on 2011-08-10
992
sub show_datatype {
993
    my ($self, $table) = @_;
994
    croak "Table name must be specified" unless defined $table;
995
    print "$table\n";
996
    
997
    my $result = $self->select(table => $table, where => "'0' <> '0'");
998
    my $sth = $result->sth;
999

            
1000
    my $columns = $sth->{NAME};
1001
    my $data_types = $sth->{TYPE};
1002
    
1003
    for (my $i = 0; $i < @$columns; $i++) {
1004
        my $column = $columns->[$i];
show_datatype method return ...
Yuki Kimoto authored on 2011-11-03
1005
        my $data_type = lc $data_types->[$i];
update pod
Yuki Kimoto authored on 2011-08-10
1006
        print "$column: $data_type\n";
1007
    }
1008
}
1009

            
1010
sub show_typename {
1011
    my ($self, $t) = @_;
1012
    croak "Table name must be specified" unless defined $t;
1013
    print "$t\n";
1014
    
1015
    $self->each_column(sub {
1016
        my ($self, $table, $column, $infos) = @_;
1017
        return unless $table eq $t;
show_datatype method return ...
Yuki Kimoto authored on 2011-11-03
1018
        my $typename = lc $infos->{TYPE_NAME};
update pod
Yuki Kimoto authored on 2011-08-10
1019
        print "$column: $typename\n";
1020
    });
1021
    
1022
    return $self;
1023
}
1024

            
test cleanup
Yuki Kimoto authored on 2011-08-15
1025
sub show_tables {
1026
    my $self = shift;
1027
    
1028
    my %tables;
1029
    $self->each_table(sub { $tables{$_[1]}++ });
1030
    print join("\n", sort keys %tables) . "\n";
1031
    return $self;
1032
}
1033

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1071
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1072
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1073
                }
1074
            });
1075
        }
1076

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

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

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

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1124
    # Created time and updated time
1125
    my @timestamp_cleanup;
1126
    if (defined $opt{updated_at}) {
- insert method created_at a...
Yuki Kimoto authored on 2011-10-27
1127
        my $now = $self->now;
1128
        $now = $now->() if ref $now eq 'CODE';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1129
        $param->{$opt{updated_at}} = $self->now->();
1130
        push @timestamp_cleanup, $opt{updated_at};
1131
    }
1132

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1153
sub update_or_insert {
- EXPERIMENTAL update_or_ins...
Yuki Kimoto authored on 2011-10-27
1154
    my ($self, $param, %opt) = @_;
1155
    croak "update_or_insert method need primary_key and id option "
1156
      unless defined $opt{id} && defined $opt{primary_key};
1157
    my $statement_opt = $opt{option} || {};
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1158

            
1159
    my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
1160
    if (@$rows == 0) {
1161
        return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
1162
    }
1163
    elsif (@$rows == 1) {
1164
        return $self->update($param, %opt, %{$statement_opt->{update} || {}});
1165
    }
1166
    else {
1167
        croak "selected row must be one " . _subname;
1168
    }
cleanup
Yuki Kimoto authored on 2011-10-21
1169
}
1170

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1354
sub _id_to_param {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1355
    my ($self, $id, $primary_keys, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1356
    
1357
    # Check primary key
cleanup
Yuki Kimoto authored on 2011-10-21
1358
    croak "primary_key option " .
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1359
          "must be specified when id option is used" . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1360
      unless defined $primary_keys;
1361
    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
improved error messages
Yuki Kimoto authored on 2011-04-18
1362
    
cleanup
Yuki Kimoto authored on 2011-06-08
1363
    # Create parameter
1364
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1365
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1366
        $id = [$id] unless ref $id;
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1367
        for(my $i = 0; $i < @$id; $i++) {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1368
           my $key = $primary_keys->[$i];
1369
           $key = "$table." . $key if $table;
1370
           $param->{$key} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1371
        }
1372
    }
1373
    
cleanup
Yuki Kimoto authored on 2011-06-08
1374
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1375
}
1376

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

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

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

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

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

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

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1524
sub _quote {
1525
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-22
1526
    return $self->{reserved_word_quote} || $self->quote || '';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1527
}
1528

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

            
1542
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1543
}
1544

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1565
    $where ||= {};
cleanup
Yuki Kimoto authored on 2011-10-25
1566
    $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
cleanup
Yuki Kimoto authored on 2011-10-25
1567
    $where_param ||= {};
cleanup
Yuki Kimoto authored on 2011-10-21
1568
    my $w = {};
1569
    my $where_clause = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1570

            
cleanup
Yuki Kimoto authored on 2011-10-25
1571
    my $obj;
1572
    
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
1573
    if (ref $where) {
cleanup
Yuki Kimoto authored on 2011-10-25
1574
        if (ref $where eq 'HASH') {
1575
            my $clause = ['and'];
cleanup
Yuki Kimoto authored on 2011-11-01
1576
            my $column_join = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1577
            for my $column (keys %$where) {
cleanup
Yuki Kimoto authored on 2011-11-01
1578
                $column_join .= $column;
cleanup
Yuki Kimoto authored on 2011-10-25
1579
                my $table;
1580
                my $c;
1581
                if ($column =~ /(?:(.*?)\.)?(.*)/) {
1582
                    $table = $1;
1583
                    $c = $2;
1584
                }
1585
                
1586
                my $table_quote;
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
1587
                $table_quote = $self->q($table) if defined $table;
1588
                my $column_quote = $self->q($c);
cleanup
Yuki Kimoto authored on 2011-10-25
1589
                $column_quote = $table_quote . '.' . $column_quote
1590
                  if defined $table_quote;
cleanup
Yuki Kimoto authored on 2011-11-01
1591
                push @$clause, "$column_quote = :$column";
cleanup
Yuki Kimoto authored on 2011-10-25
1592
            }
cleanup
Yuki Kimoto authored on 2011-11-01
1593

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

            
1616
        $w->{param} = keys %$where_param
1617
                    ? $self->merge_param($where_param, $obj->param)
1618
                    : $obj->param;
1619
        $w->{clause} = $obj->to_string;
cleanup
Yuki Kimoto authored on 2011-10-21
1620
    }
1621
    elsif ($where) {
1622
        $w->{clause} = "where $where";
cleanup
Yuki Kimoto authored on 2011-10-25
1623
        $w->{param} = $where_param;
cleanup
Yuki Kimoto authored on 2011-10-21
1624
    }
1625
    
1626
    return $w;
1627
}
1628

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1699
# DEPRECATED!
1700
has 'data_source';
1701
has dbi_options => sub { {} };
1702
has filter_check  => 1;
1703
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1704
has dbi_option => sub { {} };
1705
has default_dbi_option => sub {
1706
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1707
    return shift->default_option;
1708
};
1709

            
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
1710
# DEPRECATED
1711
sub tag_parse {
1712
   my $self = shift;
1713
   warn "tag_parse is DEPRECATED! use \$ENV{DBIX_CUSTOM_TAG_PARSE} " .
1714
         "environment variable";
1715
    if (@_) {
1716
        $self->{tag_parse} = $_[0];
1717
        return $self;
1718
    }
1719
    return $self->{tag_parse};
1720
}
1721

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

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

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

            
1745
    return $tag;
1746
}
1747

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1974
=head1 NAME
1975

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

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

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2049
Named place holder support
2050

            
2051
=item *
2052

            
cleanup
Yuki Kimoto authored on 2011-07-29
2053
Model support
2054

            
2055
=item *
2056

            
2057
Connection manager support
2058

            
2059
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2060

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

            
2065
=item *
2066

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

            
2069
=item *
2070

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

            
2073
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2074

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

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

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

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

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

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

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

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

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

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

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

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

            
2119
Note that L<DBIx::Connector> must be installed.
2120

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

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

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

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

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

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

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

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

            
2144
    my $exclude_table = $dbi->exclude_table;
2145
    $dbi = $dbi->exclude_table(qr/pg_/);
2146

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

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

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

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

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

            
2160
    my $last_sql = $dbi->last_sql;
2161
    $dbi = $dbi->last_sql($last_sql);
2162

            
2163
Get last successed SQL executed by C<execute> method.
2164

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2165
=head2 C<now>
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2166

            
2167
    my $now = $dbi->now;
2168
    $dbi = $dbi->now($now);
2169

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2170
Code reference which return current time, default to the following code reference.
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2171

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

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2179
This return the time like C<2011-10-14 05:05:27>.
2180

            
2181
This is used by C<insert> method's C<created_at> option and C<updated_at> option,
2182
and C<update> method's C<updated_at> option.
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
2183

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

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

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

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

            
2193
    my $option = $dbi->option;
2194
    $dbi = $dbi->option($option);
2195

            
2196
L<DBI> option, used when C<connect> method is executed.
2197
Each value in option override the value of C<default_option>.
2198

            
cleanup
yuki-kimoto authored on 2010-10-17
2199
=head2 C<password>
2200

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2221
You can set quote pair.
2222

            
2223
    $dbi->quote('[]');
2224

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2234
    my $safety_character = $dbi->safety_character;
2235
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2236

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

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

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

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

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

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

            
2253
    my $tag_parse = $dbi->tag_parse(0);
2254
    $dbi = $dbi->tag_parse;
2255

            
2256
Enable DEPRECATED tag parsing functionality, default to 1.
2257
If you want to disable tag parsing functionality, set to 0.
2258

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

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

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

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

            
2268
    my $user_column_info = $dbi->user_column_info;
2269
    $dbi = $dbi->user_column_info($user_column_info);
2270

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

            
2273
    [
2274
        {table => 'book', column => 'title', info => {...}},
2275
        {table => 'author', column => 'name', info => {...}}
2276
    ]
2277

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

            
2280
    my $user_column_info
2281
      = $dbi->get_column_info(exclude_table => qr/^system/);
2282
    $dbi->user_column_info($user_column_info);
2283

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

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

            
2289
    my $user_table_info = $dbi->user_table_info;
2290
    $dbi = $dbi->user_table_info($user_table_info);
2291

            
2292
You can set the following data.
2293

            
2294
    [
2295
        {table => 'book', info => {...}},
2296
        {table => 'author', info => {...}}
2297
    ]
2298

            
2299
Usually, you can set return value of C<get_table_info>.
2300

            
2301
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2302
    $dbi->user_table_info($user_table_info);
2303

            
2304
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2305
to find table info.
2306

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2343
Create column clause. The follwoing column clause is created.
2344

            
2345
    book.author as "book.author",
2346
    book.title as "book.title"
2347

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

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

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

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

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

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

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

            
2375
Get rows count.
2376

            
2377
Options is same as C<select> method's ones.
2378

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

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

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

            
2392
   $dbi->model('book')->select(...);
2393

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

            
2396
    my $dbh = $dbi->dbh;
2397

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

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

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

            
2405
Execute delete statement.
2406

            
2407
The following opitons are available.
2408

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

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

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

            
2416
=item C<id>
2417

            
2418
    id => 4
2419
    id => [4, 5]
2420

            
2421
ID corresponding to C<primary_key>.
2422
You can delete rows by C<id> and C<primary_key>.
2423

            
2424
    $dbi->delete(
fixed pod
Yuki Kimoto authored on 2011-10-20
2425
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2426
        id => [4, 5],
2427
        table => 'book',
2428
    );
2429

            
2430
The above is same as the followin one.
2431

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

            
2434
=item C<prefix>
2435

            
2436
    prefix => 'some'
2437

            
2438
prefix before table name section.
2439

            
2440
    delete some from book
2441

            
2442
=item C<table>
2443

            
2444
    table => 'book'
2445

            
2446
Table name.
2447

            
2448
=item C<where>
2449

            
2450
Same as C<select> method's C<where> option.
2451

            
2452
=back
2453

            
2454
=head2 C<delete_all>
2455

            
2456
    $dbi->delete_all(table => $table);
2457

            
2458
Execute delete statement for all rows.
2459
Options is same as C<delete>.
2460

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

            
2463
    $dbi->each_column(
2464
        sub {
2465
            my ($dbi, $table, $column, $column_info) = @_;
2466
            
2467
            my $type = $column_info->{TYPE_NAME};
2468
            
2469
            if ($type eq 'DATE') {
2470
                # ...
2471
            }
2472
        }
2473
    );
2474

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

            
2480
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2481
infromation, you can improve the performance of C<each_column> in
2482
the following way.
2483

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

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

            
2490
    $dbi->each_table(
2491
        sub {
2492
            my ($dbi, $table, $table_info) = @_;
2493
            
2494
            my $table_name = $table_info->{TABLE_NAME};
2495
        }
2496
    );
2497

            
improved pod
Yuki Kimoto authored on 2011-10-14
2498
Iterate all table informationsfrom in database.
2499
Argument is callback which is executed when one table is found.
2500
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2501
C<table information>.
2502

            
2503
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2504
infromation, you can improve the performance of C<each_table> in
2505
the following way.
2506

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

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

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

            
2518
    my $result = $dbi->execute(
2519
      "select * from book where title = :book.title and author like :book.author",
2520
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2521
    );
2522

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2540
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2541
    select * from book where :title{=} and :author{like}
2542
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2543
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2544
    select * from where title = ? and author like ?;
2545

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

            
2550
    select * from where title = "aa\\:bb";
2551

            
cleanup
Yuki Kimoto authored on 2011-10-20
2552
B<OPTIONS>
2553

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

            
2556
=over 4
2557

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

            
2560
You can filter sql after the sql is build.
2561

            
2562
    after_build_sql => $code_ref
2563

            
2564
The following one is one example.
2565

            
2566
    $dbi->select(
2567
        table => 'book',
2568
        column => 'distinct(name)',
2569
        after_build_sql => sub {
2570
            "select count(*) from ($_[0]) as t1"
2571
        }
2572
    );
2573

            
2574
The following SQL is executed.
2575

            
2576
    select count(*) from (select distinct(name) from book) as t1;
2577

            
cleanup
Yuki Kimoto authored on 2011-10-20
2578
=item C<append>
2579

            
2580
    append => 'order by name'
2581

            
2582
Append some statement after SQL.
2583

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

            
2586
Specify database bind data type.
2587

            
2588
    bind_type => [image => DBI::SQL_BLOB]
2589
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2590

            
2591
This is used to bind parameter by C<bind_param> of statment handle.
2592

            
2593
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2594

            
update pod
Yuki Kimoto authored on 2011-03-13
2595
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2596
    
2597
    filter => {
2598
        title  => sub { uc $_[0] }
2599
        author => sub { uc $_[0] }
2600
    }
update pod
Yuki Kimoto authored on 2011-03-13
2601

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

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

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

            
2620
    query => 1
2621

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

            
2625
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2626
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2627
    my $columns = $query->columns;
2628
    
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
2629
=item C<reuse>
2630
    
2631
    reuse => $hash_ref
2632

            
2633
Reuse query object if the hash reference variable is set.
2634
    
2635
    my $queries = {};
2636
    $dbi->execute($sql, $param, reuse => $queries);
2637

            
2638
This will improved performance when you want to execute same query repeatedly
2639
because generally creating query object is slow.
2640

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

            
cleanup
Yuki Kimoto authored on 2011-10-20
2643
    primary_key => 'id'
2644
    primary_key => ['id1', 'id2']
2645

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2648
=item C<table>
2649
    
2650
    table => 'author'
2651

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2659
    # Same
2660
    $dbi->execute(
2661
      "select * from book where title = :book.title and author = :book.author",
2662
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2663

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

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

            
2668
Table alias. Key is real table name, value is alias table name.
2669
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2670
on alias table name.
2671

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

            
2674
    type_rule_off => 1
2675

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

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

            
2680
    type_rule1_off => 1
2681

            
2682
Turn C<into1> type rule off.
2683

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

            
2686
    type_rule2_off => 1
2687

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

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

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

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

            
2696
get column infomation except for one which match C<exclude_table> pattern.
2697

            
2698
    [
2699
        {table => 'book', column => 'title', info => {...}},
2700
        {table => 'author', column => 'name' info => {...}}
2701
    ]
2702

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

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

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

            
2709
    [
2710
        {table => 'book', info => {...}},
2711
        {table => 'author', info => {...}}
2712
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2713

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

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

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

            
2727
Register helper. These helper is called directly from L<DBIx::Custom> object.
2728

            
2729
    $dbi->find_or_create;
2730

            
cleanup
yuki-kimoto authored on 2010-10-17
2731
=head2 C<insert>
2732

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

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

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

            
2741
    {date => \"NOW()"}
2742

            
cleanup
Yuki Kimoto authored on 2011-10-20
2743
B<options>
2744

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

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

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2750
=item C<created_at>
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2751

            
2752
    created_at => 'created_datetime'
2753

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2760
    id => 4
2761
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2762

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

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

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

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

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

            
2782
    prefix => 'or replace'
2783

            
2784
prefix before table name section
2785

            
2786
    insert or replace into book
2787

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

            
2790
    table => 'book'
2791

            
2792
Table name.
2793

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2794
=item C<updated_at>
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
2795

            
2796
This option is same as C<update> method C<updated_at> option.
2797

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

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

            
2802
placeholder wrapped string.
2803

            
2804
If the following statement
2805

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

            
2809
is executed, the following SQL is executed.
2810

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

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

            
2815
=over 4
2816

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2824
    lib / MyModel.pm
2825
        / MyModel / book.pm
2826
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2827

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

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

            
2832
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2833
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2834
    
2835
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2836

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2841
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2842
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2843
    
2844
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2845

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2848
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2849
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2850
    
2851
    1;
2852
    
updated pod
Yuki Kimoto authored on 2011-06-21
2853
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2854

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

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

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

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

            
2864
    my $like_value = $dbi->like_value
2865

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

            
2868
    sub { "%$_[0]%" }
2869

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

            
2872
    my $mapper = $dbi->mapper(param => $param);
2873

            
2874
Create a new L<DBIx::Custom::Mapper> object.
2875

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

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

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

            
2882
    {key1 => [1, 1], key2 => 2}
2883

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

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

            
2888
    my $model = $dbi->model('book');
2889

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

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

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

            
2897
Create column clause for myself. The follwoing column clause is created.
2898

            
2899
    book.author as author,
2900
    book.title as title
2901

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

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

            
2911
Create a new L<DBIx::Custom> object.
2912

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

            
2915
    my $not_exists = $dbi->not_exists;
2916

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

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

            
2922
    my $order = $dbi->order;
2923

            
2924
Create a new L<DBIx::Custom::Order> object.
2925

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
2926
=head2 C<q>
added EXPERIMENTAL q method
Yuki Kimoto authored on 2011-10-27
2927

            
2928
    my $quooted = $dbi->q("title");
2929

            
2930
Quote string by value of C<quote>.
2931

            
cleanup
yuki-kimoto authored on 2010-10-17
2932
=head2 C<register_filter>
2933

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

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

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

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2966
=item C<column>
2967
    
updated document
Yuki Kimoto authored on 2011-06-09
2968
    column => 'author'
2969
    column => ['author', 'title']
2970

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2979
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2980
        {book => [qw/author title/]},
2981
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2982
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2983

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

            
2986
    book.author as "book.author",
2987
    book.title as "book.title",
2988
    person.name as "person.name",
2989
    person.age as "person.age"
2990

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

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

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

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

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

            
3004
    id => 4
3005
    id => [4, 5]
3006

            
3007
ID corresponding to C<primary_key>.
3008
You can select rows by C<id> and C<primary_key>.
3009

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

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

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

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

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

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

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

            
3037
    prefix => 'SQL_CALC_FOUND_ROWS'
3038

            
3039
Prefix of column cluase
3040

            
3041
    select SQL_CALC_FOUND_ROWS title, author from book;
3042

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3066
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3067
    from book
3068
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3069
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3070

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3071
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
3072
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3073

            
3074
    $dbi->select(
3075
        table => 'book',
3076
        column => ['company.location_id as location_id'],
3077
        where => {'company.name' => 'Orange'},
3078
        join => [
3079
            {
3080
                clause => 'left outer join location on company.location_id = location.id',
3081
                table => ['company', 'location']
3082
            }
3083
        ]
3084
    );
3085

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3090
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3091

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

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

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

            
3118
    $dbi->setup_model;
3119

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

            
3123
=head2 C<type_rule>
3124

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

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

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

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

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

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

            
3163
=over 4
3164

            
3165
=item 1. column name
3166

            
3167
    issue_date
3168
    issue_datetime
3169

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

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

            
3174
    book.issue_date
3175
    book.issue_datetime
3176

            
3177
=back
3178

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

            
3181
    print $dbi->available_typename;
3182

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

            
3187
    print $dbi->available_datatype;
3188

            
3189
You can also specify multiple types at once.
3190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
3240
    prefix => 'or replace'
3241

            
3242
prefix before table name section
3243

            
3244
    update or replace book
3245

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

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

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

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

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

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

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

            
3260
placeholder wrapped string.
3261

            
3262
If the following statement
3263

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

            
3267
is executed, the following SQL is executed.
3268

            
3269
    update book set price =  ? + 5;
3270

            
- id option work if id count...
Yuki Kimoto authored on 2011-11-03
3271
=item C<updated_at>
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
3272

            
3273
    updated_at => 'updated_datetime'
3274

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

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

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

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

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

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

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

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

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

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

            
3314
=over 4
3315

            
3316
=item C<option>
3317

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

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

            
3333
=over 4
3334

            
3335
=item C<select_option>
3336

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

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

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

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

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

            
3348
    book
3349
    title: 5
3350
    issue_date: 91
3351

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

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

            
3356
    $dbi->show_tables;
3357

            
3358
Show tables.
3359

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

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

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

            
3366
    book
3367
    title: varchar
3368
    issue_date: date
3369

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

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

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

            
3376
Create values clause.
3377

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

            
3380
You can use this in insert statement.
3381

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

            
3384
=head2 C<where>
3385

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

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

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

            
3395
=head2 C<DBIX_CUSTOM_DEBUG>
3396

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

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

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

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

            
3406
L<DBIx::Custom>
3407

            
3408
    # Attribute methods
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
3409
    tag_parse # will be removed 2017/1/1
- 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>
- DBIx::Custom::QueryBuilder...
Yuki Kimoto authored on 2011-11-04
3482

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

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

            
3510
L<DBIx::Custom::Tag>
3511

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

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

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

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

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

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

            
3529
C<< <kimoto.yuki at gmail.com> >>
3530

            
3531
L<http://github.com/yuki-kimoto/DBIx-Custom>
3532

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3533
=head1 AUTHOR
3534

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

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

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

            
3541
This program is free software; you can redistribute it and/or modify it
3542
under the same terms as Perl itself.
3543

            
3544
=cut