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

            
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
4
our $VERSION = '0.1738';
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 { {} },
cleanup
Yuki Kimoto authored on 2011-08-13
55
    query_builder => sub {
56
        my $self = shift;
57
        my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
58
        weaken $builder->{dbi};
59
        return $builder;
60
    },
update pod
Yuki Kimoto authored on 2011-03-13
61
    result_class  => 'DBIx::Custom::Result',
62
    safety_character => '\w',
cleanup test
Yuki Kimoto authored on 2011-08-10
63
    separator => '.',
added tag_parse attribute
Yuki Kimoto authored on 2011-06-28
64
    stash => sub { {} },
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
65
    tag_parse => 1;
cleanup
yuki-kimoto authored on 2010-10-17
66

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

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

            
added helper method
yuki-kimoto authored on 2010-10-17
98
our $AUTOLOAD;
99
sub AUTOLOAD {
100
    my $self = shift;
101

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
234
sub delete {
235
    my ($self, %opt) = @_;
236
    warn "delete method where_param option is DEPRECATED!"
237
      if $opt{where_param};
238
    
cleanup
Yuki Kimoto authored on 2011-10-21
239
    # Don't allow delete all rows
cleanup
Yuki Kimoto authored on 2011-10-21
240
    croak qq{delete method where or id option must be specified } . _subname
241
      if !$opt{where} && !defined $opt{id} && !$opt{allow_delete_all};
242
    
243
    # Where
244
    my $where = defined $opt{id}
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
245
           ? $self->_id_to_param(delete $opt{id}, $opt{primary_key}, $opt{table})
cleanup
Yuki Kimoto authored on 2011-10-21
246
           : $opt{where};
247
    my $w = $self->_where_clause_and_param($where, $opt{where_param});
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
248

            
cleanup
Yuki Kimoto authored on 2011-04-02
249
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-10-21
250
    my $sql = "delete ";
cleanup
Yuki Kimoto authored on 2011-10-21
251
    $sql .= "$opt{prefix} " if defined $opt{prefix};
cleanup
Yuki Kimoto authored on 2011-10-21
252
    $sql .= "from " . $self->_q($opt{table}) . " $w->{clause} ";
packaging one directory
yuki-kimoto authored on 2009-11-16
253
    
254
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
255
    $opt{statement} = 'delete';
micro optimization
Yuki Kimoto authored on 2011-10-23
256
    $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
257
}
258

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

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

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

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

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

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

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

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

            
355
    # Options
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
356
    my $param;
357
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
358
    my %opt = @_;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
359
    warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
360
    $param ||= $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-10-21
361
    my $tables = $opt{table} || [];
cleanup
Yuki Kimoto authored on 2011-04-02
362
    $tables = [$tables] unless ref $tables eq 'ARRAY';
micro optimization
Yuki Kimoto authored on 2011-10-23
363
    my $filter = ref $opt{filter} eq 'ARRAY' ?
364
      _array_to_hash($opt{filter}) : $opt{filter};
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
365
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
366
    # Append
367
    $sql .= $opt{append} if defined $opt{append} && !ref $sql;
368
    
369
    # Query
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
370
    my $query;
371
    if (ref $sql) { $query = $sql }
372
    else {
373
        $query = $opt{reuse}->{$sql} if $opt{reuse};
374
        $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter})
375
          unless $query;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
376
        $query->statement($opt{statement} || '');
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
377
        $opt{reuse}->{$sql} = $query if $opt{reuse};
378
    }
379
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
380
    # Save query
micro optimization
Yuki Kimoto authored on 2011-10-23
381
    $self->{last_sql} = $query->{sql};
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
382

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
383
    # Return query
384
    return $query if $opt{query};
micro optimization
Yuki Kimoto authored on 2011-07-30
385
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
386
    # Merge query filter(DEPRECATED!)
DBIx::Custom::Query filter m...
Yuki Kimoto authored on 2011-07-30
387
    $filter ||= $query->{filter} || {};
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
388
    
cleanup
Yuki Kimoto authored on 2011-04-02
389
    # Tables
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
390
    unshift @$tables, @{$query->{tables} || []};
micro optimization
Yuki Kimoto authored on 2011-07-30
391
    my $main_table = @{$tables}[-1];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
392

            
393
    # Merge id to parameter
394
    my @cleanup;
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
395
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
396
        croak "execute id option must be specified with primary_key option"
397
          unless $opt{primary_key};
398
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
399
        $opt{id} = [$opt{id}] unless ref $opt{id};
400
        my $statement = $query->statement;
401
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
402
           my $key = $opt{primary_key}->[$i];
403
           $key = "$main_table.$key" if $statement eq 'update' ||
404
             $statement eq 'delete' || $statement eq 'select';
405
           next if exists $param->{$key};
406
           $param->{$key} = $opt{id}->[$i];
407
           push @cleanup, $key;
408
        }
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
409
    }
micro optimization
Yuki Kimoto authored on 2011-07-30
410
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
411
    # Cleanup tables(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
412
    $tables = $self->_remove_duplicate_table($tables, $main_table)
413
      if @$tables > 1;
cleanup
Yuki Kimoto authored on 2011-04-02
414
    
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
415
    # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
416
    my $type_filters = {};
micro optimization
Yuki Kimoto authored on 2011-10-23
417
    if ($self->{_type_rule_is_called}) {
418
        unless ($opt{type_rule_off}) {
419
            my $type_rule_off_parts = {
420
                1 => $opt{type_rule1_off},
421
                2 => $opt{type_rule2_off}
422
            };
423
            for my $i (1, 2) {
424
                unless ($type_rule_off_parts->{$i}) {
425
                    $type_filters->{$i} = {};
426
                    my $table_alias = $opt{table_alias} || {};
427
                    for my $alias (keys %$table_alias) {
428
                        my $table = $table_alias->{$alias};
429
                        
430
                        for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
431
                            $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
432
                        }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
433
                    }
micro optimization
Yuki Kimoto authored on 2011-10-23
434
                    $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
435
                      if $main_table;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
436
                }
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
437
            }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
438
        }
439
    }
cleanup
Yuki Kimoto authored on 2011-04-02
440
    
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
441
    # Applied filter(DEPRECATED!)
micro optimization
Yuki Kimoto authored on 2011-07-30
442
    if ($self->{filter}{on}) {
443
        my $applied_filter = {};
cleanup
Yuki Kimoto authored on 2011-10-21
444
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-07-30
445
            $applied_filter = {
446
                %$applied_filter,
447
                %{$self->{filter}{out}->{$table} || {}}
448
            }
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
449
        }
micro optimization
Yuki Kimoto authored on 2011-07-30
450
        $filter = {%$applied_filter, %$filter};
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
451
    }
452
    
cleanup
Yuki Kimoto authored on 2011-04-02
453
    # Replace filter name to code
