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

            
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
4
our $VERSION = '0.1740';
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
5
use 5.008001;
cleanup
yuki-kimoto authored on 2009-12-22
6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
427
    # Merge id to parameter
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
428
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
429
        croak "execute id option must be specified with primary_key option"
430
          unless $opt{primary_key};
431
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
432
        $opt{id} = [$opt{id}] unless ref $opt{id};
433
        my $statement = $query->statement;
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}) {
633
        my $now = $self->now->();
634
        if (defined $opt{created_at}) {
635
            $param->{$opt{created_at}} = $now;
636
            push @timestamp_cleanup, $opt{created_at};
637
        }
638
        if (defined $opt{updated_at}) {
639
            $param->{$opt{updated_at}} = $now;
640
            push @timestamp_cleanup, $opt{updated_at};
641
        }
642
    }
cleanup
Yuki Kimoto authored on 2011-10-21
643
    
644
    # Merge id to parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
645
    my @cleanup;
micro optimization and
Yuki Kimoto authored on 2011-10-25
646
    my $id_param = {};
micro optimization
Yuki Kimoto authored on 2011-10-23
647
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
648
        croak "insert id option must be specified with primary_key option"
micro optimization
Yuki Kimoto authored on 2011-10-23
649
          unless $opt{primary_key};
650
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
651
        $opt{id} = [$opt{id}] unless ref $opt{id};
652
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
653
           my $key = $opt{primary_key}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
654
           next if exists $param->{$key};
micro optimization
Yuki Kimoto authored on 2011-10-23
655
           $param->{$key} = $opt{id}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
656
           push @cleanup, $key;
micro optimization
Yuki Kimoto authored on 2011-10-23
657
        }
658
    }
cleanup
Yuki Kimoto authored on 2011-10-21
659
    
cleanup
Yuki Kimoto authored on 2011-04-02
660
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-10-21
661
    my $sql = "insert ";
cleanup
Yuki Kimoto authored on 2011-10-21
662
    $sql .= "$opt{prefix} " if defined $opt{prefix};
663
    $sql .= "into " . $self->_q($opt{table}) . " "
664
      . $self->values_clause($param, {wrap => $opt{wrap}}) . " ";
micro optimization
Yuki Kimoto authored on 2011-10-23
665

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
871
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
872
    my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
873
               : defined $opt{table} ? [$opt{table}]
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
874
               : [];
cleanup
Yuki Kimoto authored on 2011-10-21
875
    $opt{table} = $tables;
cleanup
Yuki Kimoto authored on 2011-10-21
876
    my $where_param = $opt{where_param} || delete $opt{param} || {};
select method where_param op...
Yuki Kimoto authored on 2011-10-25
877
    warn "select method where_param option is DEPRECATED!"
878
      if $opt{where_param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
879
    
cleanup
Yuki Kimoto authored on 2011-03-09
880
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
881
    if ($opt{relation}) {
882
        warn "select() relation option is DEPRECATED!";
883
        $self->_add_relation_table($tables, $opt{relation});
884
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
885
    
cleanup
Yuki Kimoto authored on 2011-04-02
886
    # Select statement
micro optimization
Yuki Kimoto authored on 2011-09-30
887
    my $sql = 'select ';
packaging one directory
yuki-kimoto authored on 2009-11-16
888
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
889
    # Prefix
cleanup
Yuki Kimoto authored on 2011-10-21
890
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
891
    
cleanup
Yuki Kimoto authored on 2011-10-21
892
    # Column
cleanup
Yuki Kimoto authored on 2011-10-21
893
    if (defined $opt{column}) {
894
        my $columns
895
          = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
cleanup
Yuki Kimoto authored on 2011-10-21
896
        for my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
897
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
898
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
899
            }
900
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
901
                if (@$column == 3 && $column->[1] eq 'as') {
902
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
903
                    splice @$column, 1, 1;
904
                }
905
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
906
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
907
            }
cleanup
Yuki Kimoto authored on 2011-04-02
908
            unshift @$tables, @{$self->_search_tables($column)};
micro optimization
Yuki Kimoto authored on 2011-09-30
909
            $sql .= "$column, ";
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
910
        }
micro optimization
Yuki Kimoto authored on 2011-09-30
911
        $sql =~ s/, $/ /;
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
912
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
913
    else { $sql .= '* ' }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
914
    
915
    # Table
micro optimization
Yuki Kimoto authored on 2011-09-30
916
    $sql .= 'from ';
cleanup
Yuki Kimoto authored on 2011-10-21
917
    if ($opt{relation}) {
cleanup
Yuki Kimoto authored on 2011-03-30
918
        my $found = {};
cleanup
Yuki Kimoto authored on 2011-10-21
919
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-09-30
920
            $sql .= $self->_q($table) . ', ' unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
921
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
922
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
923
    }
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
924
    else { $sql .= $self->_q($tables->[-1] || '') . ' ' }
micro optimization
Yuki Kimoto authored on 2011-09-30
925
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2011-10-21
926
    croak "select method table option must be specified " . _subname
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-10-26
927
      unless defined $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
928

            
cleanup
Yuki Kimoto authored on 2011-04-02
929
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
930
    unshift @$tables,
931
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
932
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
933
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
934
    my $w = $self->_where_clause_and_param($opt{where}, $where_param,
935
      delete $opt{id}, $opt{primary_key}, $tables->[-1]);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
936
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
937
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-10-21
938
    unshift @$tables, @{$self->_search_tables($w->{clause})};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
939
    
cleanup
Yuki Kimoto authored on 2011-10-21
940
    # Join statement
cleanup
Yuki Kimoto authored on 2011-10-21
941
    $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
942
    
cleanup
Yuki Kimoto authored on 2011-03-09
943
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-10-21
944
    $sql .= "$w->{clause} ";
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
945
    
cleanup
Yuki Kimoto authored on 2011-03-08
946
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
947
    $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
cleanup
Yuki Kimoto authored on 2011-10-21
948
      if $opt{relation};
cleanup
Yuki Kimoto authored on 2011-03-08
949
    
packaging one directory
yuki-kimoto authored on 2009-11-16
950
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
951
    $opt{statement} = 'select';
cleanup
Yuki Kimoto authored on 2011-10-21
952
    my $result = $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
953
    
micro optimization
Yuki Kimoto authored on 2011-10-23
954
    $result;
