DBIx-Custom / lib / DBIx / Custom.pm /
Newer Older
3605 lines | 92.924kb
cleanup
yuki-kimoto authored on 2009-12-22
1
package DBIx::Custom;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
2
use Object::Simple -base;
cleanup
yuki-kimoto authored on 2009-12-22
3

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
4
our $VERSION = '0.1728';
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 is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
122
sub assign_clause {
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) . " "
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
639
      . $self->values_clause($param, {wrap => $wrap}) . " ";
micro optimization
Yuki Kimoto authored on 2011-09-30
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 is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
646
sub values_clause {
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
micro optimization
Yuki Kimoto authored on 2011-09-30
897
    my $sql = 'select ';
packaging one directory
yuki-kimoto authored on 2009-11-16
898
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
899
    # Prefix
micro optimization
Yuki Kimoto authored on 2011-09-30
900
    $sql .= "$prefix " if defined $prefix;
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
901
    
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
902
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-30
903
    if ($columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-07
904
        $columns = [$columns] unless ref $columns eq 'ARRAY';
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
905
        foreach my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
906
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
907
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
908
            }
909
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
910
                if (@$column == 3 && $column->[1] eq 'as') {
911
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
912
                    splice @$column, 1, 1;
913
                }
914
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
915
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
916
            }
cleanup
Yuki Kimoto authored on 2011-04-02
917
            unshift @$tables, @{$self->_search_tables($column)};
micro optimization
Yuki Kimoto authored on 2011-09-30
918
            $sql .= "$column, ";
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
919
        }
micro optimization
Yuki Kimoto authored on 2011-09-30
920
        $sql =~ s/, $/ /;
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
921
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
922
    else { $sql .= '* ' }
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
923
    
924
    # Table
micro optimization
Yuki Kimoto authored on 2011-09-30
925
    $sql .= 'from ';