cleanup
Yuki Kimoto authored on 2011-10-21
454
    for my $column (keys %$filter) {
cleanup
Yuki Kimoto authored on 2011-04-02
455
        my $name = $filter->{$column};
456
        if (!defined $name) {
457
            $filter->{$column} = undef;
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
458
        }
cleanup
Yuki Kimoto authored on 2011-04-02
459
        elsif (ref $name ne 'CODE') {
cleanup
Yuki Kimoto authored on 2011-04-25
460
          croak qq{Filter "$name" is not registered" } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
461
            unless exists $self->filters->{$name};
462
          $filter->{$column} = $self->filters->{$name};
cleanup
Yuki Kimoto authored on 2010-12-21
463
        }
464
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
465
    
cleanup
Yuki Kimoto authored on 2011-04-02
466
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
467
    my ($bind, $bind_types) = $self->_create_bind_values($param, $query->columns,
468
      $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
469

            
cleanup
yuki-kimoto authored on 2010-10-17
470
    # Execute
micro optimization
Yuki Kimoto authored on 2011-10-23
471
    my $sth = $query->{sth};
cleanup
yuki-kimoto authored on 2010-10-17
472
    my $affected;
cleanup
Yuki Kimoto authored on 2011-03-21
473
    eval {
micro optimization
Yuki Kimoto authored on 2011-10-23
474
        if ($opt{bind_type} || $opt{type}) {
475
            $sth->bind_param($_ + 1, $bind->[$_],
476
                $bind_types->[$_] ? $bind_types->[$_] : ())
477
              for (0 .. @$bind - 1);
478
            $affected = $sth->execute;
479
        }
480
        else {
481
            $affected = $sth->execute(@$bind);
482
        }
cleanup
Yuki Kimoto authored on 2011-03-21
483
    };
improved error messages
Yuki Kimoto authored on 2011-04-18
484
    
micro optimization
Yuki Kimoto authored on 2011-07-30
485
    $self->_croak($@, qq{. Following SQL is executed.\n}
486
      . qq{$query->{sql}\n} . _subname) if $@;
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
487

            
488
    # Remove id from parameter
489
    delete $param->{$_} for @cleanup;
cleanup
yuki-kimoto authored on 2010-10-17
490
    
improved debug message
Yuki Kimoto authored on 2011-05-23
491
    # DEBUG message
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
492
    if ($ENV{DBIX_CUSTOM_DEBUG}) {
493
        warn "SQL:\n" . $query->sql . "\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
494
        my @output;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
495
        for my $value (@$bind) {
improved debug message
Yuki Kimoto authored on 2011-05-23
496
            $value = 'undef' unless defined $value;
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
497
            $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
improved debug message
Yuki Kimoto authored on 2011-05-23
498
              if utf8::is_utf8($value);
499
            push @output, $value;
500
        }
fixed DEBUG messsage bug
Yuki Kimoto authored on 2011-10-24
501
        warn "Bind values: " . join(', ', @output) . "\n\n";
improved debug message
Yuki Kimoto authored on 2011-05-23
502
    }
added environment variable D...
Yuki Kimoto authored on 2011-04-02
503
    
micro optimization
Yuki Kimoto authored on 2011-10-23
504
    # Not select statement
505
    return $affected unless $sth->{NUM_OF_FIELDS};
506

            
507
    # Filter(DEPRECATED!)
508
    my $infilter = {};
509
    if ($self->{filter}{on}) {
510
        $infilter->{in}  = {};
511
        $infilter->{end} = {};
512
        push @$tables, $main_table if $main_table;
513
        for my $table (@$tables) {
514
            for my $way (qw/in end/) {
515
                $infilter->{$way} = {%{$infilter->{$way}},
516
                  %{$self->{filter}{$way}{$table} || {}}};
cleanup
Yuki Kimoto authored on 2011-04-02
517
            }
cleanup
Yuki Kimoto authored on 2011-01-12
518
        }
cleanup
yuki-kimoto authored on 2010-10-17
519
    }
micro optimization
Yuki Kimoto authored on 2011-10-23
520
    
521
    # Result
522
    my $result = $self->result_class->new(
523
        sth => $sth,
524
        dbi => $self,
525
        default_filter => $self->{default_in_filter},
526
        filter => $infilter->{in} || {},
527
        end_filter => $infilter->{end} || {},
528
        type_rule => {
529
            from1 => $self->type_rule->{from1},
530
            from2 => $self->type_rule->{from2}
531
        },
532
    );
533
    $result;
cleanup
yuki-kimoto authored on 2010-10-17
534
}
535

            
added test
Yuki Kimoto authored on 2011-08-16
536
sub get_table_info {
cleanup
Yuki Kimoto authored on 2011-10-21
537
    my ($self, %opt) = @_;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
538
    
cleanup
Yuki Kimoto authored on 2011-10-21
539
    my $exclude = delete $opt{exclude};
540
    croak qq/"$_" is wrong option/ for keys %opt;
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
541
    
added test
Yuki Kimoto authored on 2011-08-16
542
    my $table_info = [];
543
    $self->each_table(
544
        sub { push @$table_info, {table => $_[1], info => $_[2] } },
545
        exclude => $exclude
546
    );
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
547
    
cleanup test
Yuki Kimoto authored on 2011-08-16
548
    return [sort {$a->{table} cmp $b->{table} } @$table_info];
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
549
}
550

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
551
sub get_column_info {
cleanup
Yuki Kimoto authored on 2011-10-21
552
    my ($self, %opt) = @_;
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
553
    
cleanup
Yuki Kimoto authored on 2011-10-21
554
    my $exclude_table = delete $opt{exclude_table};
555
    croak qq/"$_" is wrong option/ for keys %opt;
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
556
    
557
    my $column_info = [];
558
    $self->each_column(
559
        sub { push @$column_info, {table => $_[1], column => $_[2], info => $_[3] } },
560
        exclude_table => $exclude_table
561
    );
562
    
563
    return [
564
      sort {$a->{table} cmp $b->{table} || $a->{column} cmp $b->{column} }
cleanup
Yuki Kimoto authored on 2011-08-16
565
        @$column_info];
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
566
}
567

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
568
sub helper {
569
    my $self = shift;
570
    
571
    # Register method
572
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
573
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
574
    
575
    return $self;
576
}
577

            
cleanup
yuki-kimoto authored on 2010-10-17
578
sub insert {
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
579
    my $self = shift;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
580
    
cleanup
Yuki Kimoto authored on 2011-10-21
581
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
582
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
583
    my %opt = @_;
micro optimization
Yuki Kimoto authored on 2011-10-23
584
    warn "insert method param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
585
    $param ||= delete $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
586
    
587
    # Timestamp
cleanup
Yuki Kimoto authored on 2011-10-21
588
    if ($opt{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
589
        my $columns = $insert_timestamp->[0];
590
        $columns = [$columns] unless ref $columns eq 'ARRAY';
591
        my $value = $insert_timestamp->[1];
592
        $value = $value->() if ref $value eq 'CODE';
593
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
594
    }
cleanup
Yuki Kimoto authored on 2011-10-21
595
    
596
    # Merge id to parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
597
    my @cleanup;
micro optimization
Yuki Kimoto authored on 2011-10-23
598
    if (defined $opt{id}) {
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
599
        croak "insert id option must be specified with primary_key option"
micro optimization
Yuki Kimoto authored on 2011-10-23
600
          unless $opt{primary_key};
601
        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
602
        $opt{id} = [$opt{id}] unless ref $opt{id};
603
        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
604
           my $key = $opt{primary_key}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
605
           next if exists $param->{$key};
micro optimization
Yuki Kimoto authored on 2011-10-23
606
           $param->{$key} = $opt{id}->[$i];
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
607
           push @cleanup, $key;
micro optimization
Yuki Kimoto authored on 2011-10-23
608
        }
609
    }
cleanup
Yuki Kimoto authored on 2011-10-21
610
    
cleanup
Yuki Kimoto authored on 2011-04-02
611
    # Insert statement
cleanup
Yuki Kimoto authored on 2011-10-21
612
    my $sql = "insert ";
cleanup
Yuki Kimoto authored on 2011-10-21
613
    $sql .= "$opt{prefix} " if defined $opt{prefix};
614
    $sql .= "into " . $self->_q($opt{table}) . " "
615
      . $self->values_clause($param, {wrap => $opt{wrap}}) . " ";
micro optimization
Yuki Kimoto authored on 2011-10-23
616

            
617
    # Remove id from parameter
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
618
    delete $param->{$_} for @cleanup;
packaging one directory
yuki-kimoto authored on 2009-11-16
619
    
620
    # Execute query
micro optimization
Yuki Kimoto authored on 2011-10-23
621
    $opt{statement} = 'insert';
micro optimization
Yuki Kimoto authored on 2011-10-23
622
    $self->execute($sql, $param, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
623
}
624

            
micro optimization
Yuki Kimoto authored on 2011-10-23
625
sub _merge_id_to_param {
626
    my ($self, $id, $primary_keys, $param) = @_;
627
    
628
    # Create parameter
629
    $id = [$id] unless ref $id;
630
    
631
    return $param;
632
}
633

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
634
sub insert_timestamp {
635
    my $self = shift;
636
    
637
    if (@_) {
638
        $self->{insert_timestamp} = [@_];
639
        
640
        return $self;
641
    }
642
    return $self->{insert_timestamp};
643
}
644

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
645
sub include_model {
646
    my ($self, $name_space, $model_infos) = @_;
647
    
cleanup
Yuki Kimoto authored on 2011-04-02
648
    # Name space
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
649
    $name_space ||= '';
cleanup
Yuki Kimoto authored on 2011-04-02
650
    
651
    # Get Model infomations
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
652
    unless ($model_infos) {
cleanup
Yuki Kimoto authored on 2011-04-02
653

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
654
        # Load name space module
cleanup
Yuki Kimoto authored on 2011-04-25
655
        croak qq{"$name_space" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
656
          if $name_space =~ /[^\w:]/;
657
        eval "use $name_space";
cleanup
Yuki Kimoto authored on 2011-04-25
658
        croak qq{Name space module "$name_space.pm" is needed. $@ }
659
            . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
660
          if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
661
        
662
        # Search model modules
663
        my $path = $INC{"$name_space.pm"};
664
        $path =~ s/\.pm$//;
665
        opendir my $dh, $path
cleanup
Yuki Kimoto authored on 2011-04-25
666
          or croak qq{Can't open directory "$path": $! } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
667
        $model_infos = [];
668
        while (my $module = readdir $dh) {
669
            push @$model_infos, $module
670
              if $module =~ s/\.pm$//;
671
        }
672
        close $dh;
673
    }
674
    
cleanup
Yuki Kimoto authored on 2011-04-02
675
    # Include models
cleanup
Yuki Kimoto authored on 2011-10-21
676
    for my $model_info (@$model_infos) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
677
        
cleanup
Yuki Kimoto authored on 2011-04-02
678
        # Load model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
679
        my $model_class;
680
        my $model_name;
681
        my $model_table;
682
        if (ref $model_info eq 'HASH') {
683
            $model_class = $model_info->{class};
684
            $model_name  = $model_info->{name};
685
            $model_table = $model_info->{table};
686
            
687
            $model_name  ||= $model_class;
688
            $model_table ||= $model_name;
689
        }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
690
        else { $model_class = $model_name = $model_table = $model_info }
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
691
        my $mclass = "${name_space}::$model_class";
cleanup
Yuki Kimoto authored on 2011-04-25
692
        croak qq{"$mclass" is invalid class name } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
693
          if $mclass =~ /[^\w:]/;
694
        unless ($mclass->can('isa')) {
695
            eval "use $mclass";
cleanup
Yuki Kimoto authored on 2011-04-25
696
            croak "$@ " . _subname if $@;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
697
        }
698
        
cleanup
Yuki Kimoto authored on 2011-04-02
699
        # Create model
cleanup
Yuki Kimoto authored on 2011-10-21
700
        my $opt = {};
701
        $opt->{model_class} = $mclass if $mclass;
702
        $opt->{name}        = $model_name if $model_name;
703
        $opt->{table}       = $model_table if $model_table;
704
        $self->create_model($opt);
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
705
    }
706
    
707
    return $self;
708
}
709

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

            
added DBIx::Custom::Mapper
Yuki Kimoto authored on 2011-08-26
712
sub mapper {
713
    my $self = shift;
714
    return DBIx::Custom::Mapper->new(@_);
715
}
716

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
717
sub merge_param {
718
    my ($self, @params) = @_;
719
    
cleanup
Yuki Kimoto authored on 2011-04-02
720
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
721
    my $merge = {};
cleanup
Yuki Kimoto authored on 2011-10-21
722
    for my $param (@params) {
723
        for my $column (keys %$param) {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
724
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
725
            
726
            if (exists $merge->{$column}) {
727
                $merge->{$column} = [$merge->{$column}]
728
                  unless ref $merge->{$column} eq 'ARRAY';
729
                push @{$merge->{$column}},
730
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
731
            }
732
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
733
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
734
            }
735
        }
736
    }
737
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
738
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
739
}
740

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
741
sub model {
742
    my ($self, $name, $model) = @_;
743
    
cleanup
Yuki Kimoto authored on 2011-04-02
744
    # Set model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
745
    if ($model) {
746
        $self->models->{$name} = $model;
747
        return $self;
748
    }
749
    
750
    # Check model existance
cleanup
Yuki Kimoto authored on 2011-04-25
751
    croak qq{Model "$name" is not included } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
752
      unless $self->models->{$name};
753
    
cleanup
Yuki Kimoto authored on 2011-04-02
754
    # Get model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
755
    return $self->models->{$name};
756
}
757

            
cleanup
Yuki Kimoto authored on 2011-03-21
758
sub mycolumn {
759
    my ($self, $table, $columns) = @_;
760
    
cleanup
Yuki Kimoto authored on 2011-04-02
761
    # Create column clause
762
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
763
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
764
    push @column, $self->_q($table) . "." . $self->_q($_) .
765
      " as " . $self->_q($_)
766
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
767
    
768
    return join (', ', @column);
769
}
770

            
added dbi_options attribute
kimoto authored on 2010-12-20
771
sub new {
772
    my $self = shift->SUPER::new(@_);
773
    
cleanup
Yuki Kimoto authored on 2011-04-02
774
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
775
    my @attrs = keys %$self;
cleanup
Yuki Kimoto authored on 2011-10-21
776
    for my $attr (@attrs) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
777
        croak qq{Invalid attribute: "$attr" } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
778
          unless $self->can($attr);
779
    }
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
780

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
781
    # DEPRECATED
cleanup
Yuki Kimoto authored on 2011-08-13
782
    $self->{_tags} = {
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
783
        '?'     => \&DBIx::Custom::Tag::placeholder,
784
        '='     => \&DBIx::Custom::Tag::equal,
785
        '<>'    => \&DBIx::Custom::Tag::not_equal,
786
        '>'     => \&DBIx::Custom::Tag::greater_than,
787
        '<'     => \&DBIx::Custom::Tag::lower_than,
788
        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
789
        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
790
        'like'  => \&DBIx::Custom::Tag::like,
791
        'in'    => \&DBIx::Custom::Tag::in,
792
        'insert_param' => \&DBIx::Custom::Tag::insert_param,
793
        'update_param' => \&DBIx::Custom::Tag::update_param
cleanup
Yuki Kimoto authored on 2011-08-13
794
    };
795
    
796
    return $self;
797
}
798

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

            
801
sub order {
802
    my $self = shift;
803
    return DBIx::Custom::Order->new(dbi => $self, @_);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
804
}
805

            
cleanup
yuki-kimoto authored on 2010-10-17
806
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
807
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
808
    
809
    # Register filter
810
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
811
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
812
    
cleanup
Yuki Kimoto authored on 2011-04-02
813
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
814
}
packaging one directory
yuki-kimoto authored on 2009-11-16
815

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
819
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
820
    my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
821
               : defined $opt{table} ? [$opt{table}]
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
822
               : [];
cleanup
Yuki Kimoto authored on 2011-10-21
823
    $opt{table} = $tables;
cleanup
Yuki Kimoto authored on 2011-10-21
824
    my $where_param = $opt{where_param} || delete $opt{param} || {};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
825
    
cleanup
Yuki Kimoto authored on 2011-03-09
826
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
827
    if ($opt{relation}) {
828
        warn "select() relation option is DEPRECATED!";
829
        $self->_add_relation_table($tables, $opt{relation});
830
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
831
    
cleanup
Yuki Kimoto authored on 2011-04-02
832
    # Select statement
micro optimization
Yuki Kimoto authored on 2011-09-30
833
    my $sql = 'select ';
packaging one directory
yuki-kimoto authored on 2009-11-16
834
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
835
    # Prefix
cleanup
Yuki Kimoto authored on 2011-10-21
836
    $sql .= "$opt{prefix} " if defined $opt{prefix};
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
837
    
cleanup
Yuki Kimoto authored on 2011-10-21
838
    # Column
cleanup
Yuki Kimoto authored on 2011-10-21
839
    if (defined $opt{column}) {
840
        my $columns
841
          = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
cleanup
Yuki Kimoto authored on 2011-10-21
842
        for my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
843
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
844
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
845
            }
846
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
847
                if (@$column == 3 && $column->[1] eq 'as') {
848
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
849
                    splice @$column, 1, 1;
850
                }
851
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
852
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
853
            }
cleanup
Yuki Kimoto authored on 2011-04-02
854
            unshift @$tables, @{$self->_search_tables($column)};
micro optimization
Yuki Kimoto authored on 2011-09-30
855
            $sql .= "$column, ";
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
856
        }