packaging one directory
yuki-kimoto authored on 2009-11-16
955
}
956

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
957
sub setup_model {
958
    my $self = shift;
959
    
cleanup
Yuki Kimoto authored on 2011-04-02
960
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
961
    $self->each_column(
962
        sub {
963
            my ($self, $table, $column, $column_info) = @_;
964
            if (my $model = $self->models->{$table}) {
965
                push @{$model->columns}, $column;
966
            }
967
        }
968
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
969
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
970
}
971

            
update pod
Yuki Kimoto authored on 2011-08-10
972
sub show_datatype {
973
    my ($self, $table) = @_;
974
    croak "Table name must be specified" unless defined $table;
975
    print "$table\n";
976
    
977
    my $result = $self->select(table => $table, where => "'0' <> '0'");
978
    my $sth = $result->sth;
979

            
980
    my $columns = $sth->{NAME};
981
    my $data_types = $sth->{TYPE};
982
    
983
    for (my $i = 0; $i < @$columns; $i++) {
984
        my $column = $columns->[$i];
985
        my $data_type = $data_types->[$i];
986
        print "$column: $data_type\n";
987
    }
988
}
989

            
990
sub show_typename {
991
    my ($self, $t) = @_;
992
    croak "Table name must be specified" unless defined $t;
993
    print "$t\n";
994
    
995
    $self->each_column(sub {
996
        my ($self, $table, $column, $infos) = @_;
997
        return unless $table eq $t;
998
        my $typename = $infos->{TYPE_NAME};
999
        print "$column: $typename\n";
1000
    });
1001
    
1002
    return $self;
1003
}
1004

            
test cleanup
Yuki Kimoto authored on 2011-08-15
1005
sub show_tables {
1006
    my $self = shift;
1007
    
1008
    my %tables;
1009
    $self->each_table(sub { $tables{$_[1]}++ });
1010
    print join("\n", sort keys %tables) . "\n";
1011
    return $self;
1012
}
1013

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

            
1017
    $self->{_type_rule_is_called} = 1;
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1018
    
1019
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
1020
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1021
        
1022
        # Into
cleanup
Yuki Kimoto authored on 2011-10-21
1023
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1024
            my $into = "into$i";
cleanup
Yuki Kimoto authored on 2011-08-16
1025
            my $exists_into = exists $type_rule->{$into};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1026
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1027
            $self->{type_rule} = $type_rule;
1028
            $self->{"_$into"} = {};
cleanup
Yuki Kimoto authored on 2011-10-21
1029
            for my $type_name (keys %{$type_rule->{$into} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1030
                croak qq{type name of $into section must be lower case}
1031
                  if $type_name =~ /[A-Z]/;
1032
            }
cleanup
Yuki Kimoto authored on 2011-08-16
1033
            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1034
            $self->each_column(sub {
1035
                my ($dbi, $table, $column, $column_info) = @_;
1036
                
1037
                my $type_name = lc $column_info->{TYPE_NAME};
1038
                if ($type_rule->{$into} &&
1039
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1040
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1041
                    return unless exists $type_rule->{$into}->{$type_name};
1042
                    if  (defined $filter && ref $filter ne 'CODE') 
1043
                    {
1044
                        my $fname = $filter;
1045
                        croak qq{Filter "$fname" is not registered" } . _subname
1046
                          unless exists $self->filters->{$fname};
1047
                        
1048
                        $filter = $self->filters->{$fname};
1049
                    }
1050

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1051
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1052
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1053
                }
1054
            });
1055
        }
1056

            
1057
        # From
cleanup
Yuki Kimoto authored on 2011-10-21
1058
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1059
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
cleanup
Yuki Kimoto authored on 2011-10-21
1060
            for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1061
                croak qq{data type of from$i section must be lower case or number}
1062
                  if $data_type =~ /[A-Z]/;
1063
                my $fname = $type_rule->{"from$i"}{$data_type};
1064
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1065
                    croak qq{Filter "$fname" is not registered" } . _subname
1066
                      unless exists $self->filters->{$fname};
1067
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1068
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1069
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1070
            }
1071
        }
1072
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1073
        return $self;
1074
    }
1075
    
1076
    return $self->{type_rule} || {};
1077
}
1078

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1082
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1083
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
1084
    my %opt = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1085
    warn "update param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
1086
    warn "update method where_param option is DEPRECATED!"
1087
      if $opt{where_param};
cleanup
Yuki Kimoto authored on 2011-10-21
1088
    $param ||= $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1089
    
cleanup
Yuki Kimoto authored on 2011-10-21
1090
    # Don't allow update all rows
1091
    croak qq{update method where option must be specified } . _subname
1092
      if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1093
    
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1094
    # Timestamp(DEPRECATED!)
cleanup
Yuki Kimoto authored on 2011-10-21
1095
    if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
1096
        warn "update timestamp option is DEPRECATED! use updated_at and now method";
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1097
        my $columns = $update_timestamp->[0];
1098
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1099
        my $value = $update_timestamp->[1];
1100
        $value = $value->() if ref $value eq 'CODE';
1101
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1102
    }
1103

            
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1104
    # Created time and updated time
1105
    my @timestamp_cleanup;
1106
    if (defined $opt{updated_at}) {
1107
        $param->{$opt{updated_at}} = $self->now->();
1108
        push @timestamp_cleanup, $opt{updated_at};
1109
    }
1110

            
cleanup
Yuki Kimoto authored on 2011-10-21
1111
    # Assign clause
cleanup
Yuki Kimoto authored on 2011-10-21
1112
    my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
cleanup
Yuki Kimoto authored on 2011-10-21
1113
    
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1114
    # Where
cleanup
Yuki Kimoto authored on 2011-10-25
1115
    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
1116
      delete $opt{id}, $opt{primary_key}, $opt{table});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1117
    
cleanup
Yuki Kimoto authored on 2011-04-02
1118
    # Update statement
cleanup
Yuki Kimoto authored on 2011-10-21
1119
    my $sql = "update ";
1120
    $sql .= "$opt{prefix} " if defined $opt{prefix};
cleanup
Yuki Kimoto authored on 2011-10-21
1121
    $sql .= $self->_q($opt{table}) . " set $assign_clause $w->{clause} ";
cleanup
Yuki Kimoto authored on 2011-01-27
1122
    
cleanup
yuki-kimoto authored on 2010-10-17
1123
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
1124
    $opt{statement} = 'update';
added EXPERIMENTAL insert cr...
Yuki Kimoto authored on 2011-10-25
1125
    $opt{cleanup} = \@timestamp_cleanup;
micro optimization and
Yuki Kimoto authored on 2011-10-25
1126
    $self->execute($sql, [$param, $w->{param}], %opt);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1127
}
1128

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1131
sub update_or_insert {
1132
    my $self = shift;
1133

            
cleanup
Yuki Kimoto authored on 2011-10-21
1134
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1135
    my $param  = shift;
1136
    my %opt = @_;
1137
    my $id = $opt{id};
1138
    my $primary_key = $opt{primary_key};
1139
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
1140
    croak "update_or_insert method need primary_key option " .
1141
          "when id is specified" . _subname
1142
      if defined $id && !defined $primary_key;
1143
    my $table  = $opt{table};
1144
    croak qq{"table" option must be specified } . _subname
1145
      unless defined $table;
1146
    my $select_option = $opt{select_option};
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
1147
    my $reuse = $opt{reuse};
1148
    $opt{select_option}->{reuse} = $opt{reuse} if $opt{reuse};
cleanup
Yuki Kimoto authored on 2011-10-21
1149
    
1150
    my $rows = $self->select(table => $table, id => $id,
1151
        primary_key => $primary_key, %$select_option)->all;
1152
    
1153
    croak "selected row count must be one or zero" . _subname
1154
      if @$rows > 1;
1155
    
1156
    my $row = $rows->[0];
1157
    my @opt = (table => $table);
1158
    push @opt, id => $id, primary_key => $primary_key if defined $id;
1159
    push @opt, %opt;
1160
    
1161
    if ($row) {
1162
        return $self->update($param, @opt);
1163
    }
1164
    else {
1165
        return $self->insert($param, @opt);
1166
    }
1167
}
1168

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-29
1533
sub _q {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1534
    my ($self, $value, $quotemeta) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1535
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1536
    my $quote = $self->{reserved_word_quote}
1537
      || $self->{quote} || $self->quote || '';
1538
    return "$quote$value$quote"
1539
      if !$quotemeta && ($quote eq '`' || $quote eq '"');
1540
    
cleanup
Yuki Kimoto authored on 2011-07-29
1541
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1542
    my $p;
1543
    if (defined $quote && length $quote > 1) {
1544
        $p = substr($quote, 1, 1);
1545
    }
1546
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1547
    
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1548
    if ($quotemeta) {
1549
        $q = quotemeta($q);
1550
        $p = quotemeta($p);
1551
    }
1552
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1553
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1554
}
1555

            
cleanup
Yuki Kimoto authored on 2011-04-02
1556
sub _remove_duplicate_table {
1557
    my ($self, $tables, $main_table) = @_;
1558
    
1559
    # Remove duplicate table
1560
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1561
    delete $tables{$main_table} if $main_table;
1562
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1563
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1564
    if (my $q = $self->_quote) {
1565
        $q = quotemeta($q);
1566
        $_ =~ s/[$q]//g for @$new_tables;
1567
    }
1568

            
1569
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1570
}
1571

            
cleanup
Yuki Kimoto authored on 2011-04-02
1572
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1573
    my ($self, $source) = @_;