cleanup
Yuki Kimoto authored on 2011-03-30
926
    if ($relation) {
927
        my $found = {};
928
        foreach my $table (@$tables) {
micro optimization
Yuki Kimoto authored on 2011-09-30
929
            $sql .= $self->_q($table) . ', ' unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
930
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
931
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
932
    }
cleanup
Yuki Kimoto authored on 2011-03-30
933
    else {
934
        my $main_table = $tables->[-1] || '';
micro optimization
Yuki Kimoto authored on 2011-09-30
935
        $sql .= $self->_q($main_table);
cleanup
Yuki Kimoto authored on 2011-03-30
936
    }
micro optimization
Yuki Kimoto authored on 2011-09-30
937
    $sql =~ s/, $/ /;
cleanup
Yuki Kimoto authored on 2011-04-25
938
    croak "Not found table name " . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
939
      unless $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
940

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1140
    # Update clause
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1141
    my $assign_clause = $self->assign_clause($param, {wrap => $wrap});
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
1142

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

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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1179
sub update_timestamp {
1180
    my $self = shift;
1181
    
1182
    if (@_) {
1183
        $self->{update_timestamp} = [@_];
1184
        
1185
        return $self;
1186
    }
1187
    return $self->{update_timestamp};
1188
}
1189

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1192
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1193
    
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1194
    my ($self, $source, $after_build_sql) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1195
    
updated pod
Yuki Kimoto authored on 2011-06-21
1196
    # Cache
1197
    my $cache = $self->cache;
1198
    
1199
    # Query
1200
    my $query;
1201
    
1202
    # Get cached query
1203
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1204
        
updated pod
Yuki Kimoto authored on 2011-06-21
1205
        # Get query
1206
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1207
        
updated pod
Yuki Kimoto authored on 2011-06-21
1208
        # Create query
1209
        if ($q) {
1210
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1211
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1212
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1213
    }
1214
    
1215
    # Create query
1216
    unless ($query) {
1217

            
1218
        # Create query
1219
        my $builder = $self->query_builder;
1220
        $query = $builder->build_query($source);
1221

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

            
1228
        # Save query to cache
1229
        $self->cache_method->(
1230
            $self, $source,
1231
            {
1232
                sql     => $query->sql, 
1233
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1234
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1235
            }
1236
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1237
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1238

            
1239
    # Filter SQL
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1240
    if ($after_build_sql) {
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1241
        my $sql = $query->sql;
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
1242
        $sql = $after_build_sql->($sql);
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1243
        $query->sql($sql);
1244
    }
1245
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1246
    # Save sql
1247
    $self->last_sql($query->sql);
1248
    
updated pod
Yuki Kimoto authored on 2011-06-21
1249
    # Prepare statement handle
1250
    my $sth;
1251
    eval { $sth = $self->dbh->prepare($query->{sql})};
1252
    
1253
    if ($@) {
1254
        $self->_croak($@, qq{. Following SQL is executed.\n}
1255
                        . qq{$query->{sql}\n} . _subname);
1256
    }
1257
    
1258
    # Set statement handle
1259
    $query->sth($sth);
1260
    
1261
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1262
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1263
    
1264
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1265
}
1266

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

            
cleanup
Yuki Kimoto authored on 2011-06-08
1317
sub _create_param_from_id {
1318
    my ($self, $id, $primary_keys) = @_;
improved error messages
Yuki Kimoto authored on 2011-04-18
1319
    
cleanup
Yuki Kimoto authored on 2011-06-08
1320
    # Create parameter
1321
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1322
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1323
        $id = [$id] unless ref $id;
1324
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1325
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1326
          unless !ref $id || ref $id eq 'ARRAY';
1327
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1328
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1329
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1330
        for(my $i = 0; $i < @$primary_keys; $i ++) {
cleanup
Yuki Kimoto authored on 2011-06-08
1331
           $param->{$primary_keys->[$i]} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1332
        }
1333
    }
1334
    
cleanup
Yuki Kimoto authored on 2011-06-08
1335
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1336
}
1337

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1373
sub _croak {
1374
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1375
    
1376
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1377
    $append ||= "";
1378
    
1379
    # Verbose
1380
    if ($Carp::Verbose) { croak $error }
1381
    
1382
    # Not verbose
1383
    else {
1384
        
1385
        # Remove line and module infromation
1386
        my $at_pos = rindex($error, ' at ');
1387
        $error = substr($error, 0, $at_pos);
1388
        $error =~ s/\s+$//;
1389
        croak "$error$append";
1390
    }
1391
}
1392

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1395
sub _need_tables {
1396
    my ($self, $tree, $need_tables, $tables) = @_;
1397
    
cleanup
Yuki Kimoto authored on 2011-04-02
1398
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1399
    foreach my $table (@$tables) {
1400
        if ($tree->{$table}) {
1401
            $need_tables->{$table} = 1;
1402
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1403
        }
1404
    }
1405
}
1406

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

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1477
sub _quote {
1478
    my $self = shift;
1479
    
1480
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1481
         : defined $self->quote ? $self->quote
1482
         : '';
1483
}
1484

            
cleanup
Yuki Kimoto authored on 2011-07-29
1485
sub _q {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1486
    my ($self, $value, $quotemeta) = @_;
cleanup
Yuki Kimoto authored on 2011-07-29
1487
    
1488
    my $quote = $self->_quote;
1489
    my $q = substr($quote, 0, 1) || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1490
    my $p;
1491
    if (defined $quote && length $quote > 1) {
1492
        $p = substr($quote, 1, 1);
1493
    }
1494
    else { $p = $q }
cleanup
Yuki Kimoto authored on 2011-07-29
1495
    
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1496
    if ($quotemeta) {
1497
        $q = quotemeta($q);
1498
        $p = quotemeta($p);
1499
    }
1500
    
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1501
    return "$q$value$p";
cleanup
Yuki Kimoto authored on 2011-07-29
1502
}
1503

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

            
1517
    return $new_tables;
cleanup
Yuki Kimoto authored on 2011-04-02
1518
}
1519

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

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

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

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

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
1656
# DEPRECATED!
1657
has 'data_source';
1658
has dbi_options => sub { {} };
1659
has filter_check  => 1;
1660
has 'reserved_word_quote';
1661

            
1662
# DEPRECATED!
1663
sub assign_param {
1664
    my $self = shift;
1665
    warn "assing_param is DEPRECATED! use assign_clause instead";
1666
    return $self->assign_clause(@_);
1667
}
1668

            
1669
# DEPRECATED
1670
sub update_param {
1671
    my ($self, $param, $opts) = @_;
1672
    
1673
    warn "update_param is DEPRECATED! use assing_clause instead.";
1674
    
1675
    # Create update parameter tag
1676
    my $tag = $self->assign_clause($param, $opts);
1677
    $tag = "set $tag" unless $opts->{no_set};
1678

            
1679
    return $tag;
1680
}
1681

            
updated pod
Yuki Kimoto authored on 2011-06-21
1682
# DEPRECATED!
1683
sub create_query {
1684
    warn "create_query is DEPRECATED! use query option of each method";
1685
    shift->_create_query(@_);
1686
}
1687

            
cleanup
Yuki Kimoto authored on 2011-06-13
1688
# DEPRECATED!
1689
sub apply_filter {
1690
    my $self = shift;
1691
    
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1692
    warn "apply_filter is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-06-13
1693
    return $self->_apply_filter(@_);
1694
}
1695

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

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

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1703
    # Arguments
1704
    my $primary_keys = delete $args{primary_key};
1705
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1706
    my $where = delete $args{where};
1707
    my $param = delete $args{param};
1708
    
1709
    # Check arguments
1710
    foreach my $name (keys %args) {
1711
        croak qq{"$name" is wrong option } . _subname
1712
          unless $SELECT_AT_ARGS{$name};
1713
    }
1714
    
1715
    # Table
1716
    croak qq{"table" option must be specified } . _subname