micro optimization
Yuki Kimoto authored on 2011-09-30
857
        $sql =~ s/, $/ /;
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
858
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
859
    else { $sql .= '* ' }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
860
    
861
    # Table
micro optimization
Yuki Kimoto authored on 2011-09-30
862
    $sql .= 'from ';
cleanup
Yuki Kimoto authored on 2011-10-21
863
    if ($opt{relation}) {
cleanup
Yuki Kimoto authored on 2011-03-30
864
        my $found = {};
cleanup
Yuki Kimoto authored on 2011-10-21
865
        for my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-09-30
866
            $sql .= $self->_q($table) . ', ' unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
867
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
868
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
869
    }
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
870
    else { $sql .= $self->_q($tables->[-1] || '') . ' ' }
micro optimization
Yuki Kimoto authored on 2011-09-30
871
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2011-10-21
872
    croak "select method table option must be specified " . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
873
      unless $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
874

            
cleanup
Yuki Kimoto authored on 2011-04-02
875
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
876
    unshift @$tables,
877
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
878
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
879
    # Where
cleanup
Yuki Kimoto authored on 2011-10-21
880
    my $where = defined $opt{id}
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
881
              ? $self->_id_to_param(delete $opt{id}, $opt{primary_key}, $tables->[-1])
cleanup
Yuki Kimoto authored on 2011-10-21
882
              : $opt{where};
883
    my $w = $self->_where_clause_and_param($where, $where_param);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
884
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
885
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-10-21
886
    unshift @$tables, @{$self->_search_tables($w->{clause})};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
887
    
cleanup
Yuki Kimoto authored on 2011-10-21
888
    # Join statement
cleanup
Yuki Kimoto authored on 2011-10-21
889
    $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
890
    
cleanup
Yuki Kimoto authored on 2011-03-09
891
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-10-21
892
    $sql .= "$w->{clause} ";
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
893
    
cleanup
Yuki Kimoto authored on 2011-03-08
894
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-10-21
895
    $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
cleanup
Yuki Kimoto authored on 2011-10-21
896
      if $opt{relation};
cleanup
Yuki Kimoto authored on 2011-03-08
897
    
packaging one directory
yuki-kimoto authored on 2009-11-16
898
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
899
    $opt{statement} = 'select';
cleanup
Yuki Kimoto authored on 2011-10-21
900
    my $result = $self->execute($sql, $w->{param}, %opt);
packaging one directory
yuki-kimoto authored on 2009-11-16
901
    
micro optimization
Yuki Kimoto authored on 2011-10-23
902
    $result;
packaging one directory
yuki-kimoto authored on 2009-11-16
903
}
904

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
905
sub setup_model {
906
    my $self = shift;
907
    
cleanup
Yuki Kimoto authored on 2011-04-02
908
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
909
    $self->each_column(
910
        sub {
911
            my ($self, $table, $column, $column_info) = @_;
912
            if (my $model = $self->models->{$table}) {
913
                push @{$model->columns}, $column;
914
            }
915
        }
916
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
917
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
918
}
919

            
update pod
Yuki Kimoto authored on 2011-08-10
920
sub show_datatype {
921
    my ($self, $table) = @_;
922
    croak "Table name must be specified" unless defined $table;
923
    print "$table\n";
924
    
925
    my $result = $self->select(table => $table, where => "'0' <> '0'");
926
    my $sth = $result->sth;
927

            
928
    my $columns = $sth->{NAME};
929
    my $data_types = $sth->{TYPE};
930
    
931
    for (my $i = 0; $i < @$columns; $i++) {
932
        my $column = $columns->[$i];
933
        my $data_type = $data_types->[$i];
934
        print "$column: $data_type\n";
935
    }
936
}
937

            
938
sub show_typename {
939
    my ($self, $t) = @_;
940
    croak "Table name must be specified" unless defined $t;
941
    print "$t\n";
942
    
943
    $self->each_column(sub {
944
        my ($self, $table, $column, $infos) = @_;
945
        return unless $table eq $t;
946
        my $typename = $infos->{TYPE_NAME};
947
        print "$column: $typename\n";
948
    });
949
    
950
    return $self;
951
}
952

            
test cleanup
Yuki Kimoto authored on 2011-08-15
953
sub show_tables {
954
    my $self = shift;
955
    
956
    my %tables;
957
    $self->each_table(sub { $tables{$_[1]}++ });
958
    print join("\n", sort keys %tables) . "\n";
959
    return $self;
960
}
961

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

            
965
    $self->{_type_rule_is_called} = 1;
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
966
    
967
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
968
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
969
        
970
        # Into
cleanup
Yuki Kimoto authored on 2011-10-21
971
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
972
            my $into = "into$i";
cleanup
Yuki Kimoto authored on 2011-08-16
973
            my $exists_into = exists $type_rule->{$into};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
974
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
975
            $self->{type_rule} = $type_rule;
976
            $self->{"_$into"} = {};
cleanup
Yuki Kimoto authored on 2011-10-21
977
            for my $type_name (keys %{$type_rule->{$into} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
978
                croak qq{type name of $into section must be lower case}
979
                  if $type_name =~ /[A-Z]/;
980
            }
cleanup
Yuki Kimoto authored on 2011-08-16
981
            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
982
            $self->each_column(sub {
983
                my ($dbi, $table, $column, $column_info) = @_;
984
                
985
                my $type_name = lc $column_info->{TYPE_NAME};
986
                if ($type_rule->{$into} &&
987
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
988
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
989
                    return unless exists $type_rule->{$into}->{$type_name};
990
                    if  (defined $filter && ref $filter ne 'CODE') 
991
                    {
992
                        my $fname = $filter;
993
                        croak qq{Filter "$fname" is not registered" } . _subname
994
                          unless exists $self->filters->{$fname};
995
                        
996
                        $filter = $self->filters->{$fname};
997
                    }
998

            
micro optimization
Yuki Kimoto authored on 2011-07-30
999
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1000
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1001
                }
1002
            });
1003
        }
1004

            
1005
        # From
cleanup
Yuki Kimoto authored on 2011-10-21
1006
        for my $i (1 .. 2) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1007
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
cleanup
Yuki Kimoto authored on 2011-10-21
1008
            for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1009
                croak qq{data type of from$i section must be lower case or number}
1010
                  if $data_type =~ /[A-Z]/;
1011
                my $fname = $type_rule->{"from$i"}{$data_type};
1012
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1013
                    croak qq{Filter "$fname" is not registered" } . _subname
1014
                      unless exists $self->filters->{$fname};
1015
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1016
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1017
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1018
            }
1019
        }
1020
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1021
        return $self;
1022
    }
1023
    
1024
    return $self->{type_rule} || {};
1025
}
1026

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1030
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1031
    my $param = @_ % 2 ? shift : undef;
cleanup
Yuki Kimoto authored on 2011-10-21
1032
    my %opt = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1033
    warn "update param option is DEPRECATED!" if $opt{param};
cleanup
Yuki Kimoto authored on 2011-10-21
1034
    warn "update method where_param option is DEPRECATED!"
1035
      if $opt{where_param};
cleanup
Yuki Kimoto authored on 2011-10-21
1036
    $param ||= $opt{param} || {};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1037
    
cleanup
Yuki Kimoto authored on 2011-10-21
1038
    # Don't allow update all rows
1039
    croak qq{update method where option must be specified } . _subname
1040
      if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1041
    
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1042
    # Timestamp
cleanup
Yuki Kimoto authored on 2011-10-21
1043
    if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1044
        my $columns = $update_timestamp->[0];
1045
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1046
        my $value = $update_timestamp->[1];
1047
        $value = $value->() if ref $value eq 'CODE';
1048
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1049
    }
1050

            
cleanup
Yuki Kimoto authored on 2011-10-21
1051
    # Assign clause
cleanup
Yuki Kimoto authored on 2011-10-21
1052
    my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
cleanup
Yuki Kimoto authored on 2011-10-21
1053
    
1054
    # Convert id to where parameter
1055
    my $where = defined $opt{id}
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
1056
      ? $self->_id_to_param(delete $opt{id}, $opt{primary_key}, $opt{table})
cleanup
Yuki Kimoto authored on 2011-10-21
1057
      : $opt{where};
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1058

            
1059
    # Where
cleanup
Yuki Kimoto authored on 2011-10-21
1060
    my $w = $self->_where_clause_and_param($where, $opt{where_param});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1061
    
cleanup
Yuki Kimoto authored on 2011-10-21
1062
    # Merge where parameter to parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1063
    $param = $self->merge_param($param, $w->{param}) if keys %{$w->{param}};
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1064
    
cleanup
Yuki Kimoto authored on 2011-04-02
1065
    # Update statement
cleanup
Yuki Kimoto authored on 2011-10-21
1066
    my $sql = "update ";
1067
    $sql .= "$opt{prefix} " if defined $opt{prefix};
cleanup
Yuki Kimoto authored on 2011-10-21
1068
    $sql .= $self->_q($opt{table}) . " set $assign_clause $w->{clause} ";
cleanup
Yuki Kimoto authored on 2011-01-27
1069
    
cleanup
yuki-kimoto authored on 2010-10-17
1070
    # Execute query
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
1071
    $opt{statement} = 'update';