1574
    
cleanup
Yuki Kimoto authored on 2011-04-02
1575
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1576
    my $tables = [];
1577
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1578
    my $q = $self->_quote;
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1579
    my $quoted_safety_character_re = $self->_q("?([$safety_character]+)", 1);
1580
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1581
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1582
    while ($source =~ /$table_re/g) {
1583
        push @$tables, $1;
1584
    }
1585
    
1586
    return $tables;
1587
}
1588

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1592
    $where ||= {};
cleanup
Yuki Kimoto authored on 2011-10-25
1593
    $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
cleanup
Yuki Kimoto authored on 2011-10-25
1594
    $where_param ||= {};
cleanup
Yuki Kimoto authored on 2011-10-21
1595
    my $w = {};
1596
    my $where_clause = '';
cleanup
Yuki Kimoto authored on 2011-10-25
1597

            
cleanup
Yuki Kimoto authored on 2011-10-25
1598
    my $obj;
1599
    
cleanup
Yuki Kimoto authored on 2011-10-21
1600
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1601
        $w->{clause} = "where " . $where->[0];
1602
        $w->{param} = $where->[1];
1603
    }
1604
    elsif (ref $where) {
cleanup
Yuki Kimoto authored on 2011-10-25
1605

            
1606
        # Hash
1607
        if (ref $where eq 'HASH') {
1608
            my $clause = ['and'];
1609
            my $q = $self->_quote;
1610
            for my $column (keys %$where) {
1611
                my $table;
1612
                my $c;
1613
                if ($column =~ /(?:(.*?)\.)?(.*)/) {
1614
                    $table = $1;
1615
                    $c = $2;
1616
                }
1617
                
1618
                my $table_quote;
1619
                $table_quote = $self->_q($table) if defined $table;
1620
                my $column_quote = $self->_q($c);
1621
                $column_quote = $table_quote . '.' . $column_quote
1622
                  if defined $table_quote;
1623
                push @$clause, "$column_quote = :$column" for keys %$where;
1624
            }
1625
            $obj = $self->where(clause => $clause, param => $where);
1626
        }
1627
        
1628
        # DBIx::Custom::Where object
1629
        elsif (ref $where eq 'DBIx::Custom::Where') {
1630
            $obj = $where;
1631
        }
1632
        
1633
        # Array
1634
        elsif (ref $where eq 'ARRAY') {
1635
            $obj = $self->where(
1636
                clause => $where->[0],
1637
                param  => $where->[1]
1638
            );
1639
        }
1640
        
1641
        # Check where argument
1642
        croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1643
            . qq{or array reference, which contains where clause and parameter}
1644
            . _subname
1645
          unless ref $obj eq 'DBIx::Custom::Where';
1646

            
1647

            
1648
        $w->{param} = keys %$where_param
1649
                    ? $self->merge_param($where_param, $obj->param)
1650
                    : $obj->param;
1651
        $w->{clause} = $obj->to_string;
cleanup
Yuki Kimoto authored on 2011-10-21
1652
    }
1653
    elsif ($where) {
1654
        $w->{clause} = "where $where";
cleanup
Yuki Kimoto authored on 2011-10-25
1655
        $w->{param} = $where_param;
cleanup
Yuki Kimoto authored on 2011-10-21
1656
    }
1657
    
1658
    return $w;
1659
}
1660

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

            
1664
    # Initialize filters
1665
    $self->{filter} ||= {};
micro optimization
Yuki Kimoto authored on 2011-07-30
1666
    $self->{filter}{on} = 1;
updated pod
Yuki Kimoto authored on 2011-06-21
1667
    $self->{filter}{out} ||= {};
1668
    $self->{filter}{in} ||= {};
1669
    $self->{filter}{end} ||= {};
1670
    
1671
    # Usage
1672
    my $usage = "Usage: \$dbi->apply_filter(" .
1673
                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1674
                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1675
    
1676
    # Apply filter
1677
    for (my $i = 0; $i < @cinfos; $i += 2) {
1678
        
1679
        # Column
1680
        my $column = $cinfos[$i];
1681
        if (ref $column eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-10-21
1682
            for my $c (@$column) {
updated pod
Yuki Kimoto authored on 2011-06-21
1683
                push @cinfos, $c, $cinfos[$i + 1];
1684
            }
1685
            next;
1686
        }
1687
        
1688
        # Filter infomation
1689
        my $finfo = $cinfos[$i + 1] || {};
1690
        croak "$usage (table: $table) " . _subname
1691
          unless  ref $finfo eq 'HASH';
cleanup
Yuki Kimoto authored on 2011-10-21
1692
        for my $ftype (keys %$finfo) {
updated pod
Yuki Kimoto authored on 2011-06-21
1693
            croak "$usage (table: $table) " . _subname
1694
              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1695
        }
1696
        
1697
        # Set filters
cleanup
Yuki Kimoto authored on 2011-10-21
1698
        for my $way (qw/in out end/) {
updated pod
Yuki Kimoto authored on 2011-06-21
1699
        
1700
            # Filter
1701
            my $filter = $finfo->{$way};
1702
            
1703
            # Filter state
1704
            my $state = !exists $finfo->{$way} ? 'not_exists'
1705
                      : !defined $filter        ? 'not_defined'
1706
                      : ref $filter eq 'CODE'   ? 'code'
1707
                      : 'name';
1708
            
1709
            # Filter is not exists
1710
            next if $state eq 'not_exists';
1711
            
1712
            # Check filter name
1713
            croak qq{Filter "$filter" is not registered } . _subname
1714
              if  $state eq 'name'
1715
               && ! exists $self->filters->{$filter};
1716
            
1717
            # Set filter
1718
            my $f = $state eq 'not_defined' ? undef
1719
                  : $state eq 'code'        ? $filter
1720
                  : $self->filters->{$filter};
1721
            $self->{filter}{$way}{$table}{$column} = $f;
1722
            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1723
            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1724
            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1725
        }
1726
    }
1727
    
1728
    return $self;
