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

            
improved join clause parsing
Yuki Kimoto authored on 2011-09-30
4
our $VERSION = '0.1726';
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
5
use 5.008001;
cleanup
yuki-kimoto authored on 2009-12-22
6

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

            
added environment variable D...
Yuki Kimoto authored on 2011-04-02
22
use constant DEBUG => $ENV{DBIX_CUSTOM_DEBUG} || 0;
improved debug message
Yuki Kimoto authored on 2011-05-23
23
use constant DEBUG_ENCODING => $ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8';
added environment variable D...
Yuki Kimoto authored on 2011-04-02
24

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

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

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

            
added helper method
yuki-kimoto authored on 2010-10-17
101
our $AUTOLOAD;
102
sub AUTOLOAD {
103
    my $self = shift;
104

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
122
sub assign_param {
updated pod
Yuki Kimoto authored on 2011-09-02
123
    my ($self, $param, $opts) = @_;
124
    
125
    my $wrap = $opts->{wrap} || {};
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
126
    
127
    # Create set tag
128
    my @params;
129
    my $safety = $self->safety_character;
insert and update method's p...
Yuki Kimoto authored on 2011-07-29
130
    foreach my $column (sort keys %$param) {
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
131
        croak qq{"$column" is not safety column name } . _subname
132
          unless $column =~ /^[$safety\.]+$/;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
133
        my $column_quote = $self->_q($column);
134
        $column_quote =~ s/\./$self->_q(".")/e;
updated pod
Yuki Kimoto authored on 2011-09-02
135
        my $func = $wrap->{$column} || sub { $_[0] };
136
        push @params,
137
          ref $param->{$column} eq 'SCALAR' ? "$column_quote = " . ${$param->{$column}}
138
        : "$column_quote = " . $func->(":$column");
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
139
    }
140
    my $tag = join(', ', @params);
141
    
142
    return $tag;
143
}
144

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
232
sub delete {
select, insert, update, upda...
yuki-kimoto authored on 2010-06-14
233
    my ($self, %args) = @_;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
234

            
cleanup update and update_al...
yuki-kimoto authored on 2010-04-28
235
    # Arguments
cleanup
Yuki Kimoto authored on 2011-03-21
236
    my $table = $args{table} || '';
cleanup
Yuki Kimoto authored on 2011-04-25
237
    croak qq{"table" option must be specified. } . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
238
      unless $table;
cleanup
Yuki Kimoto authored on 2011-03-21
239
    my $where            = delete $args{where} || {};
240
    my $append           = delete $args{append};
241
    my $allow_delete_all = delete $args{allow_delete_all};
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
242
    my $where_param      = delete $args{where_param} || {};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
243
    my $id = delete $args{id};
244
    my $primary_key = delete $args{primary_key};
245
    croak "update method primary_key option " .
246
          "must be specified when id is specified " . _subname
247
      if defined $id && !defined $primary_key;
248
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
249
    my $prefix = delete $args{prefix};
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
250
    
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
251
    # Where
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
252
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
253
    my $where_clause = '';
updated pod
Yuki Kimoto authored on 2011-06-21
254
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
255
        $where_clause = "where " . $where->[0];
256
        $where_param = $where->[1];
257
    }
258
    elsif (ref $where) {
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
259
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
260
        $where_param = keys %$where_param
261
                     ? $self->merge_param($where_param, $where->param)
262
                     : $where->param;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
263
        
264
        # String where
265
        $where_clause = $where->to_string;
266
    }
267
    elsif ($where) { $where_clause = "where $where" }
cleanup
Yuki Kimoto authored on 2011-04-25
268
    croak qq{"where" must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
269
      if $where_clause eq '' && !$allow_delete_all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
270

            
cleanup
Yuki Kimoto authored on 2011-04-02
271
    # Delete statement
micro optimization
Yuki Kimoto authored on 2011-09-30
272
    my $sql;
273
    $sql .= "delete ";
274
    $sql .= "$prefix " if defined $prefix;
275
    $sql .= "from " . $self->_q($table) . " $where_clause ";
276
    $sql .= $append if defined $append;
packaging one directory
yuki-kimoto authored on 2009-11-16
277
    
278
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
279
    return $self->execute($sql, $where_param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
280
}
281

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

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

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
286
sub create_model {
287
    my $self = shift;
288
    
cleanup
Yuki Kimoto authored on 2011-04-02
289
    # Arguments
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
290
    my $args = ref $_[0] eq 'HASH' ? $_[0] : {@_};
291
    $args->{dbi} = $self;
292
    my $model_class = delete $args->{model_class} || 'DBIx::Custom::Model';
293
    my $model_name  = delete $args->{name};
294
    my $model_table = delete $args->{table};
295
    $model_name ||= $model_table;
296
    
cleanup
Yuki Kimoto authored on 2011-04-02
297
    # Create model
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
298
    my $model = $model_class->new($args);
cleanup
Yuki Kimoto authored on 2011-08-13
299
    weaken $model->{dbi};
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
300
    $model->name($model_name) unless $model->name;
301
    $model->table($model_table) unless $model->table;
302
    
micro optimization
Yuki Kimoto authored on 2011-07-30
303
    # Apply filter(DEPRECATED logic)
304
    if ($model->{filter}) {
305
        my $filter = ref $model->filter eq 'HASH'
306
                   ? [%{$model->filter}]
307
                   : $model->filter;
308
        $filter ||= [];
309
        warn "DBIx::Custom::Model filter method is DEPRECATED!"
310
          if @$filter;
311
        $self->_apply_filter($model->table, @$filter);
312
    }
313
    
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
314
    # Set model
315
    $self->model($model->name, $model);
316
    
create_model() return model
Yuki Kimoto authored on 2011-03-29
317
    return $self->model($model->name);
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
318
}
319

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

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
323
    my $user_column_info = $self->user_column_info;
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
324
    
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
325
    if ($user_column_info) {
326
        $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
327
    }
328
    else {
329
    
330
        my $re = $self->exclude_table || $options{exclude_table};
331
        # Tables
332
        my %tables;
333
        $self->each_table(sub { $tables{$_[1]}++ });
added SQL Server test
Yuki Kimoto authored on 2011-08-14
334

            
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
335
        # Iterate all tables
336
        my @tables = sort keys %tables;
337
        for (my $i = 0; $i < @tables; $i++) {
338
            my $table = $tables[$i];
339
            
340
            # Iterate all columns
341
            my $sth_columns;
342
            eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
343
            next if $@;
344
            while (my $column_info = $sth_columns->fetchrow_hashref) {
345
                my $column = $column_info->{COLUMN_NAME};
346
                $self->$cb($table, $column, $column_info);
347
            }
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
348
        }
349
    }
350
}
351

            
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
352
sub each_table {
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
353
    my ($self, $cb, %option) = @_;
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
354
    
cleanup test
Yuki Kimoto authored on 2011-08-16
355
    my $user_table_infos = $self->user_table_info;
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
356
    
added test
Yuki Kimoto authored on 2011-08-16
357
    # Iterate tables
358
    if ($user_table_infos) {
359
        $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
360
    }
361
    else {
362
        my $re = $self->exclude_table || $option{exclude};
363
        my $sth_tables = $self->dbh->table_info;
364
        while (my $table_info = $sth_tables->fetchrow_hashref) {
365
            
366
            # Table
367
            my $table = $table_info->{TABLE_NAME};
368
            next if defined $re && $table =~ /$re/;
369
            $self->$cb($table, $table_info);
370
        }
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
371
    }
372
}
373

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
374
our %VALID_ARGS = map { $_ => 1 } qw/append after_build_sql allow_delete_all
simplified arguments check
Yuki Kimoto authored on 2011-07-11
375
  allow_update_all bind_type column filter id join param prefix primary_key
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
376
  query relation sqlfilter table table_alias timestamp type type_rule_off
377
  type_rule1_off type_rule2_off wrap/;
cleanup
Yuki Kimoto authored on 2011-04-02
378

            
379
sub execute {
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
380
    my $self = shift;
381
    my $query = shift;
382
    my $param;
383
    $param = shift if @_ % 2;
384
    my %args = @_;
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
385
    
cleanup
Yuki Kimoto authored on 2011-04-02
386
    # Arguments
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
387
    my $p = delete $args{param} || {};
388
    $param ||= $p;
cleanup
Yuki Kimoto authored on 2011-04-02
389
    my $tables = delete $args{table} || [];
390
    $tables = [$tables] unless ref $tables eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-04-02
391
    my $filter = delete $args{filter};
cleanup
Yuki Kimoto authored on 2011-04-25
392
    $filter = _array_to_hash($filter);
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
393
    my $bind_type = delete $args{bind_type} || delete $args{type};
394
    $bind_type = _array_to_hash($bind_type);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
395
    my $type_rule_off = delete $args{type_rule_off};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
396
    my $type_rule_off_parts = {
397
        1 => delete $args{type_rule1_off},
398
        2 => delete $args{type_rule2_off}
399
    };
cleanup
Yuki Kimoto authored on 2011-06-09
400
    my $query_return = delete $args{query};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
401
    my $table_alias = delete $args{table_alias} || {};
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
402
    my $after_build_sql = $args{after_build_sql} || $args{sqlfilter};
403
    warn "sqlfilter option is DEPRECATED" if $args{sqlfilter};
- removed placeholder count ...
Yuki Kimoto authored on 2011-08-22
404
    my $id = delete $args{id};
405
    my $primary_key = delete $args{primary_key};
406
    croak "insert method primary_key option " .
407
          "must be specified when id is specified " . _subname
408
      if defined $id && !defined $primary_key;
409
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
410

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
1530
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1531
}
1532

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1925
=head1 NAME
1926

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

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

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2000
Named place holder support
2001

            
2002
=item *
2003

            
cleanup
Yuki Kimoto authored on 2011-07-29
2004
Model support
2005

            
2006
=item *
2007

            
2008
Connection manager support
2009

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

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

            
2016
=item *
2017

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

            
2020
=item *
2021

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

            
2024
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2025

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

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

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

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

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

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

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

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

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

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

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

            
2065
    my $dbi = DBIx::Custom->connect(
2066
      dsn => $dsn, user => $user, password => $password, connector => 1);
2067
    
2068
    my $connector = $dbi->connector; # DBIx::Connector
2069

            
2070
Note that L<DBIx::Connector> must be installed.
2071

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

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

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

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

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

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

            
2087
=head2 C<default_dbi_option>
2088

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

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

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

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

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

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

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

            
2110
    my $last_sql = $dbi->last_sql;
2111
    $dbi = $dbi->last_sql($last_sql);
2112

            
2113
Get last successed SQL executed by C<execute> method.
2114

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2122
=head2 C<password>
2123

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2144
You can set quote pair.
2145

            
2146
    $dbi->quote('[]');
2147

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2157
    my $safety_character = $dbi->safety_character;
2158
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2159

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

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

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2176
    my $exclude_table = $dbi->exclude_table;
2177
    $dbi = $dbi->exclude_table(qr/pg_/);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
2178

            
updated pod
Yuki Kimoto authored on 2011-09-27
2179
Excluded table regex.
2180
C<each_column>, C<each_table>, C<type_rule>,
2181
and C<setup_model> methods ignore matching tables.
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
2182

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

            
2185
    my $tag_parse = $dbi->tag_parse(0);
2186
    $dbi = $dbi->tag_parse;
2187

            
2188
Enable DEPRECATED tag parsing functionality, default to 1.
2189
If you want to disable tag parsing functionality, set to 0.
2190

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

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

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

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

            
2200
    my $user_column_info = $dbi->user_column_info;
2201
    $dbi = $dbi->user_column_info($user_column_info);
2202

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

            
2205
    [
2206
        {table => 'book', column => 'title', info => {...}},
2207
        {table => 'author', column => 'name', info => {...}}
2208
    ]
2209

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

            
2212
    my $user_column_info
2213
      = $dbi->get_column_info(exclude_table => qr/^system/);
2214
    $dbi->user_column_info($user_column_info);
2215

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

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

            
2221
    my $user_table_info = $dbi->user_table_info;
2222
    $dbi = $dbi->user_table_info($user_table_info);
2223

            
2224
You can set the following data.
2225

            
2226
    [
2227
        {table => 'book', info => {...}},
2228
        {table => 'author', info => {...}}
2229
    ]
2230

            
2231
Usually, you can set return value of C<get_table_info>.
2232

            
2233
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2234
    $dbi->user_table_info($user_table_info);
2235

            
2236
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2237
to find table info.
2238

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2273
Create column clause. The follwoing column clause is created.
2274

            
2275
    book.author as "book.author",
2276
    book.title as "book.title"
2277

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

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

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

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

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

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

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

            
2309
    my $count = $model->count(table => 'book');
2310

            
2311
Get rows count.
2312

            
2313
Options is same as C<select> method's ones.
2314

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

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

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

            
2328
   $dbi->model('book')->select(...);
2329

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

            
2332
    my $dbh = $dbi->dbh;
2333

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

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

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

            
2341
Execute delete statement.
2342

            
2343
The following opitons are available.
2344

            
2345
=over 4
2346

            
2347
=item C<append>
2348

            
2349
Same as C<select> method's C<append> option.
2350

            
2351
=item C<filter>
2352

            
2353
Same as C<execute> method's C<filter> option.
2354

            
2355
=item C<id>
2356

            
2357
    id => 4
2358
    id => [4, 5]
2359

            
2360
ID corresponding to C<primary_key>.
2361
You can delete rows by C<id> and C<primary_key>.
2362

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

            
2369
The above is same as the followin one.
2370

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

            
2373
=item C<prefix>
2374

            
2375
    prefix => 'some'
2376

            
2377
prefix before table name section.
2378

            
2379
    delete some from book
2380

            
2381
=item C<query>
2382

            
2383
Same as C<execute> method's C<query> option.
2384

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2385
=item C<after_build_sql>
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2386

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2387
Same as C<execute> method's C<after_build_sql> option.
added EXPERIMENTAL find_tabl...
Yuki Kimoto authored on 2011-08-16
2388

            
2389
=item C<table>
2390

            
2391
    table => 'book'
2392

            
2393
Table name.
2394

            
2395
=item C<where>
2396

            
2397
Same as C<select> method's C<where> option.
2398

            
2399
=item C<primary_key>
2400

            
2401
See C<id> option.
2402

            
2403
=item C<bind_type>
2404

            
2405
Same as C<execute> method's C<bind_type> option.
2406

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

            
2409
Same as C<execute> method's C<type_rule_off> option.
2410

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

            
2413
    type_rule1_off => 1
2414

            
2415
Same as C<execute> method's C<type_rule1_off> option.
2416

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

            
2419
    type_rule2_off => 1
2420

            
2421
Same as C<execute> method's C<type_rule2_off> option.
2422

            
2423
=back
2424

            
2425
=head2 C<delete_all>
2426

            
2427
    $dbi->delete_all(table => $table);
2428

            
2429
Execute delete statement for all rows.
2430
Options is same as C<delete>.
2431

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

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

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

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

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

            
2461
Iterate all table informationsfrom database.
2462
Argument is callback when one table is found.
2463
Callback receive three arguments, dbi object, table name,
2464
table information.
2465

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

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

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

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

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

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

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

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

            
2505
    select * from where title = "aa\\:bb";
2506

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

            
2509
=over 4
2510

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

            
2513
Specify database bind data type.
2514

            
2515
    bind_type => [image => DBI::SQL_BLOB]
2516
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2517

            
2518
This is used to bind parameter by C<bind_param> of statment handle.
2519

            
2520
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2521

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

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

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

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

            
2547
    id => 4
2548
    id => [4, 5]
2549

            
2550
ID corresponding to C<primary_key>.
2551
You can delete rows by C<id> and C<primary_key>.
2552

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

            
2560
The above is same as the followin one.
2561

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

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

            
2569
    query => 1
2570

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

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

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

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

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

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

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

            
2606
See C<id> option.
2607

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2608
=item C<after_build_sql> 
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2609

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2610
You can filter sql after the sql is build.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2611

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2612
    after_build_sql => $code_ref
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2613

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2614
The following one is one example.
2615

            
2616
    $dbi->select(
2617
        table => 'book',
2618
        column => 'distinct(name)',
2619
        after_build_sql => sub {
2620
            "select count(*) from ($_[0]) as t1"
2621
        }
2622
    );
2623

            
2624
The following SQL is executed.
2625

            
2626
    select count(*) from (select distinct(name) from book) as t1;
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2627

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

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

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

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

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

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

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

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

            
2654
    type_rule_off => 1
2655

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

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

            
2660
    type_rule1_off => 1
2661

            
2662
Turn C<into1> type rule off.
2663

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

            
2666
    type_rule2_off => 1
2667

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2674
    my $tables = $dbi->get_column_info(exclude_table => qr/^system_/);
- added EXPERIMENTAL get_col...
Yuki Kimoto authored on 2011-08-16
2675

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2724
=item C<id>
2725

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

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

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

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

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

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

            
2748
    prefix => 'or replace'
2749

            
2750
prefix before table name section
2751

            
2752
    insert or replace into book
2753

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

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

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2765
=item C<after_build_sql>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2766

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2767
Same as C<execute> method's C<after_build_sql> option.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2768

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

            
2771
    table => 'book'
2772

            
2773
Table name.
2774

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

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

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

            
2781
    timestamp => 1
2782

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

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

            
2789
    type_rule1_off => 1
2790

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

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

            
2795
    type_rule2_off => 1
2796

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

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

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

            
2803
placeholder wrapped string.
2804

            
2805
If the following statement
2806

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

            
2810
is executed, the following SQL is executed.
2811

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

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

            
2816
=over 4
2817

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2818
=head2 C<insert_param>
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2819

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2820
    my $insert_param = $dbi->insert_param({title => 'a', age => 2});
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2821

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2822
Create insert parameters.
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2823

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
2879
If multiple column are specified, same value is used.
2880

            
added EXPERIMENTAL like_valu...
Yuki Kimoto authored on 2011-09-16
2881
=head2 C<like_value EXPERIMENTAL>
2882

            
2883
    my $like_value = $dbi->like_value
2884

            
2885
Constant code reference for the like value.
2886

            
2887
    sub { "%$_[0]%" }
2888

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

            
2891
    my $mapper = $dbi->mapper(param => $param);
2892

            
2893
Create a new L<DBIx::Custom::Mapper> object.
2894

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

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

            
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
2899
Merge parameters.
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2900

            
2901
    {key1 => [1, 1], key2 => 2}
2902

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
2903
=head2 C<method>
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2904

            
2905
    $dbi->method(
2906
        update_or_insert => sub {
2907
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2908
            
2909
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2910
        },
2911
        find_or_create   => sub {
2912
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2913
            
2914
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2915
        }
2916
    );
2917

            
update pod
Yuki Kimoto authored on 2011-03-13
2918
Register method. These method is called directly from L<DBIx::Custom> object.
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2919

            
2920
    $dbi->update_or_insert;
2921
    $dbi->find_or_create;
2922

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

            
2925
    my $model = $dbi->model('book');
2926

            
updated pod
Yuki Kimoto authored on 2011-06-21
2927
Get a L<DBIx::Custom::Model> object,
update pod
Yuki Kimoto authored on 2011-03-13
2928

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

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

            
2933
Create column clause for myself. The follwoing column clause is created.
2934

            
2935
    book.author as author,
2936
    book.title as title
2937

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2940
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2941
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2942
        user => 'ken',
2943
        password => '!LFKD%$&',
2944
        dbi_option => {mysql_enable_utf8 => 1}
2945
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2946

            
2947
Create a new L<DBIx::Custom> object.
2948

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

            
2951
    my $not_exists = $dbi->not_exists;
2952

            
update pod
Yuki Kimoto authored on 2011-03-13
2953
DBIx::Custom::NotExists object, indicating the column is not exists.
2954
This is used by C<clause> of L<DBIx::Custom::Where> .
experimental extended select...
Yuki Kimoto authored on 2011-01-17
2955

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

            
2958
    my $order = $dbi->order;
2959

            
2960
Create a new L<DBIx::Custom::Order> object.
2961

            
cleanup
yuki-kimoto authored on 2010-10-17
2962
=head2 C<register_filter>
2963

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2979
=head2 C<type_rule>
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2980

            
2981
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2982
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2983
            date => sub { ... },
2984
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2985
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2986
        into2 => {
2987
            date => sub { ... },
2988
            datetime => sub { ... }
2989
        },
2990
        from1 => {
2991
            # DATE
2992
            9 => sub { ... },
2993
            # DATETIME or TIMESTAMP
2994
            11 => sub { ... },
2995
        }
2996
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2997
            # DATE
2998
            9 => sub { ... },
2999
            # DATETIME or TIMESTAMP
3000
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3001
        }