1717
      unless $args{table};
1718
    my $table = ref $args{table} ? $args{table}->[-1] : $args{table};
1719
    
1720
    # Create where parameter
1721
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1722
    
1723
    return $self->select(where => $where_param, %args);
1724
}
1725

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

            
1731
    warn "delete_at is DEPRECATED! use update and id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1732
    
1733
    # Arguments
1734
    my $primary_keys = delete $args{primary_key};
1735
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1736
    my $where = delete $args{where};
1737
    
1738
    # Check arguments
1739
    foreach my $name (keys %args) {
1740
        croak qq{"$name" is wrong option } . _subname
1741
          unless $DELETE_AT_ARGS{$name};
1742
    }
1743
    
1744
    # Create where parameter
1745
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1746
    
1747
    return $self->delete(where => $where_param, %args);
1748
}
1749

            
cleanup
Yuki Kimoto authored on 2011-06-08
1750
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1751
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1752
sub update_at {
1753
    my $self = shift;
1754

            
1755
    warn "update_at is DEPRECATED! use update and id option instead";
1756
    
1757
    # Arguments
1758
    my $param;
1759
    $param = shift if @_ % 2;
1760
    my %args = @_;
1761
    my $primary_keys = delete $args{primary_key};
1762
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1763
    my $where = delete $args{where};
1764
    my $p = delete $args{param} || {};
1765
    $param  ||= $p;
1766
    
1767
    # Check arguments
1768
    foreach my $name (keys %args) {
1769
        croak qq{"$name" is wrong option } . _subname
1770
          unless $UPDATE_AT_ARGS{$name};
1771
    }
1772
    
1773
    # Create where parameter
1774
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1775
    
1776
    return $self->update(where => $where_param, param => $param, %args);
1777
}
1778

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1779
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1780
our %INSERT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1781
sub insert_at {
1782
    my $self = shift;
1783
    
1784
    warn "insert_at is DEPRECATED! use insert and id option instead";
1785
    
1786
    # Arguments
1787
    my $param;
1788
    $param = shift if @_ % 2;
1789
    my %args = @_;
1790
    my $primary_key = delete $args{primary_key};
1791
    $primary_key = [$primary_key] unless ref $primary_key;
1792
    my $where = delete $args{where};
1793
    my $p = delete $args{param} || {};
1794
    $param  ||= $p;
1795
    
1796
    # Check arguments
1797
    foreach my $name (keys %args) {
1798
        croak qq{"$name" is wrong option } . _subname
1799
          unless $INSERT_AT_ARGS{$name};
1800
    }
1801
    
1802
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-06-08
1803
    my $where_param = $self->_create_param_from_id($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1804
    $param = $self->merge_param($where_param, $param);
1805
    
1806
    return $self->insert(param => $param, %args);
1807
}
1808

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

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

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

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

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

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

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

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

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

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

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1939
=head1 NAME
1940

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

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

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

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

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2014
Named place holder support
2015

            
2016
=item *
2017

            
cleanup
Yuki Kimoto authored on 2011-07-29
2018
Model support
2019

            
2020
=item *
2021

            
2022
Connection manager support
2023

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

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

            
2030
=item *
2031

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

            
2034
=item *
2035

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

            
2038
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2039

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

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

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

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

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

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

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

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

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

            
2067
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2068
        "dbi:mysql:database=$database",
2069
        $user,
2070
        $password,
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2071
        DBIx::Custom->new->default_dbi_option
2072
    );
2073
    
updated pod
Yuki Kimoto authored on 2011-06-21
2074
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2075

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

            
2079
    my $dbi = DBIx::Custom->connect(
2080
      dsn => $dsn, user => $user, password => $password, connector => 1);
2081
    
2082
    my $connector = $dbi->connector; # DBIx::Connector
2083

            
2084
Note that L<DBIx::Connector> must be installed.
2085

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

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

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

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

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

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

            
2101
=head2 C<default_dbi_option>
2102

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2109
    {
2110
        RaiseError => 1,
2111
        PrintError => 0,
2112
        AutoCommit => 1,
2113
    }
packaging one directory
yuki-kimoto authored on 2009-11-16
2114

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

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

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

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

            
2124
    my $last_sql = $dbi->last_sql;
2125
    $dbi = $dbi->last_sql($last_sql);
2126

            
2127
Get last successed SQL executed by C<execute> method.
2128

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2136
=head2 C<password>
2137

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2158
You can set quote pair.
2159

            
2160
    $dbi->quote('[]');
2161

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

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

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

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

            
fixed pod
Yuki Kimoto authored on 2011-09-27
2171
    my $safety_character = $dbi->safety_character;
2172
    $dbi = $dbi->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2173

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

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

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

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

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

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

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

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

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

            
2199
    my $tag_parse = $dbi->tag_parse(0);
2200
    $dbi = $dbi->tag_parse;