micro optimization
Yuki Kimoto authored on 2011-10-23
1072
    $self->execute($sql, $param, %opt);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1073
}
1074

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1077
sub update_or_insert {
1078
    my $self = shift;
1079

            
cleanup
Yuki Kimoto authored on 2011-10-21
1080
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1081
    my $param  = shift;
1082
    my %opt = @_;
1083
    my $id = $opt{id};
1084
    my $primary_key = $opt{primary_key};
1085
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
1086
    croak "update_or_insert method need primary_key option " .
1087
          "when id is specified" . _subname
1088
      if defined $id && !defined $primary_key;
1089
    my $table  = $opt{table};
1090
    croak qq{"table" option must be specified } . _subname
1091
      unless defined $table;
1092
    my $select_option = $opt{select_option};
1093
    
1094
    my $rows = $self->select(table => $table, id => $id,
1095
        primary_key => $primary_key, %$select_option)->all;
1096
    
1097
    croak "selected row count must be one or zero" . _subname
1098
      if @$rows > 1;
1099
    
1100
    my $row = $rows->[0];
1101
    my @opt = (table => $table);
1102
    push @opt, id => $id, primary_key => $primary_key if defined $id;
1103
    push @opt, %opt;
1104
    
1105
    if ($row) {
1106
        return $self->update($param, @opt);
1107
    }
1108
    else {
1109
        return $self->insert($param, @opt);
1110
    }
1111
}
1112

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1113
sub update_timestamp {
1114
    my $self = shift;
1115
    
1116
    if (@_) {
1117
        $self->{update_timestamp} = [@_];
1118
        
1119
        return $self;
1120
    }
1121
    return $self->{update_timestamp};
1122
}
1123

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1124
sub values_clause {
1125
    my ($self, $param, $opts) = @_;
1126
    
1127
    my $wrap = $opts->{wrap} || {};
1128
    
1129
    # Create insert parameter tag
micro optimization
Yuki Kimoto authored on 2011-10-23
1130
    my $safety = $self->{safety_character} || $self->safety_character;
improved performance
Yuki Kimoto authored on 2011-10-22
1131
    my $qp = $self->_q('');
fixed some quoted bug
Yuki Kimoto authored on 2011-10-22
1132
    my $q = substr($qp, 0, 1) || '';
1133
    my $p = substr($qp, 1, 1) || '';
improved performance
Yuki Kimoto authored on 2011-10-22
1134
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1135
    # Check unsafety keys
1136
    unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
1137
        for my $column (keys %$param) {
1138
            croak qq{"$column" is not safety column name } . _subname
1139
              unless $column =~ /^[$safety\.]+$/;
1140
        }
1141
    }
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1142
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1143
    # values clause(performance is important)
micro optimization
Yuki Kimoto authored on 2011-10-23
1144
    '(' .
1145
    join(
1146
      ', ',
1147
      map { "$q$_$p" } sort keys %$param
1148
    ) .
1149
    ') values (' .
1150
    join(
1151
      ', ',
1152
      map {
1153
          ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1154
          $wrap->{$_} ? $wrap->{$_}->(":$_") :
1155
          ":$_";
1156
      } sort keys %$param
1157
    ) .
1158
    ')'
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1159
}
1160

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1163
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1164
    
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1165
    my ($self, $source, $after_build_sql) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1166
    
updated pod
Yuki Kimoto authored on 2011-06-21
1167
    # Cache
1168
    my $cache = $self->cache;
1169
    
1170
    # Query
1171
    my $query;
1172
    
1173
    # Get cached query
1174
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1175
        
updated pod
Yuki Kimoto authored on 2011-06-21
1176
        # Get query
1177
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1178
        
updated pod
Yuki Kimoto authored on 2011-06-21
1179
        # Create query
1180
        if ($q) {
1181
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1182
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1183
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1184
    }
1185
    
1186
    # Create query
1187
    unless ($query) {
1188

            
1189
        # Create query
1190
        my $builder = $self->query_builder;
1191
        $query = $builder->build_query($source);
1192

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

            
1199
        # Save query to cache
1200
        $self->cache_method->(
1201
            $self, $source,
1202
            {
1203
                sql     => $query->sql, 
1204
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1205
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1206
            }
1207
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1208
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1209

            
1210
    # Filter SQL
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1211
    if ($after_build_sql) {
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1212
        my $sql = $query->sql;
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1213
        $sql = $after_build_sql->($sql);
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1214
        $query->sql($sql);
1215
    }
1216
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1217
    # Save sql
1218
    $self->last_sql($query->sql);
1219
    
updated pod
Yuki Kimoto authored on 2011-06-21
1220
    # Prepare statement handle
1221
    my $sth;
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
1222
    eval { $sth = $self->dbh->prepare($query->{sql}) };
updated pod
Yuki Kimoto authored on 2011-06-21
1223
    
1224
    if ($@) {
1225
        $self->_croak($@, qq{. Following SQL is executed.\n}
1226
                        . qq{$query->{sql}\n} . _subname);
1227
    }
1228
    
1229
    # Set statement handle
1230
    $query->sth($sth);
1231
    
1232
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1233
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1234
    
1235
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1236
}
1237

            
cleanup
Yuki Kimoto authored on 2011-04-02
1238
sub _create_bind_values {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1239
    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1240
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1241
    $bind_type = _array_to_hash($bind_type) if ref $bind_type eq 'ARRAY';
1242
    
cleanup
Yuki Kimoto authored on 2011-04-02
1243
    # Create bind values
micro optimization
Yuki Kimoto authored on 2011-10-23
1244
    my @bind;
1245
    my @types;
1246
    my %count;
1247
    my %not_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1248
    for my $column (@$columns) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
1249
        
micro optimization
Yuki Kimoto authored on 2011-10-23
1250
        # Bind value
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1251
        if(ref $params->{$column} eq 'ARRAY') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1252
            my $i = $count{$column} || 0;
1253
            $i += $not_exists{$column} || 0;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1254
            my $found;
1255
            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1256
                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1257
                    $not_exists{$column}++;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1258
                }
1259
                else  {
micro optimization
Yuki Kimoto authored on 2011-10-23
1260
                    push @bind, $params->{$column}->[$k];
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1261
                    $found = 1;
1262
                    last
1263
                }
1264
            }
1265
            next unless $found;
1266
        }
micro optimization
Yuki Kimoto authored on 2011-10-23
1267
        else { push @bind, $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1268
        
cleanup
Yuki Kimoto authored on 2011-01-12
1269
        # Filter
micro optimization
Yuki Kimoto authored on 2011-10-23
1270
        if (my $f = $filter->{$column} || $self->{default_out_filter} || '') {
micro optimization
Yuki Kimoto authored on 2011-10-23
1271
            $bind[-1] = $f->($bind[-1]);
micro optimization
Yuki Kimoto authored on 2011-10-23
1272
        }
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1273
        
1274
        # Type rule
micro optimization
Yuki Kimoto authored on 2011-10-23
1275
        if ($self->{_type_rule_is_called}) {
1276
            my $tf1 = $self->{"_into1"}->{dot}->{$column}
1277
              || $type_filters->{1}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1278
            $bind[-1] = $tf1->($bind[-1]) if $tf1;
micro optimization
Yuki Kimoto authored on 2011-10-23
1279
            my $tf2 = $self->{"_into2"}->{dot}->{$column}
1280
              || $type_filters->{2}->{$column};
micro optimization
Yuki Kimoto authored on 2011-10-23
1281
            $bind[-1] = $tf2->($bind[-1]) if $tf2;
micro optimization
Yuki Kimoto authored on 2011-10-23
1282
        }
micro optimization
Yuki Kimoto authored on 2011-10-22
1283
       
micro optimization
Yuki Kimoto authored on 2011-10-23
1284
        # Bind types
micro optimization
Yuki Kimoto authored on 2011-10-23
1285
        push @types, $bind_type->{$column};
removed reconnect method
yuki-kimoto authored on 2010-05-28
1286
        
1287
        # Count up 
micro optimization
Yuki Kimoto authored on 2011-10-23
1288
        $count{$column}++;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1289
    }
1290
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1291
    return (\@bind, \@types);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1292
}
1293

            
cleanup
Yuki Kimoto authored on 2011-10-21
1294
sub _id_to_param {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1295
    my ($self, $id, $primary_keys, $table) = @_;
cleanup
Yuki Kimoto authored on 2011-10-21
1296
    
1297
    # Check primary key
cleanup
Yuki Kimoto authored on 2011-10-21
1298
    croak "primary_key option " .
1299
          "must be specified with id option " . _subname
1300
      unless defined $primary_keys;
1301
    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
improved error messages
Yuki Kimoto authored on 2011-04-18
1302
    
cleanup
Yuki Kimoto authored on 2011-06-08
1303
    # Create parameter
1304
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1305
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1306
        $id = [$id] unless ref $id;
1307
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1308
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1309
          unless !ref $id || ref $id eq 'ARRAY';
1310
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1311
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1312
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1313
        for(my $i = 0; $i < @$primary_keys; $i ++) {
fixed id option bug when col...
Yuki Kimoto authored on 2011-10-10
1314
           my $key = $primary_keys->[$i];
1315
           $key = "$table." . $key if $table;
1316
           $param->{$key} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1317
        }
1318
    }
1319
    