1729
}
1730

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1731
# DEPRECATED!
1732
has 'data_source';
1733
has dbi_options => sub { {} };
1734
has filter_check  => 1;
1735
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1736
has dbi_option => sub { {} };
1737
has default_dbi_option => sub {
1738
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1739
    return shift->default_option;
1740
};
1741

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1742
# DEPRECATED!
1743
sub method {
1744
    warn "method is DEPRECATED! use helper instead";
1745
    return shift->helper(@_);
1746
}
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1747

            
1748
# DEPRECATED!
1749
sub assign_param {
1750
    my $self = shift;
1751
    warn "assing_param is DEPRECATED! use assign_clause instead";
1752
    return $self->assign_clause(@_);
1753
}
1754

            
1755
# DEPRECATED
1756
sub update_param {
1757
    my ($self, $param, $opts) = @_;
1758
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1759
    warn "update_param is DEPRECATED! use assign_clause instead.";
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1760
    
1761
    # Create update parameter tag
1762
    my $tag = $self->assign_clause($param, $opts);
1763
    $tag = "set $tag" unless $opts->{no_set};
1764

            
1765
    return $tag;
1766
}
1767

            
updated pod
Yuki Kimoto authored on 2011-06-21
1768
# DEPRECATED!
1769
sub create_query {
1770
    warn "create_query is DEPRECATED! use query option of each method";
1771
    shift->_create_query(@_);
1772
}
1773

            
cleanup
Yuki Kimoto authored on 2011-06-13
1774
# DEPRECATED!
1775
sub apply_filter {
1776
    my $self = shift;
1777
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1778
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1779
    return $self->_apply_filter(@_);
1780
}
1781

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1788
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1789
    my $primary_keys = delete $opt{primary_key};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1790
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1791
    my $where = delete $opt{where};
1792
    my $param = delete $opt{param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1793
    
1794
    # Table
1795
    croak qq{"table" option must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1796
      unless $opt{table};
1797
    my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1798
    
1799
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1800
    my $where_param = $self->_id_to_param($where, $primary_keys);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1801
    
cleanup
Yuki Kimoto authored on 2011-10-21
1802
    return $self->select(where => $where_param, %opt);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1803
}
1804

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1809
    warn "delete_at is DEPRECATED! use delete method id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1810
    
cleanup
Yuki Kimoto authored on 2011-10-21
1811
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1812
    my $primary_keys = delete $opt{primary_key};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1813
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1814
    my $where = delete $opt{where};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1815
    
1816
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1817
    my $where_param = $self->_id_to_param($where, $primary_keys);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1818
    
cleanup
Yuki Kimoto authored on 2011-10-21
1819
    return $self->delete(where => $where_param, %opt);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1820
}
1821

            
cleanup
Yuki Kimoto authored on 2011-06-08
1822
# DEPRECATED!
1823
sub update_at {
1824
    my $self = shift;
1825

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

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1844
# DEPRECATED!
1845
sub insert_at {
1846
    my $self = shift;
1847
    
cleanup
Yuki Kimoto authored on 2011-10-21
1848
    warn "insert_at is DEPRECATED! use insert method id option instead";
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1849
    
cleanup
Yuki Kimoto authored on 2011-10-21
1850
    # Options
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1851
    my $param;
1852
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1853
    my %opt = @_;
1854
    my $primary_key = delete $opt{primary_key};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1855
    $primary_key = [$primary_key] unless ref $primary_key;
cleanup
Yuki Kimoto authored on 2011-10-21
1856
    my $where = delete $opt{where};
1857
    my $p = delete $opt{param} || {};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1858
    $param  ||= $p;
1859
    
1860
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1861
    my $where_param = $self->_id_to_param($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1862
    $param = $self->merge_param($where_param, $param);
1863
    
cleanup
Yuki Kimoto authored on 2011-10-21
1864
    return $self->insert(param => $param, %opt);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1865
}
1866

            
added warnings
Yuki Kimoto authored on 2011-06-07
1867
# DEPRECATED!
1868
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1869
    my $self = shift;
1870
    
added warnings
Yuki Kimoto authored on 2011-06-07
1871
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1872
    
1873
    # Merge tag
1874
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1875
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1876
    
1877
    return $self;
1878
}
1879

            
1880
# DEPRECATED!
1881
sub register_tag_processor {
1882
    my $self = shift;
1883
    warn "register_tag_processor is DEPRECATED!";
1884
    # Merge tag
1885
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1886
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1887
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1888
}
1889

            
cleanup
Yuki Kimoto authored on 2011-01-25
1890
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1891
sub default_bind_filter {
1892
    my $self = shift;
1893
    
cleanup
Yuki Kimoto authored on 2011-06-13
1894
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1895
    
cleanup
Yuki Kimoto authored on 2011-01-12
1896
    if (@_) {
1897
        my $fname = $_[0];
1898
        
1899
        if (@_ && !$fname) {
1900
            $self->{default_out_filter} = undef;
1901
        }
1902
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1903
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1904
              unless exists $self->filters->{$fname};
1905
        
1906
            $self->{default_out_filter} = $self->filters->{$fname};
1907
        }
1908
        return $self;
1909
    }
1910
    
1911
    return $self->{default_out_filter};
1912
}
1913

            
cleanup
Yuki Kimoto authored on 2011-01-25
1914
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1915
sub default_fetch_filter {
1916
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1917

            
cleanup
Yuki Kimoto authored on 2011-06-13
1918
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1919
    
1920
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1921
        my $fname = $_[0];
1922

            
cleanup
Yuki Kimoto authored on 2011-01-12
1923
        if (@_ && !$fname) {
1924
            $self->{default_in_filter} = undef;
1925
        }
1926
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1927
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1928
              unless exists $self->filters->{$fname};
1929
        
1930
            $self->{default_in_filter} = $self->filters->{$fname};
1931
        }
1932
        
1933
        return $self;
1934
    }
1935
    
many changed
Yuki Kimoto authored on 2011-01-23
1936
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1937
}
1938

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1939
# DEPRECATED!
1940
sub insert_param {
1941
    my $self = shift;
1942
    warn "insert_param is DEPRECATED! use values_clause instead";
1943
    return $self->values_clause(@_);
1944
}
1945

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1946
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1947
sub insert_param_tag {
1948
    warn "insert_param_tag is DEPRECATED! " .
1949
         "use insert_param instead!";
1950
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1951
}
1952

            
1953
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1954
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1955
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1956
         "use update_param instead";
1957
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1958
}
cleanup
Yuki Kimoto authored on 2011-03-08
1959
# DEPRECATED!
1960
sub _push_relation {
1961
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1962
    
1963
    if (keys %{$relation || {}}) {
micro optimization
Yuki Kimoto authored on 2011-09-30
1964
        $$sql .= $need_where ? 'where ' : 'and ';
cleanup
Yuki Kimoto authored on 2011-10-21
1965
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1966
            my $table1 = (split (/\./, $rcolumn))[0];
1967
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1968
            push @$tables, ($table1, $table2);
micro optimization
Yuki Kimoto authored on 2011-09-30
1969
            $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
cleanup
Yuki Kimoto authored on 2011-03-08
1970
        }
1971
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
1972
    $$sql =~ s/and $/ /;
cleanup
Yuki Kimoto authored on 2011-03-08
1973
}
1974

            
1975
# DEPRECATED!
1976
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1977
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1978
    
1979
    if (keys %{$relation || {}}) {
cleanup
Yuki Kimoto authored on 2011-10-21
1980
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1981
            my $table1 = (split (/\./, $rcolumn))[0];
1982
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1983
            my $table1_exists;
1984
            my $table2_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1985
            for my $table (@$tables) {
cleanup
Yuki Kimoto authored on 2011-03-08
1986
                $table1_exists = 1 if $table eq $table1;
1987
                $table2_exists = 1 if $table eq $table2;
1988
            }
1989
            unshift @$tables, $table1 unless $table1_exists;
1990
            unshift @$tables, $table2 unless $table2_exists;
1991
        }
1992
    }