2201

            
2202
Enable DEPRECATED tag parsing functionality, default to 1.
2203
If you want to disable tag parsing functionality, set to 0.
2204

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

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

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

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

            
2214
    my $user_column_info = $dbi->user_column_info;
2215
    $dbi = $dbi->user_column_info($user_column_info);
2216

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

            
2219
    [
2220
        {table => 'book', column => 'title', info => {...}},
2221
        {table => 'author', column => 'name', info => {...}}
2222
    ]
2223

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

            
2226
    my $user_column_info
2227
      = $dbi->get_column_info(exclude_table => qr/^system/);
2228
    $dbi->user_column_info($user_column_info);
2229

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

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

            
2235
    my $user_table_info = $dbi->user_table_info;
2236
    $dbi = $dbi->user_table_info($user_table_info);
2237

            
2238
You can set the following data.
2239

            
2240
    [
2241
        {table => 'book', info => {...}},
2242
        {table => 'author', info => {...}}
2243
    ]
2244

            
2245
Usually, you can set return value of C<get_table_info>.
2246

            
2247
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2248
    $dbi->user_table_info($user_table_info);
2249

            
2250
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2251
to find table info.
2252

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2289
Create column clause. The follwoing column clause is created.
2290

            
2291
    book.author as "book.author",
2292
    book.title as "book.title"
2293

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2296
    # Separator is double underbar
2297
    $dbi->separator('__');
2298
    
2299
    book.author as "book__author",
2300
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2301

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

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

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

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

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

            
2325
    my $count = $model->count(table => 'book');
2326

            
2327
Get rows count.
2328

            
2329
Options is same as C<select> method's ones.
2330

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

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

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

            
2344
   $dbi->model('book')->select(...);
2345

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

            
2348
    my $dbh = $dbi->dbh;
2349

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

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

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

            
2357
Execute delete statement.
2358

            
2359
The following opitons are available.
2360

            
2361
=over 4
2362

            
2363
=item C<append>
2364

            
2365
Same as C<select> method's C<append> option.
2366

            
2367
=item C<filter>
2368

            
2369
Same as C<execute> method's C<filter> option.
2370

            
2371
=item C<id>
2372

            
2373
    id => 4
2374
    id => [4, 5]
2375

            
2376
ID corresponding to C<primary_key>.
2377
You can delete rows by C<id> and C<primary_key>.
2378

            
2379
    $dbi->delete(
2380
        parimary_key => ['id1', 'id2'],
2381
        id => [4, 5],
2382
        table => 'book',
2383
    );
2384

            
2385
The above is same as the followin one.
2386

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

            
2389
=item C<prefix>
2390

            
2391
    prefix => 'some'
2392

            
2393
prefix before table name section.
2394

            
2395
    delete some from book
2396

            
2397
=item C<query>
2398

            
2399
Same as C<execute> method's C<query> option.
2400

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

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

            
2405
=item C<table>
2406

            
2407
    table => 'book'
2408

            
2409
Table name.
2410

            
2411
=item C<where>
2412

            
2413
Same as C<select> method's C<where> option.
2414

            
2415
=item C<primary_key>
2416

            
2417
See C<id> option.
2418

            
2419
=item C<bind_type>
2420

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

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

            
2425
Same as C<execute> method's C<type_rule_off> option.
2426

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

            
2429
    type_rule1_off => 1
2430

            
2431
Same as C<execute> method's C<type_rule1_off> option.
2432

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

            
2435
    type_rule2_off => 1
2436

            
2437
Same as C<execute> method's C<type_rule2_off> option.
2438

            
2439
=back
2440

            
2441
=head2 C<delete_all>
2442

            
2443
    $dbi->delete_all(table => $table);
2444

            
2445
Execute delete statement for all rows.
2446
Options is same as C<delete>.
2447

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

            
2450
    $dbi->each_column(
2451
        sub {
2452
            my ($dbi, $table, $column, $column_info) = @_;
2453
            
2454
            my $type = $column_info->{TYPE_NAME};
2455
            
2456
            if ($type eq 'DATE') {
2457
                # ...
2458
            }
2459
        }
2460
    );
2461

            
2462
Iterate all column informations of all table from database.
2463
Argument is callback when one column is found.
2464
Callback receive four arguments, dbi object, table name,
2465
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2466

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

            
2469
    $dbi->each_table(
2470
        sub {
2471
            my ($dbi, $table, $table_info) = @_;
2472
            
2473
            my $table_name = $table_info->{TABLE_NAME};
2474
        }
2475
    );
2476

            
2477
Iterate all table informationsfrom database.
2478
Argument is callback when one table is found.
2479
Callback receive three arguments, dbi object, table name,
2480
table information.
2481

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

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

            
2489
    my $result = $dbi->execute(
2490
      "select * from book where title = :book.title and author like :book.author",
2491
      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
update pod
Yuki Kimoto authored on 2011-03-13
2492
    );