3002
    );
3003

            
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3004
Filtering rule when data is send into and get from database.
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
3005
This has a little complex problem.
cleanup
Yuki Kimoto authored on 2011-06-13
3006

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3007
In C<into1> and C<into2> you can specify
3008
type name as same as type name defined
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3009
by create table, such as C<DATETIME> or C<DATE>.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3010

            
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
3011
Note that type name and data type don't contain upper case.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3012
If these contain upper case charactor, you convert it to lower case.
3013

            
updated pod
Yuki Kimoto authored on 2011-06-21
3014
C<into2> is executed after C<into1>.
3015

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3016
Type rule of C<into1> and C<into2> is enabled on the following
3017
column name.
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
3018

            
cleanup
Yuki Kimoto authored on 2011-06-13
3019
=over 4
3020

            
3021
=item 1. column name
3022

            
3023
    issue_date
3024
    issue_datetime
3025

            
updated pod
Yuki Kimoto authored on 2011-06-21
3026
This need C<table> option in each method.
3027

            
cleanup
Yuki Kimoto authored on 2011-06-13
3028
=item 2. table name and column name, separator is dot
3029

            
3030
    book.issue_date
3031
    book.issue_datetime
3032

            
3033
=back
3034

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
3035
You get all type name used in database by C<available_typename>.
update pod
Yuki Kimoto authored on 2011-06-15
3036

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
3037
    print $dbi->available_typename;