cleanup
Yuki Kimoto authored on 2011-06-08
1320
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1321
}
1322

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1323
sub _connect {
1324
    my $self = shift;
1325
    
1326
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1327
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1328
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1329
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1330
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1331
    croak qq{"dsn" must be specified } . _subname
1332
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1333
    my $user        = $self->user;
1334
    my $password    = $self->password;
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1335
    my $option = $self->_option;
1336
    $option = {%{$self->default_option}, %$option};
cleanup
Yuki Kimoto authored on 2011-08-16
1337
    
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1338
    # Connect
cleanup
Yuki Kimoto authored on 2011-08-16
1339
    my $dbh;
1340
    eval {
1341
        $dbh = DBI->connect(
1342
            $dsn,
1343
            $user,
1344
            $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1345
            $option
cleanup
Yuki Kimoto authored on 2011-08-16
1346
        );
1347
    };
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1348
    
1349
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1350
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1351
    
1352
    return $dbh;
1353
}
1354

            
cleanup
yuki-kimoto authored on 2010-10-17
1355
sub _croak {
1356
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1357
    
1358
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1359
    $append ||= "";
1360
    
1361
    # Verbose
1362
    if ($Carp::Verbose) { croak $error }
1363
    
1364
    # Not verbose
1365
    else {
1366
        
1367
        # Remove line and module infromation
1368
        my $at_pos = rindex($error, ' at ');
1369
        $error = substr($error, 0, $at_pos);
1370
        $error =~ s/\s+$//;
1371
        croak "$error$append";
1372
    }
1373
}
1374

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1377
sub _need_tables {
1378
    my ($self, $tree, $need_tables, $tables) = @_;
1379
    
cleanup
Yuki Kimoto authored on 2011-04-02
1380
    # Get needed tables
cleanup
Yuki Kimoto authored on 2011-10-21
1381
    for my $table (@$tables) {
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1382
        if ($tree->{$table}) {
1383
            $need_tables->{$table} = 1;
1384
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1385
        }
1386
    }
1387
}
1388

            
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1389
sub _option {
1390
    my $self = shift;
1391
    my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1392
    warn "dbi_options is DEPRECATED! use option instead\n"
1393
      if keys %{$self->dbi_options};
1394
    warn "dbi_option is DEPRECATED! use option instead\n"
1395
      if keys %{$self->dbi_option};
1396
    return $option;
1397
}
1398

            
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1399
sub _push_join {
1400
    my ($self, $sql, $join, $join_tables) = @_;
1401
    
cleanup
Yuki Kimoto authored on 2011-10-21
1402
    $join = [$join] unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-10-21
1403
    
cleanup
Yuki Kimoto authored on 2011-04-02
1404
    # No join
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1405
    return unless @$join;
1406
    
cleanup
Yuki Kimoto authored on 2011-04-02
1407
    # Push join clause
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1408
    my $tree = {};
1409
    for (my $i = 0; $i < @$join; $i++) {
1410
        
cleanup
Yuki Kimoto authored on 2011-07-28
1411
        # Arrange
added join new syntax
Yuki Kimoto authored on 2011-07-28
1412
        my $join_clause;;
1413
        my $option;
1414
        if (ref $join->[$i] eq 'HASH') {
1415
            $join_clause = $join->[$i]->{clause};
1416
            $option = {table => $join->[$i]->{table}};
1417
        }
1418
        else {
1419
            $join_clause = $join->[$i];
1420
            $option = {};
1421
        };
cleanup
Yuki Kimoto authored on 2011-07-28
1422

            
1423
        # Find tables in join clause
added join new syntax
Yuki Kimoto authored on 2011-07-28
1424
        my $table1;
1425
        my $table2;
1426
        if (my $table = $option->{table}) {
1427
            $table1 = $table->[0];
1428
            $table2 = $table->[1];
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1429
        }
cleanup
Yuki Kimoto authored on 2011-07-28
1430
        else {
1431
            my $q = $self->_quote;
1432
            my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1433
            $j_clause =~ s/'.+?'//g;
1434
            my $q_re = quotemeta($q);
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1435
            $j_clause =~ s/[$q_re]//g;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1436
            
1437
            my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
cleanup
Yuki Kimoto authored on 2011-07-28
1438
            my $c = $self->safety_character;
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1439
            my $join_re = qr/($c+)\.$c+[^$c].*?($c+)\.$c+/sm;
improved join clause parsing
Yuki Kimoto authored on 2011-09-27
1440
            for my $clause (@j_clauses) {
1441
                if ($clause =~ $join_re) {
1442
                    $table1 = $1;
1443
                    $table2 = $2;
1444
                    last;
1445
                }                
cleanup
Yuki Kimoto authored on 2011-07-28
1446
            }
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1447
        }
added join new syntax
Yuki Kimoto authored on 2011-07-28
1448
        croak qq{join clause must have two table name after "on" keyword. } .
1449
              qq{"$join_clause" is passed }  . _subname
1450
          unless defined $table1 && defined $table2;
1451
        croak qq{right side table of "$join_clause" must be unique }
1452
            . _subname
1453
          if exists $tree->{$table2};
1454
        croak qq{Same table "$table1" is specified} . _subname
1455
          if $table1 eq $table2;
1456
        $tree->{$table2}
1457
          = {position => $i, parent => $table1, join => $join_clause};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1458
    }
1459
    
cleanup
Yuki Kimoto authored on 2011-04-02
1460
    # Search need tables
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1461
    my $need_tables = {};
1462
    $self->_need_tables($tree, $need_tables, $join_tables);
cleanup
Yuki Kimoto authored on 2011-10-21
1463
    my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} }
1464
      keys %$need_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1465
    
1466
    # Add join clause
cleanup
Yuki Kimoto authored on 2011-10-21
1467
    $$sql .= $tree->{$_}{join} . ' ' for @need_tables;
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1468
}
cleanup
Yuki Kimoto authored on 2011-03-08
1469

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1470
sub _quote {
1471
    my $self = shift;
micro optimization
Yuki Kimoto authored on 2011-10-22
1472
    return $self->{reserved_word_quote} || $self->quote || '';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1473
}
1474

            
cleanup
Yuki Kimoto authored on 2011-07-29
1475
sub _q {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1476
    my ($self, $value, $quotemeta) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1477
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1478
    my $quote = $self->{reserved_word_quote}
1479
      || $self->{quote} || $self->quote || '';
1480
    return "$quote$value$quote"
1481
      if !$quotemeta && ($quote eq '`' || $quote eq '"');
1482
    
cleanup
Yuki Kimoto authored on 2011-07-29
1483
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1484
    my $p;
1485
    if (defined $quote && length $quote > 1) {
1486
        $p = substr($quote, 1, 1);
1487
    }
1488
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1489
    
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1490
    if ($quotemeta) {
1491
        $q = quotemeta($q);
1492
        $p = quotemeta($p);
1493
    }
1494
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1495
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1496
}
1497

            
cleanup
Yuki Kimoto authored on 2011-04-02
1498
sub _remove_duplicate_table {
1499
    my ($self, $tables, $main_table) = @_;
1500
    
1501
    # Remove duplicate table
1502
    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1503
    delete $tables{$main_table} if $main_table;
1504
    
micro optimization
Yuki Kimoto authored on 2011-07-30
1505
    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1506
    if (my $q = $self->_quote) {
1507
        $q = quotemeta($q);
1508
        $_ =~ s/[$q]//g for @$new_tables;
1509
    }
1510

            
1511
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1512
}
1513

            
cleanup
Yuki Kimoto authored on 2011-04-02
1514
sub _search_tables {
cleanup
Yuki Kimoto authored on 2011-04-02
1515
    my ($self, $source) = @_;
1516
    
cleanup
Yuki Kimoto authored on 2011-04-02
1517
    # Search tables
cleanup
Yuki Kimoto authored on 2011-04-02
1518
    my $tables = [];
1519
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1520
    my $q = $self->_quote;
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1521
    my $quoted_safety_character_re = $self->_q("?([$safety_character]+)", 1);
1522
    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
improved table search in col...
Yuki Kimoto authored on 2011-04-12
1523
                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
cleanup
Yuki Kimoto authored on 2011-04-02
1524
    while ($source =~ /$table_re/g) {
1525
        push @$tables, $1;
1526
    }
1527
    
1528
    return $tables;
1529
}
1530

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1580
sub _where_clause_and_param {
1581
    my ($self, $where, $param) = @_;
1582
 
1583
    $where ||= {};
1584
    $param ||= {};
1585
    my $w = {};
1586
    my $where_clause = '';
1587
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1588
        $w->{clause} = "where " . $where->[0];
1589
        $w->{param} = $where->[1];
1590
    }
1591
    elsif (ref $where) {
1592
        $where = $self->_where_to_obj($where);
1593
        $w->{param} = keys %$param
1594
                    ? $self->merge_param($param, $where->param)
1595
                    : $where->param;
1596
        $w->{clause} = $where->to_string;
1597
    }
1598
    elsif ($where) {
1599
        $w->{clause} = "where $where";
1600
        $w->{param} = $param;
1601
    }
1602
    
1603
    return $w;
1604
}
1605

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1676
# DEPRECATED!
1677
has 'data_source';
1678
has dbi_options => sub { {} };
1679
has filter_check  => 1;
1680
has 'reserved_word_quote';
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1681
has dbi_option => sub { {} };
1682
has default_dbi_option => sub {
1683
    warn "default_dbi_option is DEPRECATED! use default_option instead";
1684
    return shift->default_option;
1685
};
1686

            
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
1687
# DEPRECATED!
1688
sub method {
1689
    warn "method is DEPRECATED! use helper instead";
1690
    return shift->helper(@_);
1691
}
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1692

            
1693
# DEPRECATED!
1694
sub assign_param {
1695
    my $self = shift;
1696
    warn "assing_param is DEPRECATED! use assign_clause instead";
1697
    return $self->assign_clause(@_);
1698
}
1699

            
1700
# DEPRECATED
1701
sub update_param {
1702
    my ($self, $param, $opts) = @_;
1703
    
micro optimization
Yuki Kimoto authored on 2011-10-23
1704
    warn "update_param is DEPRECATED! use assign_clause instead.";
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1705
    
1706
    # Create update parameter tag
1707
    my $tag = $self->assign_clause($param, $opts);
1708
    $tag = "set $tag" unless $opts->{no_set};
1709

            
1710
    return $tag;
1711
}
1712

            
updated pod
Yuki Kimoto authored on 2011-06-21
1713
# DEPRECATED!
1714
sub create_query {
1715
    warn "create_query is DEPRECATED! use query option of each method";
1716
    shift->_create_query(@_);
1717
}
1718

            
cleanup
Yuki Kimoto authored on 2011-06-13
1719
# DEPRECATED!
1720
sub apply_filter {
1721
    my $self = shift;
1722
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1723
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1724
    return $self->_apply_filter(@_);
1725
}
1726

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

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1733
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1734
    my $primary_keys = delete $opt{primary_key};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1735
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1736
    my $where = delete $opt{where};
1737
    my $param = delete $opt{param};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1738
    
1739
    # Table
1740
    croak qq{"table" option must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-10-21
1741
      unless $opt{table};
1742
    my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1743
    
1744
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1745
    my $where_param = $self->_id_to_param($where, $primary_keys);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1746
    
cleanup
Yuki Kimoto authored on 2011-10-21
1747
    return $self->select(where => $where_param, %opt);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1748
}
1749

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

            
cleanup
Yuki Kimoto authored on 2011-10-21
1754
    warn "delete_at is DEPRECATED! use delete method id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1755
    
cleanup
Yuki Kimoto authored on 2011-10-21
1756
    # Options
cleanup
Yuki Kimoto authored on 2011-10-21
1757
    my $primary_keys = delete $opt{primary_key};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1758
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1759
    my $where = delete $opt{where};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1760
    
1761
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1762
    my $where_param = $self->_id_to_param($where, $primary_keys);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1763
    