1993
}
1994

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1997
=head1 NAME
1998

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

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

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
2003
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2004
    
2005
    # Connect
2006
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2007
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2008
        user => 'ken',
2009
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2010
        option => {mysql_enable_utf8 => 1}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2011
    );
cleanup
yuki-kimoto authored on 2010-08-05
2012

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
2013
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
2014
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
2015
    
2016
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
2017
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
2018
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
2019
    
2020
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
2021
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
2022

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2027
    # Select, more complex
2028
    my $result = $dbi->select(
2029
        table  => 'book',
2030
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
2031
            {book => [qw/title author/]},
2032
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2033
        ],
2034
        where  => {'book.author' => 'Ken'},
2035
        join => ['left outer join company on book.company_id = company.id'],
2036
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
2037
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2038
    
removed register_format()
yuki-kimoto authored on 2010-05-26
2039
    # Fetch
2040
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2041
        
removed register_format()
yuki-kimoto authored on 2010-05-26
2042
    }
2043
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2044
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
2045
    while (my $row = $result->fetch_hash) {
2046
        
2047
    }
2048
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2049
    # Execute SQL with parameter.
2050
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2051
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
2052
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2053
    );
2054
    
fix heading typos
Terrence Brannon authored on 2011-08-17
2055
=head1 DESCRIPTION
removed reconnect method
yuki-kimoto authored on 2010-05-28
2056

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2072
Named place holder support
2073

            
2074
=item *
2075

            
cleanup
Yuki Kimoto authored on 2011-07-29
2076
Model support
2077

            
2078
=item *
2079

            
2080
Connection manager support
2081

            
2082
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2083

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

            
2088
=item *
2089

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

            
2092
=item *
2093

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

            
2096
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2097

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2105
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2106
L<DBIx::Custom::Result>,
2107
L<DBIx::Custom::Query>,
2108
L<DBIx::Custom::Where>,
2109
L<DBIx::Custom::Model>,
2110
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2111

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

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

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

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

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

            
2125
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2126
        "dbi:mysql:database=$database",
2127
        $user,
2128
        $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2129
        DBIx::Custom->new->default_option
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2130
    );
2131
    
updated pod
Yuki Kimoto authored on 2011-06-21
2132
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2133

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

            
2137
    my $dbi = DBIx::Custom->connect(
2138
      dsn => $dsn, user => $user, password => $password, connector => 1);
2139
    
2140
    my $connector = $dbi->connector; # DBIx::Connector
2141

            
2142
Note that L<DBIx::Connector> must be installed.
2143

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

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

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

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

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2159
    {
2160
        RaiseError => 1,
2161
        PrintError => 0,
2162
        AutoCommit => 1,
2163
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2164

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

            
2167
    my $exclude_table = $dbi->exclude_table;
2168
    $dbi = $dbi->exclude_table(qr/pg_/);
2169

            
2170
Excluded table regex.
2171
C<each_column>, C<each_table>, C<type_rule>,
2172
and C<setup_model> methods ignore matching tables.
2173

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

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

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

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

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

            
2186
Get last successed SQL executed by C<execute> method.
2187

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

            
2190
    my $now = $dbi->now;
2191
    $dbi = $dbi->now($now);
2192

            
2193
Code reference which return time now, default to the following code reference.
2194

            
2195
    sub {
2196
        my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2197
        $mon++;
2198
        $year += 1900;
2199
        return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2200
    }
2201

            
2202
This return the time like "2011-10-14 05:05:27".
2203

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

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

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

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

            
2213
    my $option = $dbi->option;
2214
    $dbi = $dbi->option($option);
2215

            
2216
L<DBI> option, used when C<connect> method is executed.
2217
Each value in option override the value of C<default_option>.
2218

            
cleanup
yuki-kimoto authored on 2010-10-17
2219
=head2 C<password>
2220

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2241
You can set quote pair.
2242

            
2243
    $dbi->quote('[]');
2244

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2254
    my $safety_character = $dbi->safety_character;
2255
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2256

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

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

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

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

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

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

            
2273
    my $tag_parse = $dbi->tag_parse(0);
2274
    $dbi = $dbi->tag_parse;
2275

            
2276
Enable DEPRECATED tag parsing functionality, default to 1.
2277
If you want to disable tag parsing functionality, set to 0.
2278

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

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

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

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

            
2288
    my $user_column_info = $dbi->user_column_info;
2289
    $dbi = $dbi->user_column_info($user_column_info);
2290

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

            
2293
    [
2294
        {table => 'book', column => 'title', info => {...}},
2295
        {table => 'author', column => 'name', info => {...}}
2296
    ]
2297

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

            
2300
    my $user_column_info
2301
      = $dbi->get_column_info(exclude_table => qr/^system/);
2302
    $dbi->user_column_info($user_column_info);
2303

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

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

            
2309
    my $user_table_info = $dbi->user_table_info;
2310
    $dbi = $dbi->user_table_info($user_table_info);
2311

            
2312
You can set the following data.
2313

            
2314
    [
2315
        {table => 'book', info => {...}},
2316
        {table => 'author', info => {...}}
2317
    ]
2318

            
2319
Usually, you can set return value of C<get_table_info>.
2320

            
2321
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2322
    $dbi->user_table_info($user_table_info);
2323

            
2324
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2325
to find table info.
2326

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2363
Create column clause. The follwoing column clause is created.
2364

            
2365
    book.author as "book.author",
2366
    book.title as "book.title"
2367

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2370
    # Separator is hyphen
2371
    $dbi->separator('-');
2372
    
2373
    book.author as "book-author",
2374
    book.title as "book-title"
2375
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2376
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2377

            
update pod
Yuki Kimoto authored on 2011-03-13
2378
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2379
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2380
        user => 'ken',
2381
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2382
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2383
    );
2384

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

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

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

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

            
2395
Get rows count.
2396

            
2397
Options is same as C<select> method's ones.
2398

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2401
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2402
        table => 'book',
2403
        primary_key => 'id',
2404
        join => [
2405
            'inner join company on book.comparny_id = company.id'
2406
        ],
2407
    );
2408

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

            
2412
   $dbi->model('book')->select(...);
2413

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

            
2416
    my $dbh = $dbi->dbh;
2417

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

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

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

            
2425
Execute delete statement.
2426

            
2427
The following opitons are available.
2428

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

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

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

            
2436
=item C<id>
2437

            
2438
    id => 4
2439
    id => [4, 5]
2440

            
2441
ID corresponding to C<primary_key>.
2442
You can delete rows by C<id> and C<primary_key>.
2443

            
2444
    $dbi->delete(
fixed pod
Yuki Kimoto authored on 2011-10-20
2445
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2446
        id => [4, 5],
2447
        table => 'book',
2448
    );
2449

            
2450
The above is same as the followin one.
2451

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

            
2454
=item C<prefix>
2455

            
2456
    prefix => 'some'
2457

            
2458
prefix before table name section.
2459

            
2460
    delete some from book
2461

            
2462
=item C<table>
2463

            
2464
    table => 'book'
2465

            
2466
Table name.
2467

            
2468
=item C<where>
2469

            
2470
Same as C<select> method's C<where> option.
2471

            
2472
=back
2473

            
2474
=head2 C<delete_all>
2475

            
2476
    $dbi->delete_all(table => $table);