update pod
Yuki Kimoto authored on 2011-06-15
3038

            
updated pod
Yuki Kimoto authored on 2011-06-21
3039
In C<from1> and C<from2> you specify data type, not type name.
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3040
C<from2> is executed after C<from1>.
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-08-09
3041
You get all data type by C<available_datatype>.
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3042

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

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3045
You can also specify multiple types at once.
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3046

            
3047
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3048
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3049
            [qw/DATE DATETIME/] => sub { ... },
3050
        ],
3051
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3052

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
3055
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3056
        table  => 'book',
3057
        column => ['author', 'title'],
3058
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
3059
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3060
    
updated document
Yuki Kimoto authored on 2011-06-09
3061
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3062

            
updated document
Yuki Kimoto authored on 2011-06-09
3063
The following opitons are available.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3064

            
3065
=over 4
3066

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3069
    append => 'order by title'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3070

            
updated document
Yuki Kimoto authored on 2011-06-09
3071
Append statement to last of SQL.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3072

            
3073
=item C<bind_type>
3074

            
3075
Same as C<execute> method's C<bind_type> option.
updated document
Yuki Kimoto authored on 2011-06-09
3076
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3077
=item C<column>
3078
    
updated document
Yuki Kimoto authored on 2011-06-09
3079
    column => 'author'