2493

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

            
I call :title named placehol...
Yuki Kimoto authored on 2011-07-30
2500
Named placeholder such as C<:title> is replaced by placeholder C<?>.
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2501
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2502
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2503
    select * from book where title = :title and author like :author
2504
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2505
    # Replaced
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2506
    select * from where title = ? and author like ?;
update pod
Yuki Kimoto authored on 2011-03-13
2507

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2511
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2512
    select * from book where :title{=} and :author{like}
2513
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2514
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2515
    select * from where title = ? and author like ?;
2516

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

            
2521
    select * from where title = "aa\\:bb";
2522

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

            
2525
=over 4
2526

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

            
2529
Specify database bind data type.
2530

            
2531
    bind_type => [image => DBI::SQL_BLOB]
2532
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2533

            
2534
This is used to bind parameter by C<bind_param> of statment handle.
2535

            
2536
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2537

            
update pod
Yuki Kimoto authored on 2011-03-13
2538
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2539
    
2540
    filter => {
2541
        title  => sub { uc $_[0] }
2542
        author => sub { uc $_[0] }
2543
    }
update pod
Yuki Kimoto authored on 2011-03-13
2544

            
updated pod
Yuki Kimoto authored on 2011-06-09
2545
    # Filter name
2546
    filter => {
2547
        title  => 'upper_case',
2548
        author => 'upper_case'
2549
    }
2550
        
2551
    # At once
2552
    filter => [
2553
        [qw/title author/]  => sub { uc $_[0] }
2554
    ]
2555

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

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

            
2563
    id => 4
2564
    id => [4, 5]
2565

            
2566
ID corresponding to C<primary_key>.
2567
You can delete rows by C<id> and C<primary_key>.
2568

            
2569
    $dbi->execute(
2570
        "select * from book where id1 = :id1 and id2 = :id2",
2571
        {},
2572
        parimary_key => ['id1', 'id2'],
2573
        id => [4, 5],
2574
    );
2575

            
2576
The above is same as the followin one.
2577

            
2578
    $dbi->execute(
2579
        "select * from book where id1 = :id1 and id2 = :id2",
2580
        {id1 => 4, id2 => 5}
2581
    );
2582

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

            
2585
    query => 1
2586

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

            
2590
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2591
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2592
    my $columns = $query->columns;
2593
    
2594
If you want to execute SQL fast, you can do the following way.
2595

            
2596
    my $query;
2597
    foreach my $row (@$rows) {
2598
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2599
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2600
    }
2601

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

            
2605
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
2606
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2607
    
2608
    my $query;
2609
    my $sth;
2610
    foreach my $row (@$rows) {
2611
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2612
      $sth ||= $query->sth;
2613
      $sth->execute(map { $row->{$_} } sort keys %$row);
2614
    }
2615

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

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

            
2622
See C<id> option.
2623

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

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

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

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

            
2632
    $dbi->select(
2633
        table => 'book',
2634
        column => 'distinct(name)',
2635
        after_build_sql => sub {
2636
            "select count(*) from ($_[0]) as t1"
2637
        }
2638
    );
2639

            
2640
The following SQL is executed.
2641

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

            
updated pod
Yuki Kimoto authored on 2011-06-09
2644
=item C<table>
2645
    
2646
    table => 'author'
2647

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

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

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

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

            
2662
    table_alias => {user => 'hiker'}
2663

            
2664
Table alias. Key is real table name, value is alias table name.
2665
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2666
on alias table name.
2667

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

            
2670
    type_rule_off => 1
2671

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

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

            
2676
    type_rule1_off => 1
2677

            
2678
Turn C<into1> type rule off.
2679

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

            
2682
    type_rule2_off => 1
2683

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2712
=head2 C<insert>
2713

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

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

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

            
2722
    {date => \"NOW()"}
2723

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

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

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

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

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

            
2734
Same as C<execute> method's C<bind_type> option.
2735

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

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

            
2740
=item C<id>
2741

            
updated document
Yuki Kimoto authored on 2011-06-09
2742
    id => 4
2743
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2744

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2748
    $dbi->insert(
updated document
Yuki Kimoto authored on 2011-06-09
2749
        {title => 'Perl', author => 'Ken'}
2750
        parimary_key => ['id1', 'id2'],
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2751
        id => [4, 5],
updated document
Yuki Kimoto authored on 2011-06-09
2752
        table => 'book'
update pod
Yuki Kimoto authored on 2011-03-13
2753
    );
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2754

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

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

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

            
2764
    prefix => 'or replace'
2765

            
2766
prefix before table name section
2767

            
2768
    insert or replace into book
2769

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

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

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

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

            
2779
Same as C<execute> method's C<query> option.
2780

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

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

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

            
2787
    table => 'book'
2788

            
2789
Table name.
2790

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

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

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

            
2797
    timestamp => 1
2798

            
2799
If this value is set to 1,
2800
automatically created timestamp column is set based on
2801
C<timestamp> attribute's C<insert> value.
2802

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

            
2805
    type_rule1_off => 1