cleanup
Yuki Kimoto authored on 2011-10-21
1764
    return $self->delete(where => $where_param, %opt);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1765
}
1766

            
cleanup
Yuki Kimoto authored on 2011-06-08
1767
# DEPRECATED!
1768
sub update_at {
1769
    my $self = shift;
1770

            
cleanup
Yuki Kimoto authored on 2011-10-21
1771
    warn "update_at is DEPRECATED! use update method id option instead";
cleanup
Yuki Kimoto authored on 2011-06-08
1772
    
cleanup
Yuki Kimoto authored on 2011-10-21
1773
    # Options
cleanup
Yuki Kimoto authored on 2011-06-08
1774
    my $param;
1775
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1776
    my %opt = @_;
1777
    my $primary_keys = delete $opt{primary_key};
cleanup
Yuki Kimoto authored on 2011-06-08
1778
    $primary_keys = [$primary_keys] unless ref $primary_keys;
cleanup
Yuki Kimoto authored on 2011-10-21
1779
    my $where = delete $opt{where};
1780
    my $p = delete $opt{param} || {};
cleanup
Yuki Kimoto authored on 2011-06-08
1781
    $param  ||= $p;
1782
    
1783
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1784
    my $where_param = $self->_id_to_param($where, $primary_keys);
cleanup
Yuki Kimoto authored on 2011-06-08
1785
    
cleanup
Yuki Kimoto authored on 2011-10-21
1786
    return $self->update(where => $where_param, param => $param, %opt);
cleanup
Yuki Kimoto authored on 2011-06-08
1787
}
1788

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1789
# DEPRECATED!
1790
sub insert_at {
1791
    my $self = shift;
1792
    
cleanup
Yuki Kimoto authored on 2011-10-21
1793
    warn "insert_at is DEPRECATED! use insert method id option instead";
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1794
    
cleanup
Yuki Kimoto authored on 2011-10-21
1795
    # Options
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1796
    my $param;
1797
    $param = shift if @_ % 2;
cleanup
Yuki Kimoto authored on 2011-10-21
1798
    my %opt = @_;
1799
    my $primary_key = delete $opt{primary_key};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1800
    $primary_key = [$primary_key] unless ref $primary_key;
cleanup
Yuki Kimoto authored on 2011-10-21
1801
    my $where = delete $opt{where};
1802
    my $p = delete $opt{param} || {};
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1803
    $param  ||= $p;
1804
    
1805
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-10-21
1806
    my $where_param = $self->_id_to_param($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1807
    $param = $self->merge_param($where_param, $param);
1808
    
cleanup
Yuki Kimoto authored on 2011-10-21
1809
    return $self->insert(param => $param, %opt);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1810
}
1811

            
added warnings
Yuki Kimoto authored on 2011-06-07
1812
# DEPRECATED!
1813
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1814
    my $self = shift;
1815
    
added warnings
Yuki Kimoto authored on 2011-06-07
1816
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1817
    
1818
    # Merge tag
1819
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1820
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1821
    
1822
    return $self;
1823
}
1824

            
1825
# DEPRECATED!
1826
sub register_tag_processor {
1827
    my $self = shift;
1828
    warn "register_tag_processor is DEPRECATED!";
1829
    # Merge tag
1830
    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1831
    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1832
    return $self;
added warnings
Yuki Kimoto authored on 2011-06-07
1833
}
1834

            
cleanup
Yuki Kimoto authored on 2011-01-25
1835
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1836
sub default_bind_filter {
1837
    my $self = shift;
1838
    
cleanup
Yuki Kimoto authored on 2011-06-13
1839
    warn "default_bind_filter is DEPRECATED!";
added warnings
Yuki Kimoto authored on 2011-06-07
1840
    
cleanup
Yuki Kimoto authored on 2011-01-12
1841
    if (@_) {
1842
        my $fname = $_[0];
1843
        
1844
        if (@_ && !$fname) {
1845
            $self->{default_out_filter} = undef;
1846
        }
1847
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1848
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1849
              unless exists $self->filters->{$fname};
1850
        
1851
            $self->{default_out_filter} = $self->filters->{$fname};
1852
        }
1853
        return $self;
1854
    }
1855
    
1856
    return $self->{default_out_filter};
1857
}
1858

            
cleanup
Yuki Kimoto authored on 2011-01-25
1859
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-01-12
1860
sub default_fetch_filter {
1861
    my $self = shift;
added warnings
Yuki Kimoto authored on 2011-06-07
1862

            
cleanup
Yuki Kimoto authored on 2011-06-13
1863
    warn "default_fetch_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-01-12
1864
    
1865
    if (@_) {
many changed
Yuki Kimoto authored on 2011-01-23
1866
        my $fname = $_[0];
1867

            
cleanup
Yuki Kimoto authored on 2011-01-12
1868
        if (@_ && !$fname) {
1869
            $self->{default_in_filter} = undef;
1870
        }
1871
        else {
many changed
Yuki Kimoto authored on 2011-01-23
1872
            croak qq{Filter "$fname" is not registered}
cleanup
Yuki Kimoto authored on 2011-01-12
1873
              unless exists $self->filters->{$fname};
1874
        
1875
            $self->{default_in_filter} = $self->filters->{$fname};
1876
        }
1877
        
1878
        return $self;
1879
    }
1880
    
many changed
Yuki Kimoto authored on 2011-01-23
1881
    return $self->{default_in_filter};
cleanup
Yuki Kimoto authored on 2011-01-12
1882
}
1883

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1884
# DEPRECATED!
1885
sub insert_param {
1886
    my $self = shift;
1887
    warn "insert_param is DEPRECATED! use values_clause instead";
1888
    return $self->values_clause(@_);
1889
}
1890

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1891
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1892
sub insert_param_tag {
1893
    warn "insert_param_tag is DEPRECATED! " .
1894
         "use insert_param instead!";
1895
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1896
}
1897

            
1898
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1899
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1900
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1901
         "use update_param instead";
1902
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1903
}
cleanup
Yuki Kimoto authored on 2011-03-08
1904
# DEPRECATED!
1905
sub _push_relation {
1906
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1907
    
1908
    if (keys %{$relation || {}}) {
micro optimization
Yuki Kimoto authored on 2011-09-30
1909
        $$sql .= $need_where ? 'where ' : 'and ';
cleanup
Yuki Kimoto authored on 2011-10-21
1910
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1911
            my $table1 = (split (/\./, $rcolumn))[0];
1912
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1913
            push @$tables, ($table1, $table2);
micro optimization
Yuki Kimoto authored on 2011-09-30
1914
            $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
cleanup
Yuki Kimoto authored on 2011-03-08
1915
        }
1916
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
1917
    $$sql =~ s/and $/ /;
cleanup
Yuki Kimoto authored on 2011-03-08
1918
}
1919

            
1920
# DEPRECATED!
1921
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1922
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1923
    
1924
    if (keys %{$relation || {}}) {
cleanup
Yuki Kimoto authored on 2011-10-21
1925
        for my $rcolumn (keys %$relation) {
cleanup
Yuki Kimoto authored on 2011-03-08
1926
            my $table1 = (split (/\./, $rcolumn))[0];
1927
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1928
            my $table1_exists;
1929
            my $table2_exists;
cleanup
Yuki Kimoto authored on 2011-10-21
1930
            for my $table (@$tables) {
cleanup
Yuki Kimoto authored on 2011-03-08
1931
                $table1_exists = 1 if $table eq $table1;
1932
                $table2_exists = 1 if $table eq $table2;
1933
            }
1934
            unshift @$tables, $table1 unless $table1_exists;
1935
            unshift @$tables, $table2 unless $table2_exists;
1936
        }
1937
    }
1938
}
1939

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1942
=head1 NAME
1943

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

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

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1948
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1949
    
1950
    # Connect
1951
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1952
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1953
        user => 'ken',
1954
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
1955
        option => {mysql_enable_utf8 => 1}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1956
    );
cleanup
yuki-kimoto authored on 2010-08-05
1957

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1958
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1959
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1960
    
1961
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
1962
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
1963
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1964
    
1965
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
1966
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
1967

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1972
    # Select, more complex
1973
    my $result = $dbi->select(
1974
        table  => 'book',
1975
        column => [
cleanup
Yuki Kimoto authored on 2011-06-13
1976
            {book => [qw/title author/]},
1977
            {company => ['name']}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1978
        ],
1979
        where  => {'book.author' => 'Ken'},
1980
        join => ['left outer join company on book.company_id = company.id'],
1981
        append => 'order by id limit 5'
removed reconnect method
yuki-kimoto authored on 2010-05-28
1982
    );
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1983
    
removed register_format()
yuki-kimoto authored on 2010-05-26
1984
    # Fetch
1985
    while (my $row = $result->fetch) {
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1986
        
removed register_format()
yuki-kimoto authored on 2010-05-26
1987
    }
1988
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1989
    # Fetch as hash
removed register_format()
yuki-kimoto authored on 2010-05-26
1990
    while (my $row = $result->fetch_hash) {
1991
        
1992
    }
1993
    
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1994
    # Execute SQL with parameter.
1995
    $dbi->execute(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1996
        "select id from book where author = :author and title like :title",
updated pod
Yuki Kimoto authored on 2011-06-21
1997
        {author => 'ken', title => '%Perl%'}
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1998
    );
1999
    
fix heading typos
Terrence Brannon authored on 2011-08-17
2000
=head1 DESCRIPTION
removed reconnect method
yuki-kimoto authored on 2010-05-28
2001

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2017
Named place holder support
2018

            
2019
=item *
2020

            
cleanup
Yuki Kimoto authored on 2011-07-29
2021
Model support
2022

            
2023
=item *
2024

            
2025
Connection manager support
2026

            
2027
=item *
pod fix
Yuki Kimoto authored on 2011-01-21
2028

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

            
2033
=item *
2034

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

            
2037
=item *
2038

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

            
2041
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2042

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2050
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2051
L<DBIx::Custom::Result>,
2052
L<DBIx::Custom::Query>,
2053
L<DBIx::Custom::Where>,
2054
L<DBIx::Custom::Model>,
2055
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2056

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

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

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

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

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

            
2070
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2071
        "dbi:mysql:database=$database",
2072
        $user,
2073
        $password,
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2074
        DBIx::Custom->new->default_option
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2075
    );
2076
    
updated pod
Yuki Kimoto authored on 2011-06-21
2077
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2078

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

            
2082
    my $dbi = DBIx::Custom->connect(
2083
      dsn => $dsn, user => $user, password => $password, connector => 1);
2084
    
2085
    my $connector = $dbi->connector; # DBIx::Connector
2086

            
2087
Note that L<DBIx::Connector> must be installed.
2088

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

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

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

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

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2104
    {
2105
        RaiseError => 1,
2106
        PrintError => 0,
2107
        AutoCommit => 1,
2108
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2109

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

            
2112
    my $exclude_table = $dbi->exclude_table;
2113
    $dbi = $dbi->exclude_table(qr/pg_/);
2114

            
2115
Excluded table regex.
2116
C<each_column>, C<each_table>, C<type_rule>,
2117
and C<setup_model> methods ignore matching tables.
2118

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

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

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

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

            
2128
    my $last_sql = $dbi->last_sql;
2129
    $dbi = $dbi->last_sql($last_sql);
2130

            
2131
Get last successed SQL executed by C<execute> method.
2132

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

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

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

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

            
2142
    my $option = $dbi->option;
2143
    $dbi = $dbi->option($option);
2144

            
2145
L<DBI> option, used when C<connect> method is executed.
2146
Each value in option override the value of C<default_option>.
2147

            
cleanup
yuki-kimoto authored on 2010-10-17
2148
=head2 C<password>
2149

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2170
You can set quote pair.
2171

            
2172
    $dbi->quote('[]');
2173

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2183
    my $safety_character = $dbi->safety_character;
2184
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2185

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

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

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

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

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

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

            
2202
    my $tag_parse = $dbi->tag_parse(0);
2203
    $dbi = $dbi->tag_parse;
2204

            
2205
Enable DEPRECATED tag parsing functionality, default to 1.
2206
If you want to disable tag parsing functionality, set to 0.
2207

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

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

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

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

            
2217
    my $user_column_info = $dbi->user_column_info;
2218
    $dbi = $dbi->user_column_info($user_column_info);
2219

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

            
2222
    [
2223
        {table => 'book', column => 'title', info => {...}},
2224
        {table => 'author', column => 'name', info => {...}}
2225
    ]
2226

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

            
2229
    my $user_column_info
2230
      = $dbi->get_column_info(exclude_table => qr/^system/);
2231
    $dbi->user_column_info($user_column_info);
2232

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

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

            
2238
    my $user_table_info = $dbi->user_table_info;
2239
    $dbi = $dbi->user_table_info($user_table_info);
2240

            
2241
You can set the following data.
2242

            
2243
    [
2244
        {table => 'book', info => {...}},
2245
        {table => 'author', info => {...}}
2246
    ]
2247

            
2248
Usually, you can set return value of C<get_table_info>.
2249

            
2250
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2251
    $dbi->user_table_info($user_table_info);
2252

            
2253
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2254
to find table info.
2255

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2292
Create column clause. The follwoing column clause is created.
2293

            
2294
    book.author as "book.author",
2295
    book.title as "book.title"
2296

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2299
    # Separator is hyphen
2300
    $dbi->separator('-');
2301
    
2302
    book.author as "book-author",
2303
    book.title as "book-title"
2304
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2305
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2306

            
update pod
Yuki Kimoto authored on 2011-03-13
2307
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2308
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2309
        user => 'ken',
2310
        password => '!LFKD%$&',
- dbi_option attribute is re...
Yuki Kimoto authored on 2011-10-05
2311
        option => {mysql_enable_utf8 => 1}
update pod
Yuki Kimoto authored on 2011-03-13
2312
    );