3080
    column => ['author', 'title']
3081

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3090
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
3091
        {book => [qw/author title/]},
3092
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
3093
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
3094

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

            
3097
    book.author as "book.author",
3098
    book.title as "book.title",
3099
    person.name as "person.name",
3100
    person.age as "person.age"
3101

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

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

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

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

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

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

            
3117
=item C<id>
3118

            
3119
    id => 4
3120
    id => [4, 5]
3121

            
3122
ID corresponding to C<primary_key>.
3123
You can select rows by C<id> and C<primary_key>.
3124

            
3125
    $dbi->select(
3126
        parimary_key => ['id1', 'id2'],
3127
        id => [4, 5],
3128
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3129
    );
3130

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3133
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3134
        where => {id1 => 4, id2 => 5},
3135
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3136
    );
3137
    
updated document
Yuki Kimoto authored on 2011-06-09
3138
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3139

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

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

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

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

            
3152
    prefix => 'SQL_CALC_FOUND_ROWS'
3153

            
3154
Prefix of column cluase
3155

            
3156
    select SQL_CALC_FOUND_ROWS title, author from book;
3157

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

            
3160
    join => [
3161
        'left outer join company on book.company_id = company_id',
3162
        'left outer join location on company.location_id = location.id'
3163
    ]
3164
        