2806

            
2807
Same as C<execute> method's C<type_rule1_off> option.
2808

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

            
2811
    type_rule2_off => 1
2812

            
2813
Same as C<execute> method's C<type_rule2_off> option.
2814

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

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

            
2819
placeholder wrapped string.
2820

            
2821
If the following statement
2822

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

            
2826
is executed, the following SQL is executed.
2827

            
2828
    insert into book price values ( ? + 5 );
2829

            
update pod
Yuki Kimoto authored on 2011-03-13
2830
=back
2831

            
2832
=over 4
2833

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2834
=head2 C<values_clause>
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2835

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2836
    my $values_clause = $dbi->values_clause({title => 'a', age => 2});
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2837

            
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
2838
Create values clause.
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
2839

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2849
    lib / MyModel.pm
2850
        / MyModel / book.pm
2851
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2852

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

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

            
2857
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2858
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2859
    
2860
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2861

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2866
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2867
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2868
    
2869
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2870

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2873
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2874
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2875
    
2876
    1;
2877
    
updated pod
Yuki Kimoto authored on 2011-06-21
2878
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2879

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

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

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

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

            
2889
    $dbi->insert_timestamp(
2890
      [qw/created_at updated_at/] => sub { localtime });
2891

            
2892
Parameter for timestamp columns when C<insert> method is executed
2893
with C<timestamp> option.
2894

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

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

            
2899
    my $like_value = $dbi->like_value
2900

            
2901
Constant code reference for the like value.
2902

            
2903
    sub { "%$_[0]%" }
2904

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

            
2907
    my $mapper = $dbi->mapper(param => $param);
2908

            
2909
Create a new L<DBIx::Custom::Mapper> object.
2910

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

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

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

            
2917
    {key1 => [1, 1], key2 => 2}
2918

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

            
2921
    $dbi->method(
2922
        update_or_insert => sub {
2923
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2924
            
2925
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2926
        },
2927
        find_or_create   => sub {
2928
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2929
            
2930
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2931
        }
2932
    );
2933

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

            
2936
    $dbi->update_or_insert;
2937
    $dbi->find_or_create;
2938

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

            
2941
    my $model = $dbi->model('book');
2942

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

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

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

            
2949
Create column clause for myself. The follwoing column clause is created.
2950

            
2951
    book.author as author,
2952
    book.title as title
2953

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2956
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2957
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2958
        user => 'ken',
2959
        password => '!LFKD%$&',
2960
        dbi_option => {mysql_enable_utf8 => 1}
2961
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2962

            
2963
Create a new L<DBIx::Custom> object.
2964

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

            
2967
    my $not_exists = $dbi->not_exists;
2968

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

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

            
2974
    my $order = $dbi->order;
2975

            
2976
Create a new L<DBIx::Custom::Order> object.
2977

            
cleanup
yuki-kimoto authored on 2010-10-17
2978
=head2 C<register_filter>
2979

            
update pod
Yuki Kimoto authored on 2011-03-13
2980
    $dbi->register_filter(
2981
        # Time::Piece object to database DATE format
2982
        tp_to_date => sub {
2983
            my $tp = shift;
2984
            return $tp->strftime('%Y-%m-%d');
2985
        },
2986
        # database DATE format to Time::Piece object
2987
        date_to_tp => sub {
2988
           my $date = shift;
2989
           return Time::Piece->strptime($date, '%Y-%m-%d');
2990
        }
2991
    );
cleanup
yuki-kimoto authored on 2010-10-17
2992
    
update pod
Yuki Kimoto authored on 2011-03-13
2993
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
2994

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

            
2997
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2998
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2999
            date => sub { ... },
3000
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3001
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3002
        into2 => {
3003
            date => sub { ... },
3004
            datetime => sub { ... }
3005
        },
3006
        from1 => {
3007
            # DATE
3008
            9 => sub { ... },
3009
            # DATETIME or TIMESTAMP
3010
            11 => sub { ... },
3011
        }
3012
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3013
            # DATE
3014
            9 => sub { ... },
3015
            # DATETIME or TIMESTAMP
3016
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3017
        }
3018
    );
3019

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3035
=over 4
3036

            
3037
=item 1. column name
3038

            
3039
    issue_date
3040
    issue_datetime
3041

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

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

            
3046
    book.issue_date
3047
    book.issue_datetime
3048

            
3049
=back
3050

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

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

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

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

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

            
3063
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3064
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3065
            [qw/DATE DATETIME/] => sub { ... },
3066
        ],
3067
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3068

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
3071
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3072
        table  => 'book',
3073
        column => ['author', 'title'],
3074
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
3075
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3076
    
updated document
Yuki Kimoto authored on 2011-06-09
3077
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3078

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

            
3081
=over 4
3082

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

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

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

            
3089
=item C<bind_type>
3090

            
3091
Same as C<execute> method's C<bind_type> option.
updated document
Yuki Kimoto authored on 2011-06-09
3092
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3093
=item C<column>
3094
    