2477

            
2478
Execute delete statement for all rows.
2479
Options is same as C<delete>.
2480

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

            
2483
    $dbi->each_column(
2484
        sub {
2485
            my ($dbi, $table, $column, $column_info) = @_;
2486
            
2487
            my $type = $column_info->{TYPE_NAME};
2488
            
2489
            if ($type eq 'DATE') {
2490
                # ...
2491
            }
2492
        }
2493
    );
2494

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

            
2500
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2501
infromation, you can improve the performance of C<each_column> in
2502
the following way.
2503

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

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

            
2510
    $dbi->each_table(
2511
        sub {
2512
            my ($dbi, $table, $table_info) = @_;
2513
            
2514
            my $table_name = $table_info->{TABLE_NAME};
2515
        }
2516
    );
2517

            
improved pod
Yuki Kimoto authored on 2011-10-14
2518
Iterate all table informationsfrom in database.
2519
Argument is callback which is executed when one table is found.
2520
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2521
C<table information>.
2522

            
2523
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2524
infromation, you can improve the performance of C<each_table> in
2525
the following way.
2526

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

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

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

            
2538
    my $result = $dbi->execute(
2539
      "select * from book where title = :book.title and author like :book.author",
2540
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2541
    );
2542

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2549
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2550
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2551
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2552
    select * from book where title = :title and author like :author
2553
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2554
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2555
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2556

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2560
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2561
    select * from book where :title{=} and :author{like}
2562
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2563
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2564
    select * from where title = ? and author like ?;
2565

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

            
2570
    select * from where title = "aa\\:bb";
2571

            
cleanup
Yuki Kimoto authored on 2011-10-20
2572
B<OPTIONS>
2573

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

            
2576
=over 4
2577

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

            
2580
You can filter sql after the sql is build.
2581

            
2582
    after_build_sql => $code_ref
2583

            
2584
The following one is one example.
2585

            
2586
    $dbi->select(
2587
        table => 'book',
2588
        column => 'distinct(name)',
2589
        after_build_sql => sub {
2590
            "select count(*) from ($_[0]) as t1"
2591
        }
2592
    );
2593

            
2594
The following SQL is executed.
2595

            
2596
    select count(*) from (select distinct(name) from book) as t1;
2597

            
cleanup
Yuki Kimoto authored on 2011-10-20
2598
=item C<append>
2599

            
2600
    append => 'order by name'
2601

            
2602
Append some statement after SQL.
2603

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

            
2606
Specify database bind data type.
2607

            
2608
    bind_type => [image => DBI::SQL_BLOB]
2609
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2610

            
2611
This is used to bind parameter by C<bind_param> of statment handle.
2612

            
2613
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2614

            
update pod
Yuki Kimoto authored on 2011-03-13
2615
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2616
    
2617
    filter => {
2618
        title  => sub { uc $_[0] }
2619
        author => sub { uc $_[0] }
2620
    }
update pod
Yuki Kimoto authored on 2011-03-13
2621

            
updated pod
Yuki Kimoto authored on 2011-06-09
2622
    # Filter name
2623
    filter => {
2624
        title  => 'upper_case',
2625
        author => 'upper_case'
2626
    }
2627
        
2628
    # At once
2629
    filter => [
2630
        [qw/title author/]  => sub { uc $_[0] }
2631
    ]
2632

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

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

            
2640
    id => 4
2641
    id => [4, 5]
2642

            
2643
ID corresponding to C<primary_key>.
2644
You can delete rows by C<id> and C<primary_key>.
2645

            
2646
    $dbi->execute(
2647
        "select * from book where id1 = :id1 and id2 = :id2",
2648
        {},
fixed pod
Yuki Kimoto authored on 2011-10-20
2649
        primary_key => ['id1', 'id2'],
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2650
        id => [4, 5],
2651
    );
2652

            
2653
The above is same as the followin one.
2654

            
2655
    $dbi->execute(
2656
        "select * from book where id1 = :id1 and id2 = :id2",
2657
        {id1 => 4, id2 => 5}
2658
    );
2659

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

            
2662
    query => 1
2663

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

            
2667
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2668
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2669
    my $columns = $query->columns;
2670
    
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2671
=item C<primary_key>
2672

            
cleanup
Yuki Kimoto authored on 2011-10-20
2673
    primary_key => 'id'
2674
    primary_key => ['id1', 'id2']
2675

            
2676
Priamry key. This is used when C<id> option find primary key.
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2677

            
updated pod
Yuki Kimoto authored on 2011-06-09
2678
=item C<table>
2679
    
2680
    table => 'author'
2681

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2689
    # Same