2313

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

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

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

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

            
2324
Get rows count.
2325

            
2326
Options is same as C<select> method's ones.
2327

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2330
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2331
        table => 'book',
2332
        primary_key => 'id',
2333
        join => [
2334
            'inner join company on book.comparny_id = company.id'
2335
        ],
2336
    );
2337

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

            
2341
   $dbi->model('book')->select(...);
2342

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

            
2345
    my $dbh = $dbi->dbh;
2346

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

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

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

            
2354
Execute delete statement.
2355

            
2356
The following opitons are available.
2357

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

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

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

            
2365
=item C<id>
2366

            
2367
    id => 4
2368
    id => [4, 5]
2369

            
2370
ID corresponding to C<primary_key>.
2371
You can delete rows by C<id> and C<primary_key>.
2372

            
2373
    $dbi->delete(
fixed pod
Yuki Kimoto authored on 2011-10-20
2374
        primary_key => ['id1', 'id2'],
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2375
        id => [4, 5],
2376
        table => 'book',
2377
    );
2378

            
2379
The above is same as the followin one.
2380

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

            
2383
=item C<prefix>
2384

            
2385
    prefix => 'some'
2386

            
2387
prefix before table name section.
2388

            
2389
    delete some from book
2390

            
2391
=item C<table>
2392

            
2393
    table => 'book'
2394

            
2395
Table name.
2396

            
2397
=item C<where>
2398

            
2399
Same as C<select> method's C<where> option.
2400

            
2401
=back
2402

            
2403
=head2 C<delete_all>
2404

            
2405
    $dbi->delete_all(table => $table);
2406

            
2407
Execute delete statement for all rows.
2408
Options is same as C<delete>.
2409

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

            
2412
    $dbi->each_column(
2413
        sub {
2414
            my ($dbi, $table, $column, $column_info) = @_;
2415
            
2416
            my $type = $column_info->{TYPE_NAME};
2417
            
2418
            if ($type eq 'DATE') {
2419
                # ...
2420
            }
2421
        }
2422
    );
2423

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

            
2429
If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2430
infromation, you can improve the performance of C<each_column> in
2431
the following way.
2432

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

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

            
2439
    $dbi->each_table(
2440
        sub {
2441
            my ($dbi, $table, $table_info) = @_;
2442
            
2443
            my $table_name = $table_info->{TABLE_NAME};
2444
        }
2445
    );
2446

            
improved pod
Yuki Kimoto authored on 2011-10-14
2447
Iterate all table informationsfrom in database.
2448
Argument is callback which is executed when one table is found.
2449
Callback receive three arguments, C<DBIx::Custom object>, C<table name>,
2450
C<table information>.
2451

            
2452
If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2453
infromation, you can improve the performance of C<each_table> in
2454
the following way.
2455

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

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

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

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

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

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

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

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

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

            
2499
    select * from where title = "aa\\:bb";
2500

            
cleanup
Yuki Kimoto authored on 2011-10-20
2501
B<OPTIONS>
2502

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

            
2505
=over 4
2506

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

            
2509
You can filter sql after the sql is build.
2510

            
2511
    after_build_sql => $code_ref
2512

            
2513
The following one is one example.
2514

            
2515
    $dbi->select(
2516
        table => 'book',
2517
        column => 'distinct(name)',
2518
        after_build_sql => sub {
2519
            "select count(*) from ($_[0]) as t1"
2520
        }
2521
    );
2522

            
2523
The following SQL is executed.
2524

            
2525
    select count(*) from (select distinct(name) from book) as t1;
2526

            
cleanup
Yuki Kimoto authored on 2011-10-20
2527
=item C<append>
2528

            
2529
    append => 'order by name'
2530

            
2531
Append some statement after SQL.
2532

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

            
2535
Specify database bind data type.
2536

            
2537
    bind_type => [image => DBI::SQL_BLOB]
2538
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2539

            
2540
This is used to bind parameter by C<bind_param> of statment handle.
2541

            
2542
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2543

            
update pod
Yuki Kimoto authored on 2011-03-13
2544
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2545
    
2546
    filter => {
2547
        title  => sub { uc $_[0] }
2548
        author => sub { uc $_[0] }
2549
    }
update pod
Yuki Kimoto authored on 2011-03-13
2550

            
updated pod
Yuki Kimoto authored on 2011-06-09
2551
    # Filter name
2552
    filter => {
2553
        title  => 'upper_case',
2554
        author => 'upper_case'
2555
    }
2556
        
2557
    # At once
2558
    filter => [
2559
        [qw/title author/]  => sub { uc $_[0] }
2560
    ]
2561

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

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

            
2569
    id => 4
2570
    id => [4, 5]
2571

            
2572
ID corresponding to C<primary_key>.
2573
You can delete rows by C<id> and C<primary_key>.
2574

            
2575
    $dbi->execute(
2576
        "select * from book where id1 = :id1 and id2 = :id2",
2577
        {},
fixed pod
Yuki Kimoto authored on 2011-10-20
2578
        primary_key => ['id1', 'id2'],
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
2579
        id => [4, 5],
2580
    );
2581

            
2582
The above is same as the followin one.
2583

            
2584
    $dbi->execute(
2585
        "select * from book where id1 = :id1 and id2 = :id2",
2586
        {id1 => 4, id2 => 5}
2587
    );
2588

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

            
2591
    query => 1
2592

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

            
2596
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2597
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2598
    my $columns = $query->columns;
2599
    
2600
If you want to execute SQL fast, you can do the following way.
2601

            
2602
    my $query;
cleanup
Yuki Kimoto authored on 2011-10-21
2603
    for my $row (@$rows) {
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2604
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
cleanup
Yuki Kimoto authored on 2011-10-20
2605
      $dbi->execute($query, $row);
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2606
    }
2607

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

            
2611
If you want to execute SQL as possible as fast and don't need filtering.
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2612
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2613
    
2614
    my $query;
2615
    my $sth;
cleanup
Yuki Kimoto authored on 2011-10-21
2616
    for my $row (@$rows) {
cleanup
Yuki Kimoto authored on 2011-07-30
2617
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2618
      $sth ||= $query->sth;
2619
      $sth->execute(map { $row->{$_} } sort keys %$row);
2620
    }
2621

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

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

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

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

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

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

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

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

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

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

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

            
added EXPERIMENTAL reuse_que...
Yuki Kimoto authored on 2011-10-22
2657
=item C<reuse EXPERIMENTAL>
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2658
    
micro optimization
Yuki Kimoto authored on 2011-10-23
2659
    reuse => $has_ref
added EXPERIMENTAL reuse_sth...
Yuki Kimoto authored on 2011-10-22
2660

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

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

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

            
2671
    type_rule_off => 1
2672

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

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

            
2677
    type_rule1_off => 1
2678

            
2679
Turn C<into1> type rule off.
2680

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

            
2683
    type_rule2_off => 1
2684

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

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

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

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

            
2693
get column infomation except for one which match C<exclude_table> pattern.
2694

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

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

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

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

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

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

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

            
2715
    $dbi->helper(
2716
        update_or_insert => sub {
2717
            my $self = shift;
2718
            
2719
            # Process
2720
        },
2721
        find_or_create   => sub {
2722
            my $self = shift;
2723
            
2724
            # Process
2725
        }
2726
    );
2727

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

            
2730
    $dbi->update_or_insert;
2731
    $dbi->find_or_create;
2732

            
cleanup
yuki-kimoto authored on 2010-10-17
2733
=head2 C<insert>
2734

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

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

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

            
2743
    {date => \"NOW()"}
2744

            
cleanup
Yuki Kimoto authored on 2011-10-20
2745
B<options>
2746

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

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

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

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

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

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

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

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

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

            
2776
    prefix => 'or replace'
2777

            
2778
prefix before table name section
2779

            
2780
    insert or replace into book
2781

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

            
2784
    table => 'book'
2785

            
2786
Table name.
2787

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

            
2790
    timestamp => 1
2791

            
2792
If this value is set to 1,
2793
automatically created timestamp column is set based on
2794
C<timestamp> attribute's C<insert> value.
2795

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

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

            
2800
placeholder wrapped string.
2801

            
2802
If the following statement
2803

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

            
2807
is executed, the following SQL is executed.
2808

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

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

            
2813
=over 4
2814

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
2862
    $dbi->insert_timestamp(
2863
      [qw/created_at updated_at/]
2864
        => sub { Time::Piece->localtime->strftime("%Y-%m-%d %H:%M:%S") }
2865
    );
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2866

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2867
Timestamp value when C<insert> method is executed
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2868
with C<timestamp> option.
2869

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
2870
If C<insert_timestamp> is set and C<insert> method is executed
2871
with C<timestamp> option, column C<created_at> and C<update_at>
2872
is automatically set to the value like "2010-10-11 10:12:54".
2873

            
moved DBIx::Custom::Guide to...
Yuki Kimoto authored on 2011-10-22
2874
    $dbi->insert($param, table => 'book', timestamp => 1);
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2875

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

            
2878
    my $like_value = $dbi->like_value
2879

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

            
2882
    sub { "%$_[0]%" }
2883

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

            
2886
    my $mapper = $dbi->mapper(param => $param);
2887

            
2888
Create a new L<DBIx::Custom::Mapper> object.
2889

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

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

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

            
2896
    {key1 => [1, 1], key2 => 2}
2897

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

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

            
2902
    my $model = $dbi->model('book');
2903

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

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

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

            
2911
Create column clause for myself. The follwoing column clause is created.
2912

            
2913
    book.author as author,
2914
    book.title as title
2915

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

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

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

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

            
2929
    my $not_exists = $dbi->not_exists;
2930

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

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

            
2936
    my $order = $dbi->order;
2937

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2940
=head2 C<register_filter>
2941

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

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
2959
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2960
        table  => 'book',
2961
        column => ['author', 'title'],
2962
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
2963
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2964
    
updated document
Yuki Kimoto authored on 2011-06-09
2965
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2966

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

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

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2974
=item C<column>
2975
    
updated document
Yuki Kimoto authored on 2011-06-09
2976
    column => 'author'
2977
    column => ['author', 'title']
2978

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
2987
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
2988
        {book => [qw/author title/]},
2989
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
2990
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
2991

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

            
2994
    book.author as "book.author",
2995
    book.title as "book.title",
2996
    person.name as "person.name",
2997
    person.age as "person.age"
2998

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

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

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

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

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

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

            
3014
=item C<id>
3015

            
3016
    id => 4
3017
    id => [4, 5]
3018

            
3019
ID corresponding to C<primary_key>.
3020
You can select rows by C<id> and C<primary_key>.
3021

            
3022
    $dbi->select(
fixed pod
Yuki Kimoto authored on 2011-10-20
3023
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3024
        id => [4, 5],
3025
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3026
    );