updated document
Yuki Kimoto authored on 2011-06-09
3095
    column => 'author'
3096
    column => ['author', 'title']
3097

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3106
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
3107
        {book => [qw/author title/]},
3108
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
3109
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
3110

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

            
3113
    book.author as "book.author",
3114
    book.title as "book.title",
3115
    person.name as "person.name",
3116
    person.age as "person.age"
3117

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

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

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

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

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

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

            
3133
=item C<id>
3134

            
3135
    id => 4
3136
    id => [4, 5]
3137

            
3138
ID corresponding to C<primary_key>.
3139
You can select rows by C<id> and C<primary_key>.
3140

            
3141
    $dbi->select(
3142
        parimary_key => ['id1', 'id2'],
3143
        id => [4, 5],
3144
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3145
    );
3146

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3149
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3150
        where => {id1 => 4, id2 => 5},
3151
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3152
    );
3153
    
updated document
Yuki Kimoto authored on 2011-06-09
3154
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3155

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

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

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

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

            
3168
    prefix => 'SQL_CALC_FOUND_ROWS'
3169

            
3170
Prefix of column cluase
3171

            
3172
    select SQL_CALC_FOUND_ROWS title, author from book;
3173

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

            
3176
    join => [
3177
        'left outer join company on book.company_id = company_id',
3178
        'left outer join location on company.location_id = location.id'
3179
    ]
3180
        
3181
Join clause. If column cluase or where clause contain table name like "company.name",
3182
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3183

            
3184
    $dbi->select(
3185
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3186
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3187
        where => {'company.name' => 'Orange'},
3188
        join => [
3189
            'left outer join company on book.company_id = company.id',
3190
            'left outer join location on company.location_id = location.id'
3191
        ]
3192
    );
3193

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3197
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3198
    from book
3199
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3200
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3201

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3202
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
3203
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3204

            
3205
    $dbi->select(
3206
        table => 'book',
3207
        column => ['company.location_id as location_id'],
3208
        where => {'company.name' => 'Orange'},
3209
        join => [
3210
            {
3211
                clause => 'left outer join location on company.location_id = location.id',
3212
                table => ['company', 'location']
3213
            }
3214
        ]
3215
    );
3216

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

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

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

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

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

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

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3236
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3237

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

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

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

            
3244
    type_rule1_off => 1
3245

            
3246
Same as C<execute> method's C<type_rule1_off> option.
3247

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

            
3250
    type_rule2_off => 1
3251

            
3252
Same as C<execute> method's C<type_rule2_off> option.
3253

            
updated document
Yuki Kimoto authored on 2011-06-09
3254
=item C<where>
3255
    
3256
    # Hash refrence
3257
    where => {author => 'Ken', 'title' => 'Perl'}
3258
    
3259
    # DBIx::Custom::Where object
3260
    where => $dbi->where(
3261
        clause => ['and', 'author = :author', 'title like :title'],
3262
        param  => {author => 'Ken', title => '%Perl%'}
3263
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3264
    
3265
    # Array reference 1 (array reference, hash referenc). same as above
3266
    where => [
3267
        ['and', 'author = :author', 'title like :title'],
3268
        {author => 'Ken', title => '%Perl%'}
3269
    ];    
3270
    
3271
    # Array reference 2 (String, hash reference)
3272
    where => [
3273
        'title like :title',
3274
        {title => '%Perl%'}
3275
    ]
3276
    
3277
    # String
3278
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3279

            
updated document
Yuki Kimoto authored on 2011-06-09
3280
Where clause.
3281
    
update pod
Yuki Kimoto authored on 2011-03-12
3282
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3283

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

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

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

            
3290
If you want to set constant value to row data, use scalar reference
3291
as parameter value.
3292

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
3297
=over 4
3298

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

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

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

            
3305
Same as C<execute> method's C<bind_type> option.
3306

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3313
    id => 4
3314
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3315

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3319
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3320
        {title => 'Perl', author => 'Ken'}
3321
        parimary_key => ['id1', 'id2'],
3322
        id => [4, 5],
3323
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3324
    );
update pod
Yuki Kimoto authored on 2011-03-13
3325

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3328
    $dbi->update(
3329
        {title => 'Perl', author => 'Ken'}
3330
        where => {id1 => 4, id2 => 5},
3331
        table => 'book'
3332
    );
update pod
Yuki Kimoto authored on 2011-03-13
3333

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

            
3336
    prefix => 'or replace'
3337

            
3338
prefix before table name section
3339

            
3340
    update or replace book
3341

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

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

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

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

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

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

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

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

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

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

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

            
3365
    timestamp => 1
3366

            
3367
If this value is set to 1,
3368
automatically updated timestamp column is set based on
3369
C<timestamp> attribute's C<update> value.
3370

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

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

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

            
3377
    type_rule1_off => 1