2690
    $dbi->execute(
2691
      "select * from book where title = :book.title and author = :book.author",
2692
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2693

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

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

            
2698
Table alias. Key is real table name, value is alias table name.
2699
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2700
on alias table name.
2701

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2702
=item C<reuse EXPERIMENTAL>
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2703
    
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
2704
    reuse => $hash_ref
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2705

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2706
Reuse query object if the hash reference variable is set.
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2707
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2708
    my $queries = {};
2709
    $dbi->execute($sql, $param, reuse => $queries);
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2710

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

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

            
2716
    type_rule_off => 1
2717

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

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

            
2722
    type_rule1_off => 1
2723

            
2724
Turn C<into1> type rule off.
2725

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

            
2728
    type_rule2_off => 1
2729

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

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

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

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

            
2738
get column infomation except for one which match C<exclude_table> pattern.
2739

            
2740
    [
2741
        {table => 'book', column => 'title', info => {...}},
2742
        {table => 'author', column => 'name' info => {...}}
2743
    ]
2744

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

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

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

            
2751
    [
2752
        {table => 'book', info => {...}},
2753
        {table => 'author', info => {...}}
2754
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2755

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

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

            
2760
    $dbi->helper(
2761
        find_or_create   => sub {
2762
            my $self = shift;
2763
            
2764
            # Process
update_or_insert method's re...
Yuki Kimoto authored on 2011-10-27
2765
        },
2766
        ...
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2767
    );
2768

            
2769
Register helper. These helper is called directly from L<DBIx::Custom> object.
2770

            
2771
    $dbi->find_or_create;
2772

            
cleanup
yuki-kimoto authored on 2010-10-17
2773
=head2 C<insert>
2774

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

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

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

            
2783
    {date => \"NOW()"}
2784

            
cleanup
Yuki Kimoto authored on 2011-10-20
2785
B<options>
2786

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

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

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

            
2794
    created_at => 'created_datetime'
2795

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2802
    id => 4
2803
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2804

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2808
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2809
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
2810
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2811
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2812
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2813
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2814

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

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

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

            
2824
    prefix => 'or replace'
2825

            
2826
prefix before table name section
2827

            
2828
    insert or replace into book
2829

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

            
2832
    table => 'book'
2833

            
2834
Table name.
2835

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

            
2838
This option is same as C<update> method C<updated_at> option.
2839

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

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

            
2844
placeholder wrapped string.
2845

            
2846
If the following statement
2847

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

            
2851
is executed, the following SQL is executed.
2852

            
2853
    insert into book price values ( ? + 5 );
2854

            
update pod
Yuki Kimoto authored on 2011-03-13
2855
=back
2856

            
2857
=over 4
2858

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2866
    lib / MyModel.pm
2867
        / MyModel / book.pm
2868
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2869

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

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

            
2874
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2875
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2876
    
2877
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2878

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2883
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2884
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2885
    
2886
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2887

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2890
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2891
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2892
    
2893
    1;
2894
    
updated pod
Yuki Kimoto authored on 2011-06-21
2895
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2896

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

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

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

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

            
2906
    my $like_value = $dbi->like_value
2907

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

            
2910
    sub { "%$_[0]%" }
2911

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

            
2914
    my $mapper = $dbi->mapper(param => $param);
2915

            
2916
Create a new L<DBIx::Custom::Mapper> object.
2917

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

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

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

            
2924
    {key1 => [1, 1], key2 => 2}
2925

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

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

            
2930
    my $model = $dbi->model('book');
2931

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

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

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

            
2939
Create column clause for myself. The follwoing column clause is created.
2940

            
2941
    book.author as author,
2942
    book.title as title
2943

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

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

            
2953
Create a new L<DBIx::Custom> object.
2954

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

            
2957
    my $not_exists = $dbi->not_exists;
2958

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

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

            
2964
    my $order = $dbi->order;
2965

            
2966
Create a new L<DBIx::Custom::Order> object.
2967

            
cleanup
yuki-kimoto authored on 2010-10-17
2968
=head2 C<register_filter>
2969

            
update pod
Yuki Kimoto authored on 2011-03-13
2970
    $dbi->register_filter(
2971
        # Time::Piece object to database DATE format
2972
        tp_to_date => sub {
2973
            my $tp = shift;
2974
            return $tp->strftime('%Y-%m-%d');
2975
        },
2976
        # database DATE format to Time::Piece object
2977
        date_to_tp => sub {
2978
           my $date = shift;
2979
           return Time::Piece->strptime($date, '%Y-%m-%d');
2980
        }
2981
    );
cleanup
yuki-kimoto authored on 2010-10-17
2982
    
update pod
Yuki Kimoto authored on 2011-03-13
2983
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2984

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2987
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2988
        table  => 'book',
2989
        column => ['author', 'title'],
2990
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2991
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2992
    
updated document
Yuki Kimoto authored on 2011-06-09
2993
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2994

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3002
=item C<column>
3003
    
updated document
Yuki Kimoto authored on 2011-06-09
3004
    column => 'author'
3005
    column => ['author', 'title']
3006

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3015
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
3016
        {book => [qw/author title/]},
3017
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
3018
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
3019

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

            
3022
    book.author as "book.author",
3023
    book.title as "book.title",
3024
    person.name as "person.name",
3025
    person.age as "person.age"
3026

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

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

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

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

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

            
3040
    id => 4
3041
    id => [4, 5]
3042

            
3043
ID corresponding to C<primary_key>.
3044
You can select rows by C<id> and C<primary_key>.
3045

            
3046
    $dbi->select(
fixed pod
Yuki Kimoto authored on 2011-10-20
3047
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3048
        id => [4, 5],
3049
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3050
    );
3051

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3054
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3055
        where => {id1 => 4, id2 => 5},
3056
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3057
    );
3058
    
cleanup
Yuki Kimoto authored on 2011-10-20
3059
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3060

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

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

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

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

            
3073
    prefix => 'SQL_CALC_FOUND_ROWS'
3074

            
3075
Prefix of column cluase
3076

            
3077
    select SQL_CALC_FOUND_ROWS title, author from book;
3078

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

            
3081
    join => [
3082
        'left outer join company on book.company_id = company_id',
3083
        'left outer join location on company.location_id = location.id'
3084
    ]
3085
        
3086
Join clause. If column cluase or where clause contain table name like "company.name",
3087
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3088

            
3089
    $dbi->select(
3090
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3091
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3092
        where => {'company.name' => 'Orange'},
3093
        join => [
3094
            'left outer join company on book.company_id = company.id',
3095
            'left outer join location on company.location_id = location.id'
3096
        ]
3097
    );
3098

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3102
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3103
    from book
3104
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3105
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3106

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3107
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
3108
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3109

            
3110
    $dbi->select(
3111
        table => 'book',
3112
        column => ['company.location_id as location_id'],
3113
        where => {'company.name' => 'Orange'},
3114
        join => [
3115
            {
3116
                clause => 'left outer join location on company.location_id = location.id',
3117
                table => ['company', 'location']
3118
            }
3119
        ]
3120
    );
3121

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3126
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3127

            
updated document
Yuki Kimoto authored on 2011-06-09
3128
=item C<where>
3129
    
3130
    # Hash refrence
3131
    where => {author => 'Ken', 'title' => 'Perl'}
3132
    
3133
    # DBIx::Custom::Where object
3134
    where => $dbi->where(
3135
        clause => ['and', 'author = :author', 'title like :title'],
3136
        param  => {author => 'Ken', title => '%Perl%'}
3137
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3138
    
3139
    # Array reference 1 (array reference, hash referenc). same as above
3140
    where => [
3141
        ['and', 'author = :author', 'title like :title'],
3142
        {author => 'Ken', title => '%Perl%'}
3143
    ];    
3144
    
3145
    # Array reference 2 (String, hash reference)
3146
    where => [
3147
        'title like :title',
3148
        {title => '%Perl%'}
3149
    ]
3150
    
3151
    # String
3152
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3153

            
cleanup
Yuki Kimoto authored on 2011-10-20
3154
Where clause. See L<DBIx::Custom::Where>.
updated document
Yuki Kimoto authored on 2011-06-09
3155
    
update pod
Yuki Kimoto authored on 2011-03-12
3156
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3157

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

            
3160
    $dbi->setup_model;
3161

            
3162
Setup all model objects.
3163
C<columns> of model object is automatically set, parsing database information.
3164

            
3165
=head2 C<type_rule>
3166

            
3167
    $dbi->type_rule(
3168
        into1 => {
3169
            date => sub { ... },
3170
            datetime => sub { ... }
3171
        },
3172
        into2 => {
3173
            date => sub { ... },
3174
            datetime => sub { ... }
3175
        },
3176
        from1 => {
3177
            # DATE
3178
            9 => sub { ... },
3179
            # DATETIME or TIMESTAMP
3180
            11 => sub { ... },
3181
        }
3182
        from2 => {
3183
            # DATE
3184
            9 => sub { ... },
3185
            # DATETIME or TIMESTAMP
3186
            11 => sub { ... },
3187
        }
3188
    );
3189

            
3190
Filtering rule when data is send into and get from database.
3191
This has a little complex problem.
3192

            
3193
In C<into1> and C<into2> you can specify
3194
type name as same as type name defined
3195
by create table, such as C<DATETIME> or C<DATE>.
3196

            
3197
Note that type name and data type don't contain upper case.
3198
If these contain upper case charactor, you convert it to lower case.
3199

            
3200
C<into2> is executed after C<into1>.
3201

            
3202
Type rule of C<into1> and C<into2> is enabled on the following
3203
column name.
3204

            
3205
=over 4
3206

            
3207
=item 1. column name
3208

            
3209
    issue_date
3210
    issue_datetime
3211

            
3212
This need C<table> option in each method.
3213

            
3214
=item 2. table name and column name, separator is dot
3215

            
3216
    book.issue_date
3217
    book.issue_datetime
3218

            
3219
=back
3220

            
3221
You get all type name used in database by C<available_typename>.
3222

            
3223
    print $dbi->available_typename;
3224

            
3225
In C<from1> and C<from2> you specify data type, not type name.
3226
C<from2> is executed after C<from1>.
3227
You get all data type by C<available_datatype>.
3228

            
3229
    print $dbi->available_datatype;
3230

            
3231
You can also specify multiple types at once.
3232

            
3233
    $dbi->type_rule(
3234
        into1 => [
3235
            [qw/DATE DATETIME/] => sub { ... },
3236
        ],
3237
    );
3238

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

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

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

            
3245
If you want to set constant value to row data, use scalar reference
3246
as parameter value.
3247

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3259
    id => 4
3260
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3261

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3265
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3266
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
3267
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3268
        id => [4, 5],
3269
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3270
    );
update pod
Yuki Kimoto authored on 2011-03-13
3271

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3274
    $dbi->update(
3275
        {title => 'Perl', author => 'Ken'}
3276
        where => {id1 => 4, id2 => 5},
3277
        table => 'book'
3278
    );
update pod
Yuki Kimoto authored on 2011-03-13
3279

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

            
3282
    prefix => 'or replace'
3283

            
3284
prefix before table name section
3285

            
3286
    update or replace book
3287

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

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

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

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

            
3296
Same as C<select> method's C<where> option.
3297

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

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

            
3302
placeholder wrapped string.
3303

            
3304
If the following statement
3305

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

            
3309
is executed, the following SQL is executed.
3310

            
3311
    update book set price =  ? + 5;
3312

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

            
3315
    updated_at => 'updated_datetime'
3316

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

            
updated pod
Yuki Kimoto authored on 2011-06-08
3321
=back
update pod
Yuki Kimoto authored on 2011-03-13
3322

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

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

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

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3330
=head2 C<update_or_insert EXPERIMENTAL>
3331
    
3332
    # Where
3333
    $dbi->update_or_insert(
3334
        {id => 1, title => 'Perl'},
3335
        table => 'book',
3336
        where => {id => 1},
3337
        select_option => {append => 'for update'}
3338
    );
3339
    
3340
    # ID
3341
    $dbi->update_or_insert(
3342
        {title => 'Perl'},
3343
        table => 'book',
3344
        id => 1,
3345
        primary_key => 'id',
3346
        select_option => {append => 'for update'}
3347
    );
3348
    
3349
Update or insert.
3350

            
3351
In both examples, the following SQL is executed.
3352

            
3353
    # In case insert
3354
    insert into book (id, title) values (?, ?)
3355
    
3356
    # In case update
3357
    update book set (id = ?, title = ?) where book.id = ?
3358

            
3359
The following opitons are available adding to C<update> option.
3360

            
3361
=over 4
3362

            
3363
=item C<select_option>
3364

            
3365
    select_option => {append => 'for update'}
3366

            
3367
select method option,
3368
select method is used to check the row is already exists.
3369

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

            
3372
    $dbi->show_datatype($table);
3373

            
3374
Show data type of the columns of specified table.
3375

            
3376
    book
3377
    title: 5
3378
    issue_date: 91
3379

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

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

            
3384
    $dbi->show_tables;
3385

            
3386
Show tables.
3387

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

            
3390
    $dbi->show_typename($table);
3391

            
3392
Show type name of the columns of specified table.
3393

            
3394
    book
3395
    title: varchar
3396
    issue_date: date
3397

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

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

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

            
3404
Create values clause.
3405

            
3406
    (title, author) values (title = :title, age = :age);
3407

            
3408
You can use this in insert statement.
3409

            
3410
    my $insert_sql = "insert into book $values_clause";
3411

            
3412
=head2 C<where>
3413

            
3414
    my $where = $dbi->where(
3415
        clause => ['and', 'title = :title', 'author = :author'],
3416
        param => {title => 'Perl', author => 'Ken'}
3417
    );
3418

            
3419
Create a new L<DBIx::Custom::Where> object.
3420

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

            
3423
=head2 C<DBIX_CUSTOM_DEBUG>
3424

            
3425
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3426
executed SQL and bind values are printed to STDERR.
3427

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

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

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

            
3434
L<DBIx::Custom>
3435

            
3436
    # Attribute methods
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
3437
    default_dbi_option # will be removed 2017/1/1
3438
    dbi_option # will be removed 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3439
    data_source # will be removed at 2017/1/1
3440
    dbi_options # will be removed at 2017/1/1
3441
    filter_check # will be removed at 2017/1/1
3442
    reserved_word_quote # will be removed at 2017/1/1
3443
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3444
    
3445
    # Methods
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
3446
    update_timestamp # will be removed at 2017/1/1
3447
    insert_timestamp # will be removed at 2017/1/1
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3448
    method # will be removed at 2017/1/1
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
3449
    assign_param # will be removed at 2017/1/1
3450
    update_param # will be removed at 2017/1/1
3451
    insert_param # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3452
    create_query # will be removed at 2017/1/1
3453
    apply_filter # will be removed at 2017/1/1
3454
    select_at # will be removed at 2017/1/1
3455
    delete_at # will be removed at 2017/1/1
3456
    update_at # will be removed at 2017/1/1
3457
    insert_at # will be removed at 2017/1/1
3458
    register_tag # will be removed at 2017/1/1
3459
    default_bind_filter # will be removed at 2017/1/1
3460
    default_fetch_filter # will be removed at 2017/1/1
3461
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3462
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3463
    register_tag_processor # will be removed at 2017/1/1
3464
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3465
    
3466
    # Options
- insert timestamp option is...
Yuki Kimoto authored on 2011-10-25
3467
    update timestamp option # will be removed 2017/1/1
3468
    insert timestamp option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3469
    select method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3470
    delete method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3471
    update method where_param option # will be removed 2017/1/1
cleanup
Yuki Kimoto authored on 2011-10-21
3472
    insert method param option # will be removed at 2017/1/1
insert method's id option is...
Yuki Kimoto authored on 2011-10-10
3473
    insert method id option # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3474
    select method relation option # will be removed at 2017/1/1
3475
    select method column option [COLUMN, as => ALIAS] format
3476
      # will be removed at 2017/1/1
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3477
    execute method's sqlfilter option # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3478
    
3479
    # Others
micro optimization and
Yuki Kimoto authored on 2011-10-25
3480
    execute($query, ...) # execute method receiving query object.
3481
                         # this is removed at 2017/1/1
cleanup
Yuki Kimoto authored on 2011-07-28
3482
    execute("select * from {= title}"); # execute method's
3483
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3484
                                        # will be removed at 2017/1/1
3485
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3486

            
3487
L<DBIx::Custom::Model>
3488

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3489
    # Attribute methods
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3490
    method # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3491
    filter # will be removed at 2017/1/1
3492
    name # will be removed at 2017/1/1
3493
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3494

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

            
3505
L<DBIx::Custom::QueryBuilder>
3506
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3507
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3508
    tags # will be removed at 2017/1/1
3509
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3510
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3511
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3512
    register_tag # will be removed at 2017/1/1
3513
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3514
    
3515
    # Others
3516
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3517
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3518

            
3519
L<DBIx::Custom::Result>
3520
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3521
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3522
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3523
    
3524
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3525
    end_filter # will be removed at 2017/1/1
3526
    remove_end_filter # will be removed at 2017/1/1
3527
    remove_filter # will be removed at 2017/1/1
3528
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3529

            
3530
L<DBIx::Custom::Tag>
3531

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

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

            
3536
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3537
except for attribute method.
3538
You can check all DEPRECATED functionalities by document.
3539
DEPRECATED functionality is removed after five years,
3540
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
3541
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3542

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

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

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

            
3549
C<< <kimoto.yuki at gmail.com> >>
3550

            
3551
L<http://github.com/yuki-kimoto/DBIx-Custom>
3552

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3553
=head1 AUTHOR
3554

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

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

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

            
3561
This program is free software; you can redistribute it and/or modify it
3562
under the same terms as Perl itself.
3563

            
3564
=cut