3027

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3030
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3031
        where => {id1 => 4, id2 => 5},
3032
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3033
    );
3034
    
cleanup
Yuki Kimoto authored on 2011-10-20
3035
=item C<param>
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3036

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

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

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

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

            
3049
    prefix => 'SQL_CALC_FOUND_ROWS'
3050

            
3051
Prefix of column cluase
3052

            
3053
    select SQL_CALC_FOUND_ROWS title, author from book;
3054

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

            
3057
    join => [
3058
        'left outer join company on book.company_id = company_id',
3059
        'left outer join location on company.location_id = location.id'
3060
    ]
3061
        
3062
Join clause. If column cluase or where clause contain table name like "company.name",
3063
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3064

            
3065
    $dbi->select(
3066
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3067
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3068
        where => {'company.name' => 'Orange'},
3069
        join => [
3070
            'left outer join company on book.company_id = company.id',
3071
            'left outer join location on company.location_id = location.id'
3072
        ]
3073
    );
3074

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3078
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3079
    from book
3080
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3081
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3082

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3083
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
3084
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3085

            
3086
    $dbi->select(
3087
        table => 'book',
3088
        column => ['company.location_id as location_id'],
3089
        where => {'company.name' => 'Orange'},
3090
        join => [
3091
            {
3092
                clause => 'left outer join location on company.location_id = location.id',
3093
                table => ['company', 'location']
3094
            }
3095
        ]
3096
    );
3097

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3102
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3103

            
updated document
Yuki Kimoto authored on 2011-06-09
3104
=item C<where>
3105
    
3106
    # Hash refrence
3107
    where => {author => 'Ken', 'title' => 'Perl'}
3108
    
3109
    # DBIx::Custom::Where object
3110
    where => $dbi->where(
3111
        clause => ['and', 'author = :author', 'title like :title'],
3112
        param  => {author => 'Ken', title => '%Perl%'}
3113
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3114
    
3115
    # Array reference 1 (array reference, hash referenc). same as above
3116
    where => [
3117
        ['and', 'author = :author', 'title like :title'],
3118
        {author => 'Ken', title => '%Perl%'}
3119
    ];    
3120
    
3121
    # Array reference 2 (String, hash reference)
3122
    where => [
3123
        'title like :title',
3124
        {title => '%Perl%'}
3125
    ]
3126
    
3127
    # String
3128
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3129

            
cleanup
Yuki Kimoto authored on 2011-10-20
3130
Where clause. See L<DBIx::Custom::Where>.
updated document
Yuki Kimoto authored on 2011-06-09
3131
    
update pod
Yuki Kimoto authored on 2011-03-12
3132
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3133

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

            
3136
    $dbi->setup_model;
3137

            
3138
Setup all model objects.
3139
C<columns> of model object is automatically set, parsing database information.
3140

            
3141
=head2 C<type_rule>
3142

            
3143
    $dbi->type_rule(
3144
        into1 => {
3145
            date => sub { ... },
3146
            datetime => sub { ... }
3147
        },
3148
        into2 => {
3149
            date => sub { ... },
3150
            datetime => sub { ... }
3151
        },
3152
        from1 => {
3153
            # DATE
3154
            9 => sub { ... },
3155
            # DATETIME or TIMESTAMP
3156
            11 => sub { ... },
3157
        }
3158
        from2 => {
3159
            # DATE
3160
            9 => sub { ... },
3161
            # DATETIME or TIMESTAMP
3162
            11 => sub { ... },
3163
        }
3164
    );
3165

            
3166
Filtering rule when data is send into and get from database.
3167
This has a little complex problem.
3168

            
3169
In C<into1> and C<into2> you can specify
3170
type name as same as type name defined
3171
by create table, such as C<DATETIME> or C<DATE>.
3172

            
3173
Note that type name and data type don't contain upper case.
3174
If these contain upper case charactor, you convert it to lower case.
3175

            
3176
C<into2> is executed after C<into1>.
3177

            
3178
Type rule of C<into1> and C<into2> is enabled on the following
3179
column name.
3180

            
3181
=over 4
3182

            
3183
=item 1. column name
3184

            
3185
    issue_date
3186
    issue_datetime
3187

            
3188
This need C<table> option in each method.
3189

            
3190
=item 2. table name and column name, separator is dot
3191

            
3192
    book.issue_date
3193
    book.issue_datetime
3194

            
3195
=back
3196

            
3197
You get all type name used in database by C<available_typename>.
3198

            
3199
    print $dbi->available_typename;
3200

            
3201
In C<from1> and C<from2> you specify data type, not type name.
3202
C<from2> is executed after C<from1>.
3203
You get all data type by C<available_datatype>.
3204

            
3205
    print $dbi->available_datatype;
3206

            
3207
You can also specify multiple types at once.
3208

            
3209
    $dbi->type_rule(
3210
        into1 => [
3211
            [qw/DATE DATETIME/] => sub { ... },
3212
        ],
3213
    );
3214

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

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

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

            
3221
If you want to set constant value to row data, use scalar reference
3222
as parameter value.
3223

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3235
    id => 4
3236
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3237

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3241
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3242
        {title => 'Perl', author => 'Ken'}
fixed pod
Yuki Kimoto authored on 2011-10-20
3243
        primary_key => ['id1', 'id2'],
updated document
Yuki Kimoto authored on 2011-06-09
3244
        id => [4, 5],
3245
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3246
    );
update pod
Yuki Kimoto authored on 2011-03-13
3247

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3250
    $dbi->update(
3251
        {title => 'Perl', author => 'Ken'}
3252
        where => {id1 => 4, id2 => 5},
3253
        table => 'book'
3254
    );
update pod
Yuki Kimoto authored on 2011-03-13
3255

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

            
3258
    prefix => 'or replace'
3259

            
3260
prefix before table name section
3261

            
3262
    update or replace book
3263

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

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

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

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

            
3272
    timestamp => 1
3273

            
3274
If this value is set to 1,
3275
automatically updated timestamp column is set based on
3276
C<timestamp> attribute's C<update> value.
3277

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

            
3280
Same as C<select> method's C<where> option.
3281

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

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

            
3286
placeholder wrapped string.
3287

            
3288
If the following statement
3289

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

            
3293
is executed, the following SQL is executed.
3294

            
3295
    update book set price =  ? + 5;
3296

            
updated pod
Yuki Kimoto authored on 2011-06-08
3297
=back
update pod
Yuki Kimoto authored on 2011-03-13
3298

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

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

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

            
- removed DEPRECATED status ...
Yuki Kimoto authored on 2011-10-11
3306
=head2 C<update_or_insert EXPERIMENTAL>
3307
    
3308
    # Where
3309
    $dbi->update_or_insert(
3310
        {id => 1, title => 'Perl'},
3311
        table => 'book',
3312
        where => {id => 1},
3313
        select_option => {append => 'for update'}
3314
    );
3315
    
3316
    # ID
3317
    $dbi->update_or_insert(
3318
        {title => 'Perl'},
3319
        table => 'book',
3320
        id => 1,
3321
        primary_key => 'id',
3322
        select_option => {append => 'for update'}
3323
    );
3324
    
3325
Update or insert.
3326

            
3327
In both examples, the following SQL is executed.
3328

            
3329
    # In case insert
3330
    insert into book (id, title) values (?, ?)
3331
    
3332
    # In case update
3333
    update book set (id = ?, title = ?) where book.id = ?
3334

            
3335
The following opitons are available adding to C<update> option.
3336

            
3337
=over 4
3338

            
3339
=item C<select_option>
3340

            
3341
    select_option => {append => 'for update'}
3342

            
3343
select method option,
3344
select method is used to check the row is already exists.
3345

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3348
    $dbi->update_timestamp(
3349
      updated_at
3350
        => sub { Time::Piece->localtime->strftime("%Y-%m-%d %H:%M:%S") }
cleanup
Yuki Kimoto authored on 2011-03-09
3351
    );
fix tests
Yuki Kimoto authored on 2011-01-18
3352

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3353
Timestamp value when C<update> method is executed
3354
with C<timestamp> option.
cleanup
Yuki Kimoto authored on 2011-01-12
3355

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3356
If C<insert_timestamp> is set and C<insert> method is executed
3357
with C<timestamp> option, column C<update_at>
3358
is automatically set to the value like "2010-10-11 10:12:54".
cleanup
Yuki Kimoto authored on 2011-01-12
3359

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-10-19
3360
>|perl|
3361
$dbi->update($param, table => 'book', timestamp => 1);
3362
||<
cleanup
Yuki Kimoto authored on 2011-01-12
3363

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

            
3366
    $dbi->show_datatype($table);
3367

            
3368
Show data type of the columns of specified table.
3369

            
3370
    book
3371
    title: 5
3372
    issue_date: 91
3373

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

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

            
3378
    $dbi->show_tables;
3379

            
3380
Show tables.
3381

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

            
3384
    $dbi->show_typename($table);
3385

            
3386
Show type name of the columns of specified table.
3387

            
3388
    book
3389
    title: varchar
3390
    issue_date: date
3391

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

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

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

            
3398
Create values clause.
3399

            
3400
    (title, author) values (title = :title, age = :age);
3401

            
3402
You can use this in insert statement.
3403

            
3404
    my $insert_sql = "insert into book $values_clause";
3405

            
3406
=head2 C<where>
3407

            
3408
    my $where = $dbi->where(
3409
        clause => ['and', 'title = :title', 'author = :author'],
3410
        param => {title => 'Perl', author => 'Ken'}
3411
    );
3412

            
3413
Create a new L<DBIx::Custom::Where> object.
3414

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

            
3417
=head2 C<DBIX_CUSTOM_DEBUG>
3418

            
3419
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3420
executed SQL and bind values are printed to STDERR.
3421

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

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

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

            
3428
L<DBIx::Custom>
3429

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

            
3475
L<DBIx::Custom::Model>
3476

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3477
    # Attribute methods
- method method of DBIx::Cus...
Yuki Kimoto authored on 2011-10-10
3478
    method # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3479
    filter # will be removed at 2017/1/1
3480
    name # will be removed at 2017/1/1
3481
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3482

            
3483
L<DBIx::Custom::Query>
3484
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3485
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3486
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3487
    table # will be removed at 2017/1/1
3488
    filters # will be removed at 2017/1/1
3489
    
3490
    # Methods
3491
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3492

            
3493
L<DBIx::Custom::QueryBuilder>
3494
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3495
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3496
    tags # will be removed at 2017/1/1
3497
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3498
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3499
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3500
    register_tag # will be removed at 2017/1/1
3501
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3502
    
3503
    # Others
3504
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3505
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3506

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

            
3518
L<DBIx::Custom::Tag>
3519

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

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

            
3524
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3525
except for attribute method.
3526
You can check all DEPRECATED functionalities by document.
3527
DEPRECATED functionality is removed after five years,
3528
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
3529
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3530

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

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

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

            
3537
C<< <kimoto.yuki at gmail.com> >>
3538

            
3539
L<http://github.com/yuki-kimoto/DBIx-Custom>
3540

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3541
=head1 AUTHOR
3542

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

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

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

            
3549
This program is free software; you can redistribute it and/or modify it
3550
under the same terms as Perl itself.
3551

            
3552
=cut