3165
Join clause. If column cluase or where clause contain table name like "company.name",
3166
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3167

            
3168
    $dbi->select(
3169
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3170
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3171
        where => {'company.name' => 'Orange'},
3172
        join => [
3173
            'left outer join company on book.company_id = company.id',
3174
            'left outer join location on company.location_id = location.id'
3175
        ]
3176
    );
3177

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3181
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3182
    from book
3183
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3184
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3185

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3186
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
3187
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3188

            
3189
    $dbi->select(
3190
        table => 'book',
3191
        column => ['company.location_id as location_id'],
3192
        where => {'company.name' => 'Orange'},
3193
        join => [
3194
            {
3195
                clause => 'left outer join location on company.location_id = location.id',
3196
                table => ['company', 'location']
3197
            }
3198
        ]
3199
    );
3200

            
updated document
Yuki Kimoto authored on 2011-06-09
3201
=item C<primary_key>
added EXPERIMENTAL replace()...
Yuki Kimoto authored on 2011-04-01
3202

            
updated document
Yuki Kimoto authored on 2011-06-09
3203
    primary_key => 'id'
3204
    primary_key => ['id1', 'id2']
added EXPERIMENTAL replace()...
Yuki Kimoto authored on 2011-04-01
3205

            
updated document
Yuki Kimoto authored on 2011-06-09
3206
Primary key. This is used by C<id> option.
added EXPERIMENTAL replace()...
Yuki Kimoto authored on 2011-04-01
3207

            
updated document
Yuki Kimoto authored on 2011-06-09
3208
=item C<query>
update pod
Yuki Kimoto authored on 2011-03-12
3209

            
updated document
Yuki Kimoto authored on 2011-06-09
3210
Same as C<execute> method's C<query> option.
update pod
Yuki Kimoto authored on 2011-03-12
3211

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3212
=item C<after_build_sql>
updated pod
Yuki Kimoto authored on 2011-06-08
3213

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3214
Same as C<execute> method's C<after_build_sql> option
updated pod
Yuki Kimoto authored on 2011-06-08
3215

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3220
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3221

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3222
=item C<type_rule_off>
updated pod
Yuki Kimoto authored on 2011-06-08
3223

            
updated document
Yuki Kimoto authored on 2011-06-09
3224
Same as C<execute> method's C<type_rule_off> option.
updated pod
Yuki Kimoto authored on 2011-06-08
3225

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

            
3228
    type_rule1_off => 1