3378

            
3379
Same as C<execute> method's C<type_rule1_off> option.
3380

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

            
3383
    type_rule2_off => 1
3384

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

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

            
3389
Same as C<select> method's C<where> option.
3390

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

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

            
3395
placeholder wrapped string.
3396

            
3397
If the following statement
3398

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

            
3402
is executed, the following SQL is executed.
3403

            
3404
    update book set price =  ? + 5;
3405

            
updated pod
Yuki Kimoto authored on 2011-06-08
3406
=back
update pod
Yuki Kimoto authored on 2011-03-13
3407

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

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

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

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

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

            
3419
Create update parameter tag.
3420

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

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

            
3425
    $dbi->update_timestamp(updated_at => sub { localtime });
3426

            
3427
Parameter for timestamp columns when C<update> method is executed
3428
with C<timestamp> option.
3429

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

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

            
3437
Create a new L<DBIx::Custom::Where> object.
3438

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

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

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

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

            
3448
    $dbi->show_datatype($table);
3449

            
3450
Show data type of the columns of specified table.
3451

            
3452
    book
3453
    title: 5
3454
    issue_date: 91
3455

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

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

            
3460
    $dbi->show_tables;
3461

            
3462
Show tables.
3463

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

            
3466
    $dbi->show_typename($table);
3467

            
3468
Show type name of the columns of specified table.
3469

            
3470
    book
3471
    title: varchar
3472
    issue_date: date
3473

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

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

            
3478
=head2 C<DBIX_CUSTOM_DEBUG>
3479

            
3480
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3481
executed SQL and bind values are printed to STDERR.
3482

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

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

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

            
3489
L<DBIx::Custom>
3490

            
3491
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3492
    data_source # will be removed at 2017/1/1
3493
    dbi_options # will be removed at 2017/1/1
3494
    filter_check # will be removed at 2017/1/1
3495
    reserved_word_quote # will be removed at 2017/1/1
3496
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3497
    
3498
    # Methods
- update_param is DEPRECATED...
Yuki Kimoto authored on 2011-10-04
3499
    assign_param # will be removed at 2017/1/1
3500
    update_param # will be removed at 2017/1/1
3501
    insert_param # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3502
    create_query # will be removed at 2017/1/1
3503
    apply_filter # will be removed at 2017/1/1
3504
    select_at # will be removed at 2017/1/1
3505
    delete_at # will be removed at 2017/1/1
3506
    update_at # will be removed at 2017/1/1
3507
    insert_at # will be removed at 2017/1/1
3508
    register_tag # will be removed at 2017/1/1
3509
    default_bind_filter # will be removed at 2017/1/1
3510
    default_fetch_filter # will be removed at 2017/1/1
3511
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3512
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3513
    register_tag_processor # will be removed at 2017/1/1
3514
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3515
    
3516
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3517
    select method relation option # will be removed at 2017/1/1
3518
    select method param option # will be removed at 2017/1/1
3519
    select method column option [COLUMN, as => ALIAS] format
3520
      # will be removed at 2017/1/1
sqlfilter option is renamed ...
Yuki Kimoto authored on 2011-09-16
3521
    execute method's sqlfilter option # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3522
    
3523
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3524
    execute("select * from {= title}"); # execute method's
3525
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3526
                                        # will be removed at 2017/1/1
3527
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3528

            
3529
L<DBIx::Custom::Model>
3530

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3531
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3532
    filter # will be removed at 2017/1/1
3533
    name # will be removed at 2017/1/1
3534
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3535

            
3536
L<DBIx::Custom::Query>
3537
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3538
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3539
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3540
    table # will be removed at 2017/1/1
3541
    filters # will be removed at 2017/1/1
3542
    
3543
    # Methods
3544
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3545

            
3546
L<DBIx::Custom::QueryBuilder>
3547
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3548
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3549
    tags # will be removed at 2017/1/1
3550
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3551
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3552
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3553
    register_tag # will be removed at 2017/1/1
3554
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3555
    
3556
    # Others
3557
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3558
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3559

            
3560
L<DBIx::Custom::Result>
3561
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3562
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3563
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3564
    
3565
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3566
    end_filter # will be removed at 2017/1/1
3567
    remove_end_filter # will be removed at 2017/1/1
3568
    remove_filter # will be removed at 2017/1/1
3569
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3570

            
3571
L<DBIx::Custom::Tag>
3572

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

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

            
3577
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3578
except for attribute method.
3579
You can check all DEPRECATED functionalities by document.
3580
DEPRECATED functionality is removed after five years,
3581
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
3582
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3583

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

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

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

            
3590
C<< <kimoto.yuki at gmail.com> >>
3591

            
3592
L<http://github.com/yuki-kimoto/DBIx-Custom>
3593

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3594
=head1 AUTHOR
3595

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

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

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

            
3602
This program is free software; you can redistribute it and/or modify it
3603
under the same terms as Perl itself.
3604

            
3605
=cut