3229

            
3230
Same as C<execute> method's C<type_rule1_off> option.
3231

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

            
3234
    type_rule2_off => 1
3235

            
3236
Same as C<execute> method's C<type_rule2_off> option.
3237

            
updated document
Yuki Kimoto authored on 2011-06-09
3238
=item C<where>
3239
    
3240
    # Hash refrence
3241
    where => {author => 'Ken', 'title' => 'Perl'}
3242
    
3243
    # DBIx::Custom::Where object
3244
    where => $dbi->where(
3245
        clause => ['and', 'author = :author', 'title like :title'],
3246
        param  => {author => 'Ken', title => '%Perl%'}
3247
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3248
    
3249
    # Array reference 1 (array reference, hash referenc). same as above
3250
    where => [
3251
        ['and', 'author = :author', 'title like :title'],
3252
        {author => 'Ken', title => '%Perl%'}
3253
    ];    
3254
    
3255
    # Array reference 2 (String, hash reference)
3256
    where => [
3257
        'title like :title',
3258
        {title => '%Perl%'}
3259
    ]
3260
    
3261
    # String
3262
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3263

            
updated document
Yuki Kimoto authored on 2011-06-09
3264
Where clause.
3265
    
update pod
Yuki Kimoto authored on 2011-03-12
3266
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3267

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

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

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

            
3274
If you want to set constant value to row data, use scalar reference
3275
as parameter value.
3276

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3279
The following opitons are available.
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
3280

            
update pod
Yuki Kimoto authored on 2011-03-13
3281
=over 4
3282

            
updated document
Yuki Kimoto authored on 2011-06-09
3283
=item C<append>
update pod
Yuki Kimoto authored on 2011-03-13
3284

            
updated document
Yuki Kimoto authored on 2011-06-09
3285
Same as C<select> method's C<append> option.
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3286

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

            
3289
Same as C<execute> method's C<bind_type> option.
3290

            
updated document
Yuki Kimoto authored on 2011-06-09
3291
=item C<filter>
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3292

            
updated document
Yuki Kimoto authored on 2011-06-09
3293
Same as C<execute> method's C<filter> option.
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3294

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3297
    id => 4
3298
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3299

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3303
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3304
        {title => 'Perl', author => 'Ken'}
3305
        parimary_key => ['id1', 'id2'],
3306
        id => [4, 5],
3307
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3308
    );
update pod
Yuki Kimoto authored on 2011-03-13
3309

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3312
    $dbi->update(
3313
        {title => 'Perl', author => 'Ken'}
3314
        where => {id1 => 4, id2 => 5},
3315
        table => 'book'
3316
    );
update pod
Yuki Kimoto authored on 2011-03-13
3317

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

            
3320
    prefix => 'or replace'
3321

            
3322
prefix before table name section
3323

            
3324
    update or replace book
3325

            
updated document
Yuki Kimoto authored on 2011-06-09
3326
=item C<primary_key>
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
3327

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3331
Primary key. This is used by C<id> option.
update pod
Yuki Kimoto authored on 2011-03-13
3332

            
updated document
Yuki Kimoto authored on 2011-06-09
3333
=item C<query>
update pod
Yuki Kimoto authored on 2011-03-13
3334

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

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3337
=item C<after_build_sql>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3338

            
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3339
Same as C<execute> method's C<after_build_sql> option.
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3340

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

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

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

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

            
3349
    timestamp => 1
3350

            
3351
If this value is set to 1,
3352
automatically updated timestamp column is set based on
3353
C<timestamp> attribute's C<update> value.
3354

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

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3357
Same as C<execute> method's C<type_rule_off> option.
3358

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

            
3361
    type_rule1_off => 1
3362

            
3363
Same as C<execute> method's C<type_rule1_off> option.
3364

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

            
3367
    type_rule2_off => 1
3368

            
3369
Same as C<execute> method's C<type_rule2_off> option.
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
3370

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

            
3373
Same as C<select> method's C<where> option.
3374

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

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

            
3379
placeholder wrapped string.
3380

            
3381
If the following statement
3382

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

            
3386
is executed, the following SQL is executed.
3387

            
3388
    update book set price =  ? + 5;
3389

            
updated pod
Yuki Kimoto authored on 2011-06-08
3390
=back
update pod
Yuki Kimoto authored on 2011-03-13
3391

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

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

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3399
=head2 C<update_param>
update pod
Yuki Kimoto authored on 2011-03-13
3400

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3401
    my $update_param = $dbi->update_param({title => 'a', age => 2});
update pod
Yuki Kimoto authored on 2011-03-13
3402

            
3403
Create update parameter tag.
3404

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3405
    set title = :title, author = :author
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
3406

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

            
3409
    $dbi->update_timestamp(updated_at => sub { localtime });
3410

            
3411
Parameter for timestamp columns when C<update> method is executed
3412
with C<timestamp> option.
3413

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
3414
=head2 C<where>
fix tests
Yuki Kimoto authored on 2011-01-18
3415

            
cleanup
Yuki Kimoto authored on 2011-03-09
3416
    my $where = $dbi->where(
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3417
        clause => ['and', 'title = :title', 'author = :author'],
cleanup
Yuki Kimoto authored on 2011-03-09
3418
        param => {title => 'Perl', author => 'Ken'}
3419
    );
fix tests
Yuki Kimoto authored on 2011-01-18
3420

            
3421
Create a new L<DBIx::Custom::Where> object.
3422

            
- removed DEPRECATED DBIx::C...
Yuki Kimoto authored on 2011-04-11
3423
=head2 C<setup_model>
cleanup
Yuki Kimoto authored on 2011-01-12
3424

            
update pod
Yuki Kimoto authored on 2011-03-13
3425
    $dbi->setup_model;
cleanup
Yuki Kimoto authored on 2011-01-12
3426

            
update pod
Yuki Kimoto authored on 2011-03-13
3427
Setup all model objects.
update pod
Yuki Kimoto authored on 2011-03-13
3428
C<columns> of model object is automatically set, parsing database information.
cleanup
Yuki Kimoto authored on 2011-01-12
3429

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

            
3432
    $dbi->show_datatype($table);
3433

            
3434
Show data type of the columns of specified table.
3435

            
3436
    book
3437
    title: 5
3438
    issue_date: 91
3439

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

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

            
3444
    $dbi->show_tables;
3445

            
3446
Show tables.
3447

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

            
3450
    $dbi->show_typename($table);
3451

            
3452
Show type name of the columns of specified table.
3453

            
3454
    book
3455
    title: varchar
3456
    issue_date: date
3457

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

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

            
3462
=head2 C<DBIX_CUSTOM_DEBUG>
3463

            
3464
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3465
executed SQL and bind values are printed to STDERR.
3466

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

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

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

            
3473
L<DBIx::Custom>
3474

            
3475
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3476
    data_source # will be removed at 2017/1/1
3477
    dbi_options # will be removed at 2017/1/1
3478
    filter_check # will be removed at 2017/1/1
3479
    reserved_word_quote # will be removed at 2017/1/1
3480
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3481
    
3482
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3483
    create_query # will be removed at 2017/1/1
3484
    apply_filter # will be removed at 2017/1/1
3485
    select_at # will be removed at 2017/1/1
3486
    delete_at # will be removed at 2017/1/1
3487
    update_at # will be removed at 2017/1/1
3488
    insert_at # will be removed at 2017/1/1
3489
    register_tag # will be removed at 2017/1/1
3490
    default_bind_filter # will be removed at 2017/1/1
3491
    default_fetch_filter # will be removed at 2017/1/1
3492
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3493
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3494
    register_tag_processor # will be removed at 2017/1/1
3495
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3496
    
3497
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3498
    select method relation option # will be removed at 2017/1/1
3499
    select method param option # will be removed at 2017/1/1
3500
    select method column option [COLUMN, as => ALIAS] format
3501
      # will be removed at 2017/1/1
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3502
    execute method's sqlfilter option # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3503
    
3504
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3505
    execute("select * from {= title}"); # execute method's
3506
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3507
                                        # will be removed at 2017/1/1
3508
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3509

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

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3512
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3513
    filter # will be removed at 2017/1/1
3514
    name # will be removed at 2017/1/1
3515
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3516

            
3517
L<DBIx::Custom::Query>
3518
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3519
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3520
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3521
    table # will be removed at 2017/1/1
3522
    filters # will be removed at 2017/1/1
3523
    
3524
    # Methods
3525
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3526

            
3527
L<DBIx::Custom::QueryBuilder>
3528
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3529
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3530
    tags # will be removed at 2017/1/1
3531
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3532
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3533
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3534
    register_tag # will be removed at 2017/1/1
3535
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3536
    
3537
    # Others
3538
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3539
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3540

            
3541
L<DBIx::Custom::Result>
3542
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3543
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3544
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3545
    
3546
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3547
    end_filter # will be removed at 2017/1/1
3548
    remove_end_filter # will be removed at 2017/1/1
3549
    remove_filter # will be removed at 2017/1/1
3550
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3551

            
3552
L<DBIx::Custom::Tag>
3553

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

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

            
3558
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3559
except for attribute method.
3560
You can check all DEPRECATED functionalities by document.
3561
DEPRECATED functionality is removed after five years,
3562
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
3563
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3564

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

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

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

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

            
3573
C<< <kimoto.yuki at gmail.com> >>
3574

            
3575
L<http://github.com/yuki-kimoto/DBIx-Custom>
3576

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3577
=head1 AUTHOR
3578

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

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

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

            
3585
This program is free software; you can redistribute it and/or modify it
3586
under the same terms as Perl itself.
3587

            
3588
=cut