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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
4
our $VERSION = '0.1723';
fixed DBIx::Custom::QueryBui...
yuki-kimoto authored on 2010-08-15
5
use 5.008001;
cleanup
yuki-kimoto authored on 2009-12-22
6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
271
    # Delete statement
cleanup
Yuki Kimoto authored on 2011-01-27
272
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
273
    push @sql, "delete";
274
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
275
    push @sql, "from " . $self->_q($table) . " $where_clause";
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
276
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
277
    my $sql = join(' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
278
    
279
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
280
    return $self->execute($sql, $where_param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
281
}
282

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

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

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

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

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

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

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

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

            
380
sub execute {
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
381
    my $self = shift;
382
    my $query = shift;
383
    my $param;
384
    $param = shift if @_ % 2;
385
    my %args = @_;
refactoring delete and delet...
yuki-kimoto authored on 2010-04-28
386
    
cleanup
Yuki Kimoto authored on 2011-04-02
387
    # Arguments
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
388
    my $p = delete $args{param} || {};
389
    $param ||= $p;
cleanup
Yuki Kimoto authored on 2011-04-02
390
    my $tables = delete $args{table} || [];
391
    $tables = [$tables] unless ref $tables eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-04-02
392
    my $filter = delete $args{filter};
cleanup
Yuki Kimoto authored on 2011-04-25
393
    $filter = _array_to_hash($filter);
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
394
    my $bind_type = delete $args{bind_type} || delete $args{type};
395
    $bind_type = _array_to_hash($bind_type);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
396
    my $type_rule_off = delete $args{type_rule_off};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
397
    my $type_rule_off_parts = {
398
        1 => delete $args{type_rule1_off},
399
        2 => delete $args{type_rule2_off}
400
    };
cleanup
Yuki Kimoto authored on 2011-06-09
401
    my $query_return = delete $args{query};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-06-27
402
    my $table_alias = delete $args{table_alias} || {};
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
403
    my $sqlfilter = $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
    
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
422
    $query = $self->_create_query($query, $sqlfilter) 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
cleanup
Yuki Kimoto authored on 2011-01-27
635
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
636
    push @sql, "insert";
637
    push @sql, $prefix if defined $prefix;
updated pod
Yuki Kimoto authored on 2011-09-02
638
    push @sql, "into " . $self->_q($table) . " "
639
      . $self->insert_param($param, {wrap => $wrap});
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
640
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
641
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
642
    
643
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
644
    return $self->execute($sql, $param, table => $table, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
645
}
646

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

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

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

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

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

            
added EXPERIMENTAL map_param...
Yuki Kimoto authored on 2011-06-24
754
sub map_param {
755
    my $self = shift;
756
    my $param = shift;
757
    my %map = @_;
758
    
759
    # Mapping
760
    my $map_param = {};
761
    foreach my $key (keys %map) {
762
        my $value_cb;
763
        my $condition;
764
        my $map_key;
765
        
766
        # Get mapping information
767
        if (ref $map{$key} eq 'ARRAY') {
768
            foreach my $some (@{$map{$key}}) {
769
                $map_key = $some unless ref $some;
770
                $condition = $some->{if} if ref $some eq 'HASH';
771
                $value_cb = $some if ref $some eq 'CODE';
772
            }
773
        }
774
        else {
775
            $map_key = $map{$key};
776
        }
777
        $value_cb ||= sub { $_[0] };
778
        $condition ||= sub { defined $_[0] && length $_[0] };
779

            
780
        # Map parameter
781
        my $value;
782
        if (ref $condition eq 'CODE') {
783
            $map_param->{$map_key} = $value_cb->($param->{$key})
784
              if $condition->($param->{$key});
785
        }
786
        elsif ($condition eq 'exists') {
787
            $map_param->{$map_key} = $value_cb->($param->{$key})
788
              if exists $param->{$key};
789
        }
790
        else { croak qq/Condition must be code reference or "exists" / . _subname }
791
    }
792
    
793
    return $map_param;
794
}
795

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
796
sub merge_param {
797
    my ($self, @params) = @_;
798
    
cleanup
Yuki Kimoto authored on 2011-04-02
799
    # Merge parameters
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
800
    my $merge = {};
801
    foreach my $param (@params) {
802
        foreach my $column (keys %$param) {
803
            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
804
            
805
            if (exists $merge->{$column}) {
806
                $merge->{$column} = [$merge->{$column}]
807
                  unless ref $merge->{$column} eq 'ARRAY';
808
                push @{$merge->{$column}},
809
                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
810
            }
811
            else {
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
812
                $merge->{$column} = $param->{$column};
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
813
            }
814
        }
815
    }
816
    
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
817
    return $merge;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
818
}
819

            
cleanup
Yuki Kimoto authored on 2011-03-21
820
sub method {
821
    my $self = shift;
822
    
cleanup
Yuki Kimoto authored on 2011-04-02
823
    # Register method
cleanup
Yuki Kimoto authored on 2011-03-21
824
    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
825
    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
826
    
827
    return $self;
828
}
829

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
830
sub model {
831
    my ($self, $name, $model) = @_;
832
    
cleanup
Yuki Kimoto authored on 2011-04-02
833
    # Set model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
834
    if ($model) {
835
        $self->models->{$name} = $model;
836
        return $self;
837
    }
838
    
839
    # Check model existance
cleanup
Yuki Kimoto authored on 2011-04-25
840
    croak qq{Model "$name" is not included } . _subname
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
841
      unless $self->models->{$name};
842
    
cleanup
Yuki Kimoto authored on 2011-04-02
843
    # Get model
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
844
    return $self->models->{$name};
845
}
846

            
cleanup
Yuki Kimoto authored on 2011-03-21
847
sub mycolumn {
848
    my ($self, $table, $columns) = @_;
849
    
cleanup
Yuki Kimoto authored on 2011-04-02
850
    # Create column clause
851
    my @column;
cleanup
Yuki Kimoto authored on 2011-03-21
852
    $columns ||= [];
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
853
    push @column, $self->_q($table) . "." . $self->_q($_) .
854
      " as " . $self->_q($_)
855
      for @$columns;
cleanup
Yuki Kimoto authored on 2011-03-21
856
    
857
    return join (', ', @column);
858
}
859

            
added dbi_options attribute
kimoto authored on 2010-12-20
860
sub new {
861
    my $self = shift->SUPER::new(@_);
862
    
cleanup
Yuki Kimoto authored on 2011-04-02
863
    # Check attributes
added dbi_options attribute
kimoto authored on 2010-12-20
864
    my @attrs = keys %$self;
865
    foreach my $attr (@attrs) {
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-08-20
866
        croak qq{Invalid attribute: "$attr" } . _subname
added dbi_options attribute
kimoto authored on 2010-12-20
867
          unless $self->can($attr);
868
    }
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
869

            
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
870
    # DEPRECATED
cleanup
Yuki Kimoto authored on 2011-08-13
871
    $self->{_tags} = {
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
872
        '?'     => \&DBIx::Custom::Tag::placeholder,
873
        '='     => \&DBIx::Custom::Tag::equal,
874
        '<>'    => \&DBIx::Custom::Tag::not_equal,
875
        '>'     => \&DBIx::Custom::Tag::greater_than,
876
        '<'     => \&DBIx::Custom::Tag::lower_than,
877
        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
878
        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
879
        'like'  => \&DBIx::Custom::Tag::like,
880
        'in'    => \&DBIx::Custom::Tag::in,
881
        'insert_param' => \&DBIx::Custom::Tag::insert_param,
882
        'update_param' => \&DBIx::Custom::Tag::update_param
cleanup
Yuki Kimoto authored on 2011-08-13
883
    };
884
    
885
    return $self;
886
}
887

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

            
890
sub order {
891
    my $self = shift;
892
    return DBIx::Custom::Order->new(dbi => $self, @_);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
893
}
894

            
cleanup
yuki-kimoto authored on 2010-10-17
895
sub register_filter {
cleanup
Yuki Kimoto authored on 2011-04-02
896
    my $self = shift;
cleanup
yuki-kimoto authored on 2010-10-17
897
    
898
    # Register filter
899
    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
cleanup
Yuki Kimoto authored on 2011-04-02
900
    $self->filters({%{$self->filters}, %$filters});
cleanup
yuki-kimoto authored on 2010-10-17
901
    
cleanup
Yuki Kimoto authored on 2011-04-02
902
    return $self;
cleanup
yuki-kimoto authored on 2010-10-17
903
}
packaging one directory
yuki-kimoto authored on 2009-11-16
904

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

            
refactoring select
yuki-kimoto authored on 2010-04-28
908
    # Arguments
cleanup
Yuki Kimoto authored on 2011-03-21
909
    my $table = delete $args{table};
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
910
    my $tables = ref $table eq 'ARRAY' ? $table
911
               : defined $table ? [$table]
912
               : [];
cleanup
Yuki Kimoto authored on 2011-03-21
913
    my $columns   = delete $args{column};
914
    my $where     = delete $args{where} || {};
915
    my $append    = delete $args{append};
916
    my $join      = delete $args{join} || [];
cleanup
Yuki Kimoto authored on 2011-04-25
917
    croak qq{"join" must be array reference } . _subname
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
918
      unless ref $join eq 'ARRAY';
cleanup
Yuki Kimoto authored on 2011-03-21
919
    my $relation = delete $args{relation};
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
920
    warn "select() relation option is DEPRECATED!"
added warnings
Yuki Kimoto authored on 2011-06-07
921
      if $relation;
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
922
    my $param = delete $args{param} || {}; # DEPRECATED!
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
923
    warn "select() param option is DEPRECATED!"
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
924
      if keys %$param;
925
    my $where_param = delete $args{where_param} || $param || {};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
926
    my $id = delete $args{id};
927
    my $primary_key = delete $args{primary_key};
928
    croak "update method primary_key option " .
929
          "must be specified when id is specified " . _subname
930
      if defined $id && !defined $primary_key;
931
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
932
    my $prefix = delete $args{prefix};
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
933
    
cleanup
Yuki Kimoto authored on 2011-03-09
934
    # Add relation tables(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-03-21
935
    $self->_add_relation_table($tables, $relation);
packaging one directory
yuki-kimoto authored on 2009-11-16
936
    
cleanup
Yuki Kimoto authored on 2011-04-02
937
    # Select statement
cleanup
Yuki Kimoto authored on 2011-01-27
938
    my @sql;
939
    push @sql, 'select';
packaging one directory
yuki-kimoto authored on 2009-11-16
940
    
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
941
    # Prefix
942
    push @sql, $prefix if defined $prefix;
943
    
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
944
    # Column clause
cleanup
Yuki Kimoto authored on 2011-03-30
945
    if ($columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-07
946
        $columns = [$columns] unless ref $columns eq 'ARRAY';
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
947
        foreach my $column (@$columns) {
- select() column option can...
Yuki Kimoto authored on 2011-06-08
948
            if (ref $column eq 'HASH') {
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
949
                $column = $self->column(%$column) if ref $column eq 'HASH';
- select() column option can...
Yuki Kimoto authored on 2011-06-08
950
            }
951
            elsif (ref $column eq 'ARRAY') {
- select method column optio...
Yuki Kimoto authored on 2011-07-11
952
                if (@$column == 3 && $column->[1] eq 'as') {
953
                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
954
                    splice @$column, 1, 1;
955
                }
956
                
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
957
                $column = join(' ', $column->[0], 'as', $self->_q($column->[1]));
- select() column option can...
Yuki Kimoto authored on 2011-06-08
958
            }
cleanup
Yuki Kimoto authored on 2011-04-02
959
            unshift @$tables, @{$self->_search_tables($column)};
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
960
            push @sql, ($column, ',');
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
961
        }
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
962
        pop @sql if $sql[-1] eq ',';
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
963
    }
964
    else { push @sql, '*' }
965
    
966
    # Table
cleanup
Yuki Kimoto authored on 2011-03-30
967
    push @sql, 'from';
968
    if ($relation) {
969
        my $found = {};
970
        foreach my $table (@$tables) {
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
971
            push @sql, ($self->_q($table), ',') unless $found->{$table};
cleanup
Yuki Kimoto authored on 2011-03-30
972
            $found->{$table} = 1;
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
973
        }
packaging one directory
yuki-kimoto authored on 2009-11-16
974
    }
cleanup
Yuki Kimoto authored on 2011-03-30
975
    else {
976
        my $main_table = $tables->[-1] || '';
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
977
        push @sql, $self->_q($main_table);
cleanup
Yuki Kimoto authored on 2011-03-30
978
    }
979
    pop @sql if ($sql[-1] || '') eq ',';
cleanup
Yuki Kimoto authored on 2011-04-25
980
    croak "Not found table name " . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
981
      unless $tables->[-1];
cleanup
Yuki Kimoto authored on 2011-04-01
982

            
cleanup
Yuki Kimoto authored on 2011-04-02
983
    # Add tables in parameter
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
984
    unshift @$tables,
985
            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
986
    
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
987
    # Where
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
988
    my $where_clause = '';
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
989
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
updated pod
Yuki Kimoto authored on 2011-06-21
990
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
991
        $where_clause = "where " . $where->[0];
992
        $where_param = $where->[1];
993
    }
994
    elsif (ref $where) {
cleanup
Yuki Kimoto authored on 2011-04-25
995
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
996
        $where_param = keys %$where_param
997
                     ? $self->merge_param($where_param, $where->param)
998
                     : $where->param;
cleanup
Yuki Kimoto authored on 2011-04-25
999
        
1000
        # String where
1001
        $where_clause = $where->to_string;
1002
    }
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1003
    elsif ($where) { $where_clause = "where $where" }
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1004
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1005
    # Add table names in where clause
cleanup
Yuki Kimoto authored on 2011-04-02
1006
    unshift @$tables, @{$self->_search_tables($where_clause)};
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1007
    
fixed some select() join opi...
Yuki Kimoto authored on 2011-03-09
1008
    # Push join
1009
    $self->_push_join(\@sql, $join, $tables);
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1010
    
cleanup
Yuki Kimoto authored on 2011-03-09
1011
    # Add where clause
cleanup
Yuki Kimoto authored on 2011-04-02
1012
    push @sql, $where_clause;
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
1013
    
cleanup
Yuki Kimoto authored on 2011-03-08
1014
    # Relation(DEPRECATED!);
cleanup
Yuki Kimoto authored on 2011-04-02
1015
    $self->_push_relation(\@sql, $tables, $relation, $where_clause eq '' ? 1 : 0);
cleanup
Yuki Kimoto authored on 2011-03-08
1016
    
cleanup
Yuki Kimoto authored on 2011-04-02
1017
    # Append
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1018
    push @sql, $append if defined $append;
cleanup
Yuki Kimoto authored on 2011-01-27
1019
    
1020
    # SQL
1021
    my $sql = join (' ', @sql);
packaging one directory
yuki-kimoto authored on 2009-11-16
1022
    
1023
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
1024
    my $result = $self->execute($sql, $where_param, table => $tables, %args);
packaging one directory
yuki-kimoto authored on 2009-11-16
1025
    
1026
    return $result;
1027
}
1028

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
1029
sub setup_model {
1030
    my $self = shift;
1031
    
cleanup
Yuki Kimoto authored on 2011-04-02
1032
    # Setup model
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
1033
    $self->each_column(
1034
        sub {
1035
            my ($self, $table, $column, $column_info) = @_;
1036
            if (my $model = $self->models->{$table}) {
1037
                push @{$model->columns}, $column;
1038
            }
1039
        }
1040
    );
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
1041
    return $self;
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
1042
}
1043

            
update pod
Yuki Kimoto authored on 2011-08-10
1044
sub show_datatype {
1045
    my ($self, $table) = @_;
1046
    croak "Table name must be specified" unless defined $table;
1047
    print "$table\n";
1048
    
1049
    my $result = $self->select(table => $table, where => "'0' <> '0'");
1050
    my $sth = $result->sth;
1051

            
1052
    my $columns = $sth->{NAME};
1053
    my $data_types = $sth->{TYPE};
1054
    
1055
    for (my $i = 0; $i < @$columns; $i++) {
1056
        my $column = $columns->[$i];
1057
        my $data_type = $data_types->[$i];
1058
        print "$column: $data_type\n";
1059
    }
1060
}
1061

            
1062
sub show_typename {
1063
    my ($self, $t) = @_;
1064
    croak "Table name must be specified" unless defined $t;
1065
    print "$t\n";
1066
    
1067
    $self->each_column(sub {
1068
        my ($self, $table, $column, $infos) = @_;
1069
        return unless $table eq $t;
1070
        my $typename = $infos->{TYPE_NAME};
1071
        print "$column: $typename\n";
1072
    });
1073
    
1074
    return $self;
1075
}
1076

            
test cleanup
Yuki Kimoto authored on 2011-08-15
1077
sub show_tables {
1078
    my $self = shift;
1079
    
1080
    my %tables;
1081
    $self->each_table(sub { $tables{$_[1]}++ });
1082
    print join("\n", sort keys %tables) . "\n";
1083
    return $self;
1084
}
1085

            
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1086
sub type_rule {
1087
    my $self = shift;
1088
    
1089
    if (@_) {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
1090
        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1091
        
1092
        # Into
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1093
        foreach my $i (1 .. 2) {
1094
            my $into = "into$i";
cleanup
Yuki Kimoto authored on 2011-08-16
1095
            my $exists_into = exists $type_rule->{$into};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1096
            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1097
            $self->{type_rule} = $type_rule;
1098
            $self->{"_$into"} = {};
1099
            foreach my $type_name (keys %{$type_rule->{$into} || {}}) {
1100
                croak qq{type name of $into section must be lower case}
1101
                  if $type_name =~ /[A-Z]/;
1102
            }
cleanup
Yuki Kimoto authored on 2011-08-16
1103
            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1104
            $self->each_column(sub {
1105
                my ($dbi, $table, $column, $column_info) = @_;
1106
                
1107
                my $type_name = lc $column_info->{TYPE_NAME};
1108
                if ($type_rule->{$into} &&
1109
                    (my $filter = $type_rule->{$into}->{$type_name}))
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1110
                {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1111
                    return unless exists $type_rule->{$into}->{$type_name};
1112
                    if  (defined $filter && ref $filter ne 'CODE') 
1113
                    {
1114
                        my $fname = $filter;
1115
                        croak qq{Filter "$fname" is not registered" } . _subname
1116
                          unless exists $self->filters->{$fname};
1117
                        
1118
                        $filter = $self->filters->{$fname};
1119
                    }
1120

            
micro optimization
Yuki Kimoto authored on 2011-07-30
1121
                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1122
                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1123
                }
1124
            });
1125
        }
1126

            
1127
        # From
1128
        foreach my $i (1 .. 2) {
1129
            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
1130
            foreach my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
1131
                croak qq{data type of from$i section must be lower case or number}
1132
                  if $data_type =~ /[A-Z]/;
1133
                my $fname = $type_rule->{"from$i"}{$data_type};
1134
                if (defined $fname && ref $fname ne 'CODE') {
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1135
                    croak qq{Filter "$fname" is not registered" } . _subname
1136
                      unless exists $self->filters->{$fname};
1137
                    
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1138
                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
1139
                }
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
1140
            }
1141
        }
1142
        
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
1143
        return $self;
1144
    }
1145
    
1146
    return $self->{type_rule} || {};
1147
}
1148

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

            
cleanup
yuki-kimoto authored on 2010-10-17
1152
    # Arguments
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1153
    my $param;
1154
    $param = shift if @_ % 2;
1155
    my %args = @_;
cleanup
Yuki Kimoto authored on 2011-03-21
1156
    my $table = delete $args{table} || '';
cleanup
Yuki Kimoto authored on 2011-04-25
1157
    croak qq{"table" option must be specified } . _subname
improved error messages
Yuki Kimoto authored on 2011-04-18
1158
      unless $table;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1159
    my $p = delete $args{param} || {};
1160
    $param  ||= $p;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1161
    my $where = delete $args{where} || {};
1162
    my $where_param = delete $args{where_param} || {};
1163
    my $append = delete $args{append} || '';
cleanup
Yuki Kimoto authored on 2011-03-21
1164
    my $allow_update_all = delete $args{allow_update_all};
cleanup
Yuki Kimoto authored on 2011-06-08
1165
    my $id = delete $args{id};
1166
    my $primary_key = delete $args{primary_key};
1167
    croak "update method primary_key option " .
1168
          "must be specified when id is specified " . _subname
1169
      if defined $id && !defined $primary_key;
1170
    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1171
    my $prefix = delete $args{prefix};
updated pod
Yuki Kimoto authored on 2011-09-02
1172
    my $wrap = delete $args{wrap};
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1173
    my $timestamp = $args{timestamp};
1174
    
1175
    # Timestamp
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1176
    if ($timestamp && (my $update_timestamp = $self->update_timestamp)) {
1177
        my $columns = $update_timestamp->[0];
1178
        $columns = [$columns] unless ref $columns eq 'ARRAY';
1179
        my $value = $update_timestamp->[1];
1180
        $value = $value->() if ref $value eq 'CODE';
1181
        $param->{$_} = $value for @$columns;
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
1182
    }
1183

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

            
1187
    # Where
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1188
    $where = $self->_create_param_from_id($id, $primary_key) if defined $id;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1189
    my $where_clause = '';
updated pod
Yuki Kimoto authored on 2011-06-21
1190
    if (ref $where eq 'ARRAY' && !ref $where->[0]) {
1191
        $where_clause = "where " . $where->[0];
1192
        $where_param = $where->[1];
1193
    }
1194
    elsif (ref $where) {
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1195
        $where = $self->_where_to_obj($where);
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1196
        $where_param = keys %$where_param
1197
                     ? $self->merge_param($where_param, $where->param)
1198
                     : $where->param;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
1199
        
1200
        # String where
1201
        $where_clause = $where->to_string;
1202
    }
1203
    elsif ($where) { $where_clause = "where $where" }
cleanup
Yuki Kimoto authored on 2011-04-25
1204
    croak qq{"where" must be specified } . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
1205
      if "$where_clause" eq '' && !$allow_update_all;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1206
    
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
1207
    # Merge param
1208
    $param = $self->merge_param($param, $where_param) if keys %$where_param;
1209
    
cleanup
Yuki Kimoto authored on 2011-04-02
1210
    # Update statement
cleanup
Yuki Kimoto authored on 2011-01-27
1211
    my @sql;
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1212
    push @sql, "update";
1213
    push @sql, $prefix if defined $prefix;
added quote method's two cha...
Yuki Kimoto authored on 2011-07-29
1214
    push @sql, $self->_q($table) . " $update_clause $where_clause";
added EXPERIMENTAL insert, u...
Yuki Kimoto authored on 2011-06-21
1215
    push @sql, $append if defined $append;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1216
    
cleanup
Yuki Kimoto authored on 2011-01-27
1217
    # SQL
1218
    my $sql = join(' ', @sql);
1219
    
cleanup
yuki-kimoto authored on 2010-10-17
1220
    # Execute query
updated pod
Yuki Kimoto authored on 2011-06-21
1221
    return $self->execute($sql, $param, table => $table, %args);
removed reconnect method
yuki-kimoto authored on 2010-05-28
1222
}
1223

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

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1226
sub update_param {
updated pod
Yuki Kimoto authored on 2011-09-02
1227
    my ($self, $param, $opts) = @_;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1228
    
cleanup
Yuki Kimoto authored on 2011-04-02
1229
    # Create update parameter tag
updated pod
Yuki Kimoto authored on 2011-09-02
1230
    my $tag = $self->assign_param($param, $opts);
1231
    $tag = "set $tag" unless $opts->{no_set};
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1232

            
cleanup
Yuki Kimoto authored on 2011-04-02
1233
    return $tag;
remove experimental DBIx::Cu...
Yuki Kimoto authored on 2011-03-08
1234
}
1235

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
1236
sub update_timestamp {
1237
    my $self = shift;
1238
    
1239
    if (@_) {
1240
        $self->{update_timestamp} = [@_];
1241
        
1242
        return $self;
1243
    }
1244
    return $self->{update_timestamp};
1245
}
1246

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
1249
sub _create_query {
cleanup
Yuki Kimoto authored on 2011-06-13
1250
    
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1251
    my ($self, $source, $sqlfilter) = @_;
cleanup
Yuki Kimoto authored on 2011-06-13
1252
    
updated pod
Yuki Kimoto authored on 2011-06-21
1253
    # Cache
1254
    my $cache = $self->cache;
1255
    
1256
    # Query
1257
    my $query;
1258
    
1259
    # Get cached query
1260
    if ($cache) {
cleanup
Yuki Kimoto authored on 2011-06-13
1261
        
updated pod
Yuki Kimoto authored on 2011-06-21
1262
        # Get query
1263
        my $q = $self->cache_method->($self, $source);
cleanup
Yuki Kimoto authored on 2011-06-13
1264
        
updated pod
Yuki Kimoto authored on 2011-06-21
1265
        # Create query
1266
        if ($q) {
1267
            $query = DBIx::Custom::Query->new($q);
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1268
            $query->{filters} = $self->filters;
cleanup
Yuki Kimoto authored on 2011-06-13
1269
        }
updated pod
Yuki Kimoto authored on 2011-06-21
1270
    }
1271
    
1272
    # Create query
1273
    unless ($query) {
1274

            
1275
        # Create query
1276
        my $builder = $self->query_builder;
1277
        $query = $builder->build_query($source);
1278

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

            
1285
        # Save query to cache
1286
        $self->cache_method->(
1287
            $self, $source,
1288
            {
1289
                sql     => $query->sql, 
1290
                columns => $query->columns,
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
1291
                tables  => $query->{tables} || []
updated pod
Yuki Kimoto authored on 2011-06-21
1292
            }
1293
        ) if $cache;
cleanup
Yuki Kimoto authored on 2011-06-13
1294
    }
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
1295

            
1296
    # Filter SQL
1297
    if ($sqlfilter) {
1298
        my $sql = $query->sql;
1299
        $sql = $sqlfilter->($sql);
1300
        $query->sql($sql);
1301
    }
1302
        
added EXPERIMENTAL last_sql ...
Yuki Kimoto authored on 2011-07-11
1303
    # Save sql
1304
    $self->last_sql($query->sql);
1305
    
updated pod
Yuki Kimoto authored on 2011-06-21
1306
    # Prepare statement handle
1307
    my $sth;
1308
    eval { $sth = $self->dbh->prepare($query->{sql})};
1309
    
1310
    if ($@) {
1311
        $self->_croak($@, qq{. Following SQL is executed.\n}
1312
                        . qq{$query->{sql}\n} . _subname);
1313
    }
1314
    
1315
    # Set statement handle
1316
    $query->sth($sth);
1317
    
1318
    # Set filters
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
1319
    $query->{filters} = $self->filters;
updated pod
Yuki Kimoto authored on 2011-06-21
1320
    
1321
    return $query;
cleanup
Yuki Kimoto authored on 2011-06-13
1322
}
1323

            
cleanup
Yuki Kimoto authored on 2011-04-02
1324
sub _create_bind_values {
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1325
    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1326
    
cleanup
Yuki Kimoto authored on 2011-04-02
1327
    # Create bind values
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1328
    my $bind = [];
removed reconnect method
yuki-kimoto authored on 2010-05-28
1329
    my $count = {};
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1330
    my $not_exists = {};
cleanup
Yuki Kimoto authored on 2011-01-12
1331
    foreach my $column (@$columns) {
removed reconnect method
yuki-kimoto authored on 2010-05-28
1332
        
1333
        # Value
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1334
        my $value;
1335
        if(ref $params->{$column} eq 'ARRAY') {
1336
            my $i = $count->{$column} || 0;
1337
            $i += $not_exists->{$column} || 0;
1338
            my $found;
1339
            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1340
                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
1341
                    $not_exists->{$column}++;
1342
                }
1343
                else  {
1344
                    $value = $params->{$column}->[$k];
1345
                    $found = 1;
1346
                    last
1347
                }
1348
            }
1349
            next unless $found;
1350
        }
1351
        else { $value = $params->{$column} }
removed reconnect method
yuki-kimoto authored on 2010-05-28
1352
        
cleanup
Yuki Kimoto authored on 2011-01-12
1353
        # Filter
1354
        my $f = $filter->{$column} || $self->{default_out_filter} || '';
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1355
        $value = $f->($value) if $f;
1356
        
1357
        # Type rule
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1358
        foreach my $i (1 .. 2) {
1359
            my $type_filter = $type_filters->{$i};
micro optimization
Yuki Kimoto authored on 2011-07-30
1360
            my $tf = $self->{"_into$i"}->{dot}->{$column} || $type_filter->{$column};
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
1361
            $value = $tf->($value) if $tf;
1362
        }
cleanup
kimoto.yuki@gmail.com authored on 2010-12-21
1363
        
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
1364
        # Bind values
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
1365
        push @$bind, {value => $value, bind_type => $bind_type->{$column}};
removed reconnect method
yuki-kimoto authored on 2010-05-28
1366
        
1367
        # Count up 
1368
        $count->{$column}++;
1369
    }
1370
    
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1371
    return $bind;
removed reconnect method
yuki-kimoto authored on 2010-05-28
1372
}
1373

            
cleanup
Yuki Kimoto authored on 2011-06-08
1374
sub _create_param_from_id {
1375
    my ($self, $id, $primary_keys) = @_;
improved error messages
Yuki Kimoto authored on 2011-04-18
1376
    
cleanup
Yuki Kimoto authored on 2011-06-08
1377
    # Create parameter
1378
    my $param = {};
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
1379
    if (defined $id) {
cleanup
Yuki Kimoto authored on 2011-06-08
1380
        $id = [$id] unless ref $id;
1381
        croak qq{"id" must be constant value or array reference}
improved error messages
Yuki Kimoto authored on 2011-04-18
1382
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1383
          unless !ref $id || ref $id eq 'ARRAY';
1384
        croak qq{"id" must contain values same count as primary key}
improved error messages
Yuki Kimoto authored on 2011-04-18
1385
            . " (" . (caller 1)[3] . ")"
cleanup
Yuki Kimoto authored on 2011-06-08
1386
          unless @$primary_keys eq @$id;
improved error messages
Yuki Kimoto authored on 2011-04-18
1387
        for(my $i = 0; $i < @$primary_keys; $i ++) {
cleanup
Yuki Kimoto authored on 2011-06-08
1388
           $param->{$primary_keys->[$i]} = $id->[$i];
improved error messages
Yuki Kimoto authored on 2011-04-18
1389
        }
1390
    }
1391
    
cleanup
Yuki Kimoto authored on 2011-06-08
1392
    return $param;
improved error messages
Yuki Kimoto authored on 2011-04-18
1393
}
1394

            
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1395
sub _connect {
1396
    my $self = shift;
1397
    
1398
    # Attributes
added warnings
Yuki Kimoto authored on 2011-06-07
1399
    my $dsn = $self->data_source;
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
1400
    warn "data_source is DEPRECATED!\n"
fixed bug that data_source D...
Yuki Kimoto authored on 2011-06-13
1401
      if $dsn;
added warnings
Yuki Kimoto authored on 2011-06-07
1402
    $dsn ||= $self->dsn;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1403
    croak qq{"dsn" must be specified } . _subname
1404
      unless $dsn;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1405
    my $user        = $self->user;
1406
    my $password    = $self->password;
1407
    my $dbi_option = {%{$self->dbi_options}, %{$self->dbi_option}};
added warnings
Yuki Kimoto authored on 2011-06-07
1408
    warn "dbi_options is DEPRECATED! use dbi_option instead\n"
1409
      if keys %{$self->dbi_options};
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1410
    
cleanup
Yuki Kimoto authored on 2011-08-16
1411
    $dbi_option = {%{$self->default_dbi_option}, %$dbi_option};
1412
    
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1413
    # Connect
cleanup
Yuki Kimoto authored on 2011-08-16
1414
    my $dbh;
1415
    eval {
1416
        $dbh = DBI->connect(
1417
            $dsn,
1418
            $user,
1419
            $password,
1420
            $dbi_option
1421
        );
1422
    };
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1423
    
1424
    # Connect error
cleanup
Yuki Kimoto authored on 2011-04-25
1425
    croak "$@ " . _subname if $@;
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
1426
    
1427
    return $dbh;
1428
}
1429

            
cleanup
yuki-kimoto authored on 2010-10-17
1430
sub _croak {
1431
    my ($self, $error, $append) = @_;
cleanup
Yuki Kimoto authored on 2011-04-02
1432
    
1433
    # Append
cleanup
yuki-kimoto authored on 2010-10-17
1434
    $append ||= "";
1435
    
1436
    # Verbose
1437
    if ($Carp::Verbose) { croak $error }
1438
    
1439
    # Not verbose
1440
    else {
1441
        
1442
        # Remove line and module infromation
1443
        my $at_pos = rindex($error, ' at ');
1444
        $error = substr($error, 0, $at_pos);
1445
        $error =~ s/\s+$//;
1446
        croak "$error$append";
1447
    }
1448
}
1449

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

            
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1452
sub _need_tables {
1453
    my ($self, $tree, $need_tables, $tables) = @_;
1454
    
cleanup
Yuki Kimoto authored on 2011-04-02
1455
    # Get needed tables
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
1456
    foreach my $table (@$tables) {
1457
        if ($tree->{$table}) {
1458
            $need_tables->{$table} = 1;
1459
            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1460
        }
1461
    }
1462
}
1463

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

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

            
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1529
sub _quote {
1530
    my $self = shift;
1531
    
1532
    return defined $self->reserved_word_quote ? $self->reserved_word_quote
1533
         : defined $self->quote ? $self->quote
1534
         : '';
1535
}
1536

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-04-02
1589
sub _where_to_obj {
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1590
    my ($self, $where) = @_;
1591
    
cleanup
Yuki Kimoto authored on 2011-04-02
1592
    my $obj;
1593
    
1594
    # Hash
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1595
    if (ref $where eq 'HASH') {
1596
        my $clause = ['and'];
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1597
        my $q = $self->_quote;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1598
        foreach my $column (keys %$where) {
fixex [] reserved_word_quote...
Yuki Kimoto authored on 2011-08-14
1599
            my $table;
1600
            my $c;
1601
            if ($column =~ /(?:(.*?)\.)?(.*)/) {
1602
                $table = $1;
1603
                $c = $2;
1604
            }
1605
            
1606
            my $table_quote;
1607
            $table_quote = $self->_q($table) if defined $table;
1608
            my $column_quote = $self->_q($c);
1609
            $column_quote = $table_quote . '.' . $column_quote
1610
              if defined $table_quote;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1611
            push @$clause, "$column_quote = :$column" for keys %$where;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
1612
        }
cleanup
Yuki Kimoto authored on 2011-04-02
1613
        $obj = $self->where(clause => $clause, param => $where);
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1614
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1615
    
1616
    # DBIx::Custom::Where object
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1617
    elsif (ref $where eq 'DBIx::Custom::Where') {
cleanup
Yuki Kimoto authored on 2011-04-02
1618
        $obj = $where;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1619
    }
cleanup
Yuki Kimoto authored on 2011-04-02
1620
    
updated pod
Yuki Kimoto authored on 2011-06-21
1621
    # Array
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1622
    elsif (ref $where eq 'ARRAY') {
cleanup
Yuki Kimoto authored on 2011-04-02
1623
        $obj = $self->where(
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1624
            clause => $where->[0],
1625
            param  => $where->[1]
1626
        );
1627
    }
1628
    
cleanup
Yuki Kimoto authored on 2011-04-02
1629
    # Check where argument
improved error messages
Yuki Kimoto authored on 2011-04-18
1630
    croak qq{"where" must be hash reference or DBIx::Custom::Where object}
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
1631
        . qq{or array reference, which contains where clause and parameter}
cleanup
Yuki Kimoto authored on 2011-04-25
1632
        . _subname
cleanup
Yuki Kimoto authored on 2011-04-02
1633
      unless ref $obj eq 'DBIx::Custom::Where';
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1634
    
cleanup
Yuki Kimoto authored on 2011-04-02
1635
    return $obj;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1636
}
1637

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

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

            
1708
# DEPRECATED!
1709
sub create_query {
1710
    warn "create_query is DEPRECATED! use query option of each method";
1711
    shift->_create_query(@_);
1712
}
1713

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

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

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

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1729
    # Arguments
1730
    my $primary_keys = delete $args{primary_key};
1731
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1732
    my $where = delete $args{where};
1733
    my $param = delete $args{param};
1734
    
1735
    # Check arguments
1736
    foreach my $name (keys %args) {
1737
        croak qq{"$name" is wrong option } . _subname
1738
          unless $SELECT_AT_ARGS{$name};
1739
    }
1740
    
1741
    # Table
1742
    croak qq{"table" option must be specified } . _subname
1743
      unless $args{table};
1744
    my $table = ref $args{table} ? $args{table}->[-1] : $args{table};
1745
    
1746
    # Create where parameter
1747
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1748
    
1749
    return $self->select(where => $where_param, %args);
1750
}
1751

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

            
1757
    warn "delete_at is DEPRECATED! use update and id option instead";
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
1758
    
1759
    # Arguments
1760
    my $primary_keys = delete $args{primary_key};
1761
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1762
    my $where = delete $args{where};
1763
    
1764
    # Check arguments
1765
    foreach my $name (keys %args) {
1766
        croak qq{"$name" is wrong option } . _subname
1767
          unless $DELETE_AT_ARGS{$name};
1768
    }
1769
    
1770
    # Create where parameter
1771
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1772
    
1773
    return $self->delete(where => $where_param, %args);
1774
}
1775

            
cleanup
Yuki Kimoto authored on 2011-06-08
1776
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1777
our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
cleanup
Yuki Kimoto authored on 2011-06-08
1778
sub update_at {
1779
    my $self = shift;
1780

            
1781
    warn "update_at is DEPRECATED! use update and id option instead";
1782
    
1783
    # Arguments
1784
    my $param;
1785
    $param = shift if @_ % 2;
1786
    my %args = @_;
1787
    my $primary_keys = delete $args{primary_key};
1788
    $primary_keys = [$primary_keys] unless ref $primary_keys;
1789
    my $where = delete $args{where};
1790
    my $p = delete $args{param} || {};
1791
    $param  ||= $p;
1792
    
1793
    # Check arguments
1794
    foreach my $name (keys %args) {
1795
        croak qq{"$name" is wrong option } . _subname
1796
          unless $UPDATE_AT_ARGS{$name};
1797
    }
1798
    
1799
    # Create where parameter
1800
    my $where_param = $self->_create_param_from_id($where, $primary_keys);
1801
    
1802
    return $self->update(where => $where_param, param => $param, %args);
1803
}
1804

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1805
# DEPRECATED!
simplified arguments check
Yuki Kimoto authored on 2011-07-11
1806
our %INSERT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1807
sub insert_at {
1808
    my $self = shift;
1809
    
1810
    warn "insert_at is DEPRECATED! use insert and id option instead";
1811
    
1812
    # Arguments
1813
    my $param;
1814
    $param = shift if @_ % 2;
1815
    my %args = @_;
1816
    my $primary_key = delete $args{primary_key};
1817
    $primary_key = [$primary_key] unless ref $primary_key;
1818
    my $where = delete $args{where};
1819
    my $p = delete $args{param} || {};
1820
    $param  ||= $p;
1821
    
1822
    # Check arguments
1823
    foreach my $name (keys %args) {
1824
        croak qq{"$name" is wrong option } . _subname
1825
          unless $INSERT_AT_ARGS{$name};
1826
    }
1827
    
1828
    # Create where parameter
cleanup
Yuki Kimoto authored on 2011-06-08
1829
    my $where_param = $self->_create_param_from_id($where, $primary_key);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
1830
    $param = $self->merge_param($where_param, $param);
1831
    
1832
    return $self->insert(param => $param, %args);
1833
}
1834

            
added warnings
Yuki Kimoto authored on 2011-06-07
1835
# DEPRECATED!
1836
sub register_tag {
test cleanup
Yuki Kimoto authored on 2011-08-10
1837
    my $self = shift;
1838
    
added warnings
Yuki Kimoto authored on 2011-06-07
1839
    warn "register_tag is DEPRECATED!";
test cleanup
Yuki Kimoto authored on 2011-08-10
1840
    
1841
    # Merge tag
1842
    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1843
    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1844
    
1845
    return $self;
1846
}
1847

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

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1858
# DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-06-13
1859
has 'data_source';
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1860
has dbi_options => sub { {} };
1861
has filter_check  => 1;
1862
has 'reserved_word_quote';
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1863

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

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

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

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

            
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1913
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1914
sub insert_param_tag {
1915
    warn "insert_param_tag is DEPRECATED! " .
1916
         "use insert_param instead!";
1917
    return shift->insert_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1918
}
1919

            
1920
# DEPRECATED!
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1921
sub update_param_tag {
fixed DEPRECATED message bug
Yuki Kimoto authored on 2011-06-10
1922
    warn "update_param_tag is DEPRECATED! " .
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1923
         "use update_param instead";
1924
    return shift->update_param(@_);
- renamed update_param to up...
Yuki Kimoto authored on 2011-03-30
1925
}
cleanup
Yuki Kimoto authored on 2011-03-08
1926
# DEPRECATED!
1927
sub _push_relation {
1928
    my ($self, $sql, $tables, $relation, $need_where) = @_;
1929
    
1930
    if (keys %{$relation || {}}) {
1931
        push @$sql, $need_where ? 'where' : 'and';
1932
        foreach my $rcolumn (keys %$relation) {
1933
            my $table1 = (split (/\./, $rcolumn))[0];
1934
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1935
            push @$tables, ($table1, $table2);
1936
            push @$sql, ("$rcolumn = " . $relation->{$rcolumn},  'and');
1937
        }
1938
    }
1939
    pop @$sql if $sql->[-1] eq 'and';    
1940
}
1941

            
1942
# DEPRECATED!
1943
sub _add_relation_table {
cleanup
Yuki Kimoto authored on 2011-03-09
1944
    my ($self, $tables, $relation) = @_;
cleanup
Yuki Kimoto authored on 2011-03-08
1945
    
1946
    if (keys %{$relation || {}}) {
1947
        foreach my $rcolumn (keys %$relation) {
1948
            my $table1 = (split (/\./, $rcolumn))[0];
1949
            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1950
            my $table1_exists;
1951
            my $table2_exists;
1952
            foreach my $table (@$tables) {
1953
                $table1_exists = 1 if $table eq $table1;
1954
                $table2_exists = 1 if $table eq $table2;
1955
            }
1956
            unshift @$tables, $table1 unless $table1_exists;
1957
            unshift @$tables, $table2 unless $table2_exists;
1958
        }
1959
    }
1960
}
1961

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

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1964
=head1 NAME
1965

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

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

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
1970
    use DBIx::Custom;
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1971
    
1972
    # Connect
1973
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1974
        dsn => "dbi:mysql:database=dbname",
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
1975
        user => 'ken',
1976
        password => '!LFKD%$&',
1977
        dbi_option => {mysql_enable_utf8 => 1}
1978
    );
cleanup
yuki-kimoto authored on 2010-08-05
1979

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
1980
    # Insert 
updated pod
Yuki Kimoto authored on 2011-06-21
1981
    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
removed reconnect method
yuki-kimoto authored on 2010-05-28
1982
    
1983
    # Update 
updated pod
Yuki Kimoto authored on 2011-06-21
1984
    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
1985
      where  => {id => 5});
removed reconnect method
yuki-kimoto authored on 2010-05-28
1986
    
1987
    # Delete
updated pod
Yuki Kimoto authored on 2011-06-21
1988
    $dbi->delete(table  => 'book', where => {author => 'Ken'});
cleanup
yuki-kimoto authored on 2010-08-05
1989

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

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

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

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2039
Named place holder support
2040

            
2041
=item *
2042

            
cleanup
Yuki Kimoto authored on 2011-07-29
2043
Model support
2044

            
2045
=item *
2046

            
2047
Connection manager support
2048

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

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

            
2055
=item *
2056

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

            
2059
=item *
2060

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

            
2063
=back
pod fix
Yuki Kimoto authored on 2011-01-21
2064

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2072
Module documentations - 
cleanup
Yuki Kimoto authored on 2011-07-29
2073
L<DBIx::Custom::Result>,
2074
L<DBIx::Custom::Query>,
2075
L<DBIx::Custom::Where>,
2076
L<DBIx::Custom::Model>,
2077
L<DBIx::Custom::Order>
updated document
yuki-kimoto authored on 2010-08-08
2078

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

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

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

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

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

            
2092
    my $connector = DBIx::Connector->new(
cleanup
Yuki Kimoto authored on 2011-08-16
2093
        "dbi:mysql:database=$database",
2094
        $user,
2095
        $password,
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2096
        DBIx::Custom->new->default_dbi_option
2097
    );
2098
    
updated pod
Yuki Kimoto authored on 2011-06-21
2099
    my $dbi = DBIx::Custom->connect(connector => $connector);
- removed EXPERIMENTAL Prefo...
Yuki Kimoto authored on 2011-04-04
2100

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

            
2104
    my $dbi = DBIx::Custom->connect(
2105
      dsn => $dsn, user => $user, password => $password, connector => 1);
2106
    
2107
    my $connector = $dbi->connector; # DBIx::Connector
2108

            
2109
Note that L<DBIx::Connector> must be installed.
2110

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

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

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

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

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

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

            
2126
=head2 C<default_dbi_option>
2127

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

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

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

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

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

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

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

            
2149
    my $last_sql = $dbi->last_sql;
2150
    $dbi = $dbi->last_sql($last_sql);
2151

            
2152
Get last successed SQL executed by C<execute> method.
2153

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2161
=head2 C<password>
2162

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

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

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

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-07-30
2183
You can set quote pair.
2184

            
2185
    $dbi->quote('[]');
2186

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

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

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

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

            
- remaned experimental safty...
Yuki Kimoto authored on 2011-03-10
2196
    my $safety_character = $self->safety_character;
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2197
    $dbi = $self->safety_character($character);
update pod
Yuki Kimoto authored on 2011-01-27
2198

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

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

            
2204
    my $separator = $self->separator;
2205
    $dbi = $self->separator($separator);
2206

            
2207
Separator whichi join table and column.
2208
This is used by C<column> and C<mycolumn> method.
2209

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

            
renamed system_table to excl...
Yuki Kimoto authored on 2011-08-10
2212
    my $exclude_table = $self->exclude_table;
2213
    $dbi = $self->exclude_table(qr/pg_/);
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
2214

            
2215
Regex matching system table.
2216
this regex match is used by C<each_table> method and C<each_column> method
2217
System table is ignored.
2218
C<type_rule> method and C<setup_model> method call
renamed system_table to excl...
Yuki Kimoto authored on 2011-08-10
2219
C<each_table>, so if you set C<exclude_table> properly,
added EXPERIMENTAL system_ta...
Yuki Kimoto authored on 2011-08-10
2220
The performance is up.
2221

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

            
2224
    my $tag_parse = $dbi->tag_parse(0);
2225
    $dbi = $dbi->tag_parse;
2226

            
2227
Enable DEPRECATED tag parsing functionality, default to 1.
2228
If you want to disable tag parsing functionality, set to 0.
2229

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

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

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

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

            
2239
    my $user_column_info = $dbi->user_column_info;
2240
    $dbi = $dbi->user_column_info($user_column_info);
2241

            
2242
You can set the following data.
2243

            
2244
    [
2245
        {table => 'book', column => 'title', info => {...}},
2246
        {table => 'author', column => 'name', info => {...}}
2247
    ]
2248

            
2249
Usually, you can set return value of C<get_column_info>.
2250

            
2251
    my $user_column_info
2252
      = $dbi->get_column_info(exclude_table => qr/^system/);
2253
    $dbi->user_column_info($user_column_info);
2254

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

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

            
2260
    my $user_table_info = $dbi->user_table_info;
2261
    $dbi = $dbi->user_table_info($user_table_info);
2262

            
2263
You can set the following data.
2264

            
2265
    [
2266
        {table => 'book', info => {...}},
2267
        {table => 'author', info => {...}}
2268
    ]
2269

            
2270
Usually, you can set return value of C<get_table_info>.
2271

            
2272
    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2273
    $dbi->user_table_info($user_table_info);
2274

            
2275
If C<user_table_info> is set, C<each_table> use C<user_table_info>
2276
to find table info.
2277

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
2312
Create column clause. The follwoing column clause is created.
2313

            
2314
    book.author as "book.author",
2315
    book.title as "book.title"
2316

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
2319
    # Separator is double underbar
2320
    $dbi->separator('__');
2321
    
2322
    book.author as "book__author",
2323
    book.title as "book__title"
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2324

            
cleanup
Yuki Kimoto authored on 2011-06-13
2325
    # Separator is hyphen
2326
    $dbi->separator('-');
2327
    
2328
    book.author as "book-author",
2329
    book.title as "book-title"
2330
    
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
2331
=head2 C<connect>
packaging one directory
yuki-kimoto authored on 2009-11-16
2332

            
update pod
Yuki Kimoto authored on 2011-03-13
2333
    my $dbi = DBIx::Custom->connect(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2334
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
2335
        user => 'ken',
2336
        password => '!LFKD%$&',
2337
        dbi_option => {mysql_enable_utf8 => 1}
2338
    );
2339

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

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

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

            
2348
    my $count = $model->count(table => 'book');
2349

            
2350
Get rows count.
2351

            
2352
Options is same as C<select> method's ones.
2353

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

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2356
    my $model = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2357
        table => 'book',
2358
        primary_key => 'id',
2359
        join => [
2360
            'inner join company on book.comparny_id = company.id'
2361
        ],
2362
    );
2363

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

            
2367
   $dbi->model('book')->select(...);
2368

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

            
2371
    my $dbh = $dbi->dbh;
2372

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

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

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

            
2380
Execute delete statement.
2381

            
2382
The following opitons are available.
2383

            
2384
=over 4
2385

            
2386
=item C<append>
2387

            
2388
Same as C<select> method's C<append> option.
2389

            
2390
=item C<filter>
2391

            
2392
Same as C<execute> method's C<filter> option.
2393

            
2394
=item C<id>
2395

            
2396
    id => 4
2397
    id => [4, 5]
2398

            
2399
ID corresponding to C<primary_key>.
2400
You can delete rows by C<id> and C<primary_key>.
2401

            
2402
    $dbi->delete(
2403
        parimary_key => ['id1', 'id2'],
2404
        id => [4, 5],
2405
        table => 'book',
2406
    );
2407

            
2408
The above is same as the followin one.
2409

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

            
2412
=item C<prefix>
2413

            
2414
    prefix => 'some'
2415

            
2416
prefix before table name section.
2417

            
2418
    delete some from book
2419

            
2420
=item C<query>
2421

            
2422
Same as C<execute> method's C<query> option.
2423

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

            
2426
Same as C<execute> method's C<sqlfilter> option.
2427

            
2428
=item C<table>
2429

            
2430
    table => 'book'
2431

            
2432
Table name.
2433

            
2434
=item C<where>
2435

            
2436
Same as C<select> method's C<where> option.
2437

            
2438
=item C<primary_key>
2439

            
2440
See C<id> option.
2441

            
2442
=item C<bind_type>
2443

            
2444
Same as C<execute> method's C<bind_type> option.
2445

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

            
2448
Same as C<execute> method's C<type_rule_off> option.
2449

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

            
2452
    type_rule1_off => 1
2453

            
2454
Same as C<execute> method's C<type_rule1_off> option.
2455

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

            
2458
    type_rule2_off => 1
2459

            
2460
Same as C<execute> method's C<type_rule2_off> option.
2461

            
2462
=back
2463

            
2464
=head2 C<delete_all>
2465

            
2466
    $dbi->delete_all(table => $table);
2467

            
2468
Execute delete statement for all rows.
2469
Options is same as C<delete>.
2470

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

            
2473
    $dbi->each_column(
2474
        sub {
2475
            my ($dbi, $table, $column, $column_info) = @_;
2476
            
2477
            my $type = $column_info->{TYPE_NAME};
2478
            
2479
            if ($type eq 'DATE') {
2480
                # ...
2481
            }
2482
        }
2483
    );
2484

            
2485
Iterate all column informations of all table from database.
2486
Argument is callback when one column is found.
2487
Callback receive four arguments, dbi object, table name,
2488
column name and column information.
EXPERIMETAL fork safety impl...
Yuki Kimoto authored on 2011-03-12
2489

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

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

            
2500
Iterate all table informationsfrom database.
2501
Argument is callback when one table is found.
2502
Callback receive three arguments, dbi object, table name,
2503
table information.
2504

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

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

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

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

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

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

            
micro optimization
Yuki Kimoto authored on 2011-07-30
2534
    # Original
added EXPERIMENTAL parameter...
Yuki Kimoto authored on 2011-07-29
2535
    select * from book where :title{=} and :author{like}
2536
    
micro optimization
Yuki Kimoto authored on 2011-07-30
2537
    # Replaced
update pod
Yuki Kimoto authored on 2011-03-13
2538
    select * from where title = ? and author like ?;
2539

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

            
2544
    select * from where title = "aa\\:bb";
2545

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

            
2548
=over 4
2549

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

            
2552
Specify database bind data type.
2553

            
2554
    bind_type => [image => DBI::SQL_BLOB]
2555
    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2556

            
2557
This is used to bind parameter by C<bind_param> of statment handle.
2558

            
2559
    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2560

            
update pod
Yuki Kimoto authored on 2011-03-13
2561
=item C<filter>
updated pod
Yuki Kimoto authored on 2011-06-09
2562
    
2563
    filter => {
2564
        title  => sub { uc $_[0] }
2565
        author => sub { uc $_[0] }
2566
    }
update pod
Yuki Kimoto authored on 2011-03-13
2567

            
updated pod
Yuki Kimoto authored on 2011-06-09
2568
    # Filter name
2569
    filter => {
2570
        title  => 'upper_case',
2571
        author => 'upper_case'
2572
    }
2573
        
2574
    # At once
2575
    filter => [
2576
        [qw/title author/]  => sub { uc $_[0] }
2577
    ]
2578

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

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

            
2586
    id => 4
2587
    id => [4, 5]
2588

            
2589
ID corresponding to C<primary_key>.
2590
You can delete rows by C<id> and C<primary_key>.
2591

            
2592
    $dbi->execute(
2593
        "select * from book where id1 = :id1 and id2 = :id2",
2594
        {},
2595
        parimary_key => ['id1', 'id2'],
2596
        id => [4, 5],
2597
    );
2598

            
2599
The above is same as the followin one.
2600

            
2601
    $dbi->execute(
2602
        "select * from book where id1 = :id1 and id2 = :id2",
2603
        {id1 => 4, id2 => 5}
2604
    );
2605

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

            
2608
    query => 1
2609

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

            
2613
    my $sql = $query->sql;
cleanup
Yuki Kimoto authored on 2011-07-30
2614
    my $sth = $query->sth;
Added execute method's query...
Yuki Kimoto authored on 2011-07-30
2615
    my $columns = $query->columns;
2616
    
2617
If you want to execute SQL fast, you can do the following way.
2618

            
2619
    my $query;
2620
    foreach my $row (@$rows) {
2621
      $query ||= $dbi->insert($row, table => 'table1', query => 1);
2622
      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
2623
    }
2624

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

            
2628
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
2629
You can do the following way.
cleanup
Yuki Kimoto authored on 2011-07-30
2630
    
2631
    my $query;
2632
    my $sth;
2633
    foreach my $row (@$rows) {
2634
      $query ||= $dbi->insert($row, table => 'book', query => 1);
2635
      $sth ||= $query->sth;
2636
      $sth->execute(map { $row->{$_} } sort keys %$row);
2637
    }
2638

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

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

            
2645
See C<id> option.
2646

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2647
=item C<sqlfilter> 
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2648

            
2649
SQL filter function.
2650

            
2651
    sqlfilter => $code_ref
2652

            
2653
This option is generally for Oracle and SQL Server paging process.
2654
    
2655
    my $limit = sub {
2656
        my ($sql, $count, $offset) = @_;
2657
        
2658
        my $min = $offset + 1;
2659
        my $max = $offset + $count;
2660
        
2661
        $sql = "select * from ( $sql ) as t where rnum >= $min rnum <= $max";
2662
        
2663
        return $sql;
2664
    }
2665
    $dbi->select(... column => ['ROWNUM rnom'], sqlfilter => sub {
2666
        my $sql = shift;
2667
        return $limit->($sql, 100, 50);
2668
    })
2669

            
updated pod
Yuki Kimoto authored on 2011-06-09
2670
=item C<table>
2671
    
2672
    table => 'author'
2673

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

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

            
updated pod
Yuki Kimoto authored on 2011-06-21
2681
    # Same
2682
    $dbi->execute(
2683
      "select * from book where title = :book.title and author = :book.author",
2684
      {title => 'Perl', author => 'Ken');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2685

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

            
2688
    table_alias => {user => 'hiker'}
2689

            
2690
Table alias. Key is real table name, value is alias table name.
2691
If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
2692
on alias table name.
2693

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

            
2696
    type_rule_off => 1
2697

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

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

            
2702
    type_rule1_off => 1
2703

            
2704
Turn C<into1> type rule off.
2705

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

            
2708
    type_rule2_off => 1
2709

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

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

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

            
2716
    my $tables = $self->get_column_info(exclude_table => qr/^system_/);
2717

            
2718
get column infomation except for one which match C<exclude_table> pattern.
2719

            
2720
    [
2721
        {table => 'book', column => 'title', info => {...}},
2722
        {table => 'author', column => 'name' info => {...}}
2723
    ]
2724

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

            
2727
    my $tables = $self->get_table_info(exclude => qr/^system_/);
update pod
Yuki Kimoto authored on 2011-03-13
2728

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

            
2731
    [
2732
        {table => 'book', info => {...}},
2733
        {table => 'author', info => {...}}
2734
    ]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
2735

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

            
cleanup
yuki-kimoto authored on 2010-10-17
2738
=head2 C<insert>
2739

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

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

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

            
2748
    {date => \"NOW()"}
2749

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

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

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

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

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

            
2760
Same as C<execute> method's C<bind_type> option.
2761

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

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

            
2766
=item C<id>
2767

            
updated document
Yuki Kimoto authored on 2011-06-09
2768
    id => 4
2769
    id => [4, 5]
update pod
Yuki Kimoto authored on 2011-03-13
2770

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

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

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

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

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

            
2790
    prefix => 'or replace'
2791

            
2792
prefix before table name section
2793

            
2794
    insert or replace into book
2795

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

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

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

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

            
2805
Same as C<execute> method's C<query> option.
2806

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
2807
=item C<sqlfilter>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
2808

            
2809
Same as C<execute> method's C<sqlfilter> option.
2810

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

            
2813
    table => 'book'
2814

            
2815
Table name.
2816

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

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

            
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
2821
=item C<timestamp EXPERIMENTAL>
2822

            
2823
    timestamp => 1
2824

            
2825
If this value is set to 1,
2826
automatically created timestamp column is set based on
2827
C<timestamp> attribute's C<insert> value.
2828

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

            
2831
    type_rule1_off => 1
2832

            
2833
Same as C<execute> method's C<type_rule1_off> option.
2834

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

            
2837
    type_rule2_off => 1
2838

            
2839
Same as C<execute> method's C<type_rule2_off> option.
2840

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

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

            
2845
placeholder wrapped string.
2846

            
2847
If the following statement
2848

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

            
2852
is executed, the following SQL is executed.
2853

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

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

            
2858
=over 4
2859

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

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

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

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

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

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2875
    lib / MyModel.pm
2876
        / MyModel / book.pm
2877
                  / company.pm
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2878

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

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

            
2883
    package MyModel;
updated pod
Yuki Kimoto authored on 2011-06-21
2884
    use DBIx::Custom::Model -base;
update pod
Yuki Kimoto authored on 2011-03-13
2885
    
2886
    1;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
2887

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2892
    package MyModel::book;
updated pod
Yuki Kimoto authored on 2011-06-21
2893
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2894
    
2895
    1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2896

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

            
update pod
Yuki Kimoto authored on 2011-03-13
2899
    package MyModel::company;
updated pod
Yuki Kimoto authored on 2011-06-21
2900
    use MyModel -base;
update pod
Yuki Kimoto authored on 2011-03-13
2901
    
2902
    1;
2903
    
updated pod
Yuki Kimoto authored on 2011-06-21
2904
MyModel::book and MyModel::company is included by C<include_model>.
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
2905

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

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

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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
2913
=head2 C<insert_timestamp EXPERIMENTAL>
2914

            
2915
    $dbi->insert_timestamp(
2916
      [qw/created_at updated_at/] => sub { localtime });
2917

            
2918
Parameter for timestamp columns when C<insert> method is executed
2919
with C<timestamp> option.
2920

            
- added EXPERIMENTAL pass at...
Yuki Kimoto authored on 2011-09-02
2921
=head2 C<mapper EXPERIMETNAL>
2922

            
2923
    my $mapper = $dbi->mapper(param => $param);
2924

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

            
added EXPERIMENTAL map_param...
Yuki Kimoto authored on 2011-06-24
2927
=head2 C<map_param> EXPERIMENTAL
2928

            
2929
    my $map_param = $dbi->map_param(
2930
        {id => 1, authro => 'Ken', price => 1900},
2931
        'id' => 'book.id',
2932
        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2933
        'price' => [
2934
            'book.price', {if => sub { length $_[0] }}
2935
        ]
2936
    );
2937

            
2938
Map paramters to other key and value. First argument is original
2939
parameter. this is hash reference. Rest argument is mapping.
2940
By default, Mapping is done if the value length is not zero.
2941

            
2942
=over 4
2943

            
2944
=item Key mapping
2945

            
2946
    'id' => 'book.id'
2947

            
2948
This is only key mapping. Value is same as original one.
2949

            
2950
    (id => 1) is mapped to ('book.id' => 1) if value length is not zero.
2951

            
2952
=item Key and value mapping
2953

            
2954
    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2955

            
2956
This is key and value mapping. Frist element of array reference
2957
is mapped key name, second element is code reference to map the value.
2958

            
2959
    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2960
      if value length is not zero.
2961

            
2962
=item Condition
2963

            
2964
    'price' => ['book.price', {if => 'exists'}]
2965
    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2966
    'price' => ['book.price', {if => sub { defined shift }}]
2967

            
2968
If you need condition, you can sepecify it. this is code reference
2969
or 'exists'. By default, condition is the following one.
2970

            
2971
    sub { defined $_[0] && length $_[0] }
2972

            
2973
=back
2974

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

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

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

            
2981
    {key1 => [1, 1], key2 => 2}
2982

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

            
2985
    $dbi->method(
2986
        update_or_insert => sub {
2987
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2988
            
2989
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2990
        },
2991
        find_or_create   => sub {
2992
            my $self = shift;
update pod
Yuki Kimoto authored on 2011-03-13
2993
            
2994
            # Process
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
2995
        }
2996
    );
2997

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

            
3000
    $dbi->update_or_insert;
3001
    $dbi->find_or_create;
3002

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

            
3005
    my $model = $dbi->model('book');
3006

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

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

            
3011
    my $column = $self->mycolumn(book => ['author', 'title']);
3012

            
3013
Create column clause for myself. The follwoing column clause is created.
3014

            
3015
    book.author as author,
3016
    book.title as title
3017

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

            
update pod
Yuki Kimoto authored on 2011-03-13
3020
    my $dbi = DBIx::Custom->new(
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
3021
        dsn => "dbi:mysql:database=dbname",
update pod
Yuki Kimoto authored on 2011-03-13
3022
        user => 'ken',
3023
        password => '!LFKD%$&',
3024
        dbi_option => {mysql_enable_utf8 => 1}
3025
    );
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
3026

            
3027
Create a new L<DBIx::Custom> object.
3028

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

            
3031
    my $not_exists = $dbi->not_exists;
3032

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

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

            
3038
    my $order = $dbi->order;
3039

            
3040
Create a new L<DBIx::Custom::Order> object.
3041

            
cleanup
yuki-kimoto authored on 2010-10-17
3042
=head2 C<register_filter>
3043

            
update pod
Yuki Kimoto authored on 2011-03-13
3044
    $dbi->register_filter(
3045
        # Time::Piece object to database DATE format
3046
        tp_to_date => sub {
3047
            my $tp = shift;
3048
            return $tp->strftime('%Y-%m-%d');
3049
        },
3050
        # database DATE format to Time::Piece object
3051
        date_to_tp => sub {
3052
           my $date = shift;
3053
           return Time::Piece->strptime($date, '%Y-%m-%d');
3054
        }
3055
    );
cleanup
yuki-kimoto authored on 2010-10-17
3056
    
update pod
Yuki Kimoto authored on 2011-03-13
3057
Register filters, used by C<filter> option of many methods.
cleanup
yuki-kimoto authored on 2010-10-17
3058

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

            
3061
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3062
        into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
3063
            date => sub { ... },
3064
            datetime => sub { ... }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3065
        },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3066
        into2 => {
3067
            date => sub { ... },
3068
            datetime => sub { ... }
3069
        },
3070
        from1 => {
3071
            # DATE
3072
            9 => sub { ... },
3073
            # DATETIME or TIMESTAMP
3074
            11 => sub { ... },
3075
        }
3076
        from2 => {
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3077
            # DATE
3078
            9 => sub { ... },
3079
            # DATETIME or TIMESTAMP
3080
            11 => sub { ... },
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3081
        }
3082
    );
3083

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

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

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

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

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3099
=over 4
3100

            
3101
=item 1. column name
3102

            
3103
    issue_date
3104
    issue_datetime
3105

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

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

            
3110
    book.issue_date
3111
    book.issue_datetime
3112

            
3113
=back
3114

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

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

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

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

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

            
3127
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3128
        into1 => [
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
3129
            [qw/DATE DATETIME/] => sub { ... },
3130
        ],
3131
    );
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
3132

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

            
select method column option ...
Yuki Kimoto authored on 2011-02-22
3135
    my $result = $dbi->select(
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3136
        table  => 'book',
3137
        column => ['author', 'title'],
3138
        where  => {author => 'Ken'},
select method column option ...
Yuki Kimoto authored on 2011-02-22
3139
    );
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3140
    
updated document
Yuki Kimoto authored on 2011-06-09
3141
Execute select statement.
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3142

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

            
3145
=over 4
3146

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

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

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

            
3153
=item C<bind_type>
3154

            
3155
Same as C<execute> method's C<bind_type> option.
updated document
Yuki Kimoto authored on 2011-06-09
3156
    
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3157
=item C<column>
3158
    
updated document
Yuki Kimoto authored on 2011-06-09
3159
    column => 'author'
3160
    column => ['author', 'title']
3161

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3170
    column => [
updated pod
Yuki Kimoto authored on 2011-06-07
3171
        {book => [qw/author title/]},
3172
        {person => [qw/name age/]}
updated document
Yuki Kimoto authored on 2011-06-09
3173
    ]
updated pod
Yuki Kimoto authored on 2011-06-07
3174

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

            
3177
    book.author as "book.author",
3178
    book.title as "book.title",
3179
    person.name as "person.name",
3180
    person.age as "person.age"
3181

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

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

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

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

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

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

            
3197
=item C<id>
3198

            
3199
    id => 4
3200
    id => [4, 5]
3201

            
3202
ID corresponding to C<primary_key>.
3203
You can select rows by C<id> and C<primary_key>.
3204

            
3205
    $dbi->select(
3206
        parimary_key => ['id1', 'id2'],
3207
        id => [4, 5],
3208
        table => 'book'
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3209
    );
3210

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

            
updated pod
Yuki Kimoto authored on 2011-04-25
3213
    $dbi->select(
updated document
Yuki Kimoto authored on 2011-06-09
3214
        where => {id1 => 4, id2 => 5},
3215
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3216
    );
3217
    
updated document
Yuki Kimoto authored on 2011-06-09
3218
=item C<param> EXPERIMETNAL
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
3219

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

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

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

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

            
3232
    prefix => 'SQL_CALC_FOUND_ROWS'
3233

            
3234
Prefix of column cluase
3235

            
3236
    select SQL_CALC_FOUND_ROWS title, author from book;
3237

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

            
3240
    join => [
3241
        'left outer join company on book.company_id = company_id',
3242
        'left outer join location on company.location_id = location.id'
3243
    ]
3244
        
3245
Join clause. If column cluase or where clause contain table name like "company.name",
3246
join clausees needed when SQL is created is used automatically.
update pod
Yuki Kimoto authored on 2011-03-12
3247

            
3248
    $dbi->select(
3249
        table => 'book',
cleanup
Yuki Kimoto authored on 2011-06-13
3250
        column => ['company.location_id as location_id'],
update pod
Yuki Kimoto authored on 2011-03-12
3251
        where => {'company.name' => 'Orange'},
3252
        join => [
3253
            'left outer join company on book.company_id = company.id',
3254
            'left outer join location on company.location_id = location.id'
3255
        ]
3256
    );
3257

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

            
cleanup
Yuki Kimoto authored on 2011-06-13
3261
    select company.location_id as location_id
update pod
Yuki Kimoto authored on 2011-03-12
3262
    from book
3263
      left outer join company on book.company_id = company.id
cleanup
Yuki Kimoto authored on 2011-06-13
3264
    where company.name = ?;
update pod
Yuki Kimoto authored on 2011-03-12
3265

            
added join new syntax
Yuki Kimoto authored on 2011-07-28
3266
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
3267
the join clause correctly.
added join new syntax
Yuki Kimoto authored on 2011-07-28
3268

            
3269
    $dbi->select(
3270
        table => 'book',
3271
        column => ['company.location_id as location_id'],
3272
        where => {'company.name' => 'Orange'},
3273
        join => [
3274
            {
3275
                clause => 'left outer join location on company.location_id = location.id',
3276
                table => ['company', 'location']
3277
            }
3278
        ]
3279
    );
3280

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

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

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

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3292
=item C<sqlfilter>
updated pod
Yuki Kimoto authored on 2011-06-08
3293

            
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3294
Same as C<execute> method's C<sqlfilter> option
updated pod
Yuki Kimoto authored on 2011-06-08
3295

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3300
Table name.
updated pod
Yuki Kimoto authored on 2011-06-08
3301

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

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

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

            
3308
    type_rule1_off => 1
3309

            
3310
Same as C<execute> method's C<type_rule1_off> option.
3311

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

            
3314
    type_rule2_off => 1
3315

            
3316
Same as C<execute> method's C<type_rule2_off> option.
3317

            
updated document
Yuki Kimoto authored on 2011-06-09
3318
=item C<where>
3319
    
3320
    # Hash refrence
3321
    where => {author => 'Ken', 'title' => 'Perl'}
3322
    
3323
    # DBIx::Custom::Where object
3324
    where => $dbi->where(
3325
        clause => ['and', 'author = :author', 'title like :title'],
3326
        param  => {author => 'Ken', title => '%Perl%'}
3327
    );
updated pod
Yuki Kimoto authored on 2011-06-21
3328
    
3329
    # Array reference 1 (array reference, hash referenc). same as above
3330
    where => [
3331
        ['and', 'author = :author', 'title like :title'],
3332
        {author => 'Ken', title => '%Perl%'}
3333
    ];    
3334
    
3335
    # Array reference 2 (String, hash reference)
3336
    where => [
3337
        'title like :title',
3338
        {title => '%Perl%'}
3339
    ]
3340
    
3341
    # String
3342
    where => 'title is null'
update pod
Yuki Kimoto authored on 2011-03-12
3343

            
updated document
Yuki Kimoto authored on 2011-06-09
3344
Where clause.
3345
    
update pod
Yuki Kimoto authored on 2011-03-12
3346
=back
cleanup
Yuki Kimoto authored on 2011-03-08
3347

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

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

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

            
3354
If you want to set constant value to row data, use scalar reference
3355
as parameter value.
3356

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

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

            
update pod
Yuki Kimoto authored on 2011-03-13
3361
=over 4
3362

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

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

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

            
3369
Same as C<execute> method's C<bind_type> option.
3370

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

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

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3377
    id => 4
3378
    id => [4, 5]
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
3379

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

            
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
3383
    $dbi->update(
updated document
Yuki Kimoto authored on 2011-06-09
3384
        {title => 'Perl', author => 'Ken'}
3385
        parimary_key => ['id1', 'id2'],
3386
        id => [4, 5],
3387
        table => 'book'
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
3388
    );
update pod
Yuki Kimoto authored on 2011-03-13
3389

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

            
updated document
Yuki Kimoto authored on 2011-06-09
3392
    $dbi->update(
3393
        {title => 'Perl', author => 'Ken'}
3394
        where => {id1 => 4, id2 => 5},
3395
        table => 'book'
3396
    );
update pod
Yuki Kimoto authored on 2011-03-13
3397

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

            
3400
    prefix => 'or replace'
3401

            
3402
prefix before table name section
3403

            
3404
    update or replace book
3405

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

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

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

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

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

            
- removed EXPERIMENTAL flag ...
Yuki Kimoto authored on 2011-09-12
3417
=item C<sqlfilter>
added EXPERIMENTAL execute m...
Yuki Kimoto authored on 2011-08-14
3418

            
3419
Same as C<execute> method's C<sqlfilter> option.
3420

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

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

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

            
- added EXPERIMENTAL timesta...
Yuki Kimoto authored on 2011-09-02
3427
=item C<timestamp EXPERIMENTAL>
3428

            
3429
    timestamp => 1
3430

            
3431
If this value is set to 1,
3432
automatically updated timestamp column is set based on
3433
C<timestamp> attribute's C<update> value.
3434

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

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

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

            
3441
    type_rule1_off => 1
3442

            
3443
Same as C<execute> method's C<type_rule1_off> option.
3444

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

            
3447
    type_rule2_off => 1
3448

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

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

            
3453
Same as C<select> method's C<where> option.
3454

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

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

            
3459
placeholder wrapped string.
3460

            
3461
If the following statement
3462

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

            
3466
is executed, the following SQL is executed.
3467

            
3468
    update book set price =  ? + 5;
3469

            
updated pod
Yuki Kimoto authored on 2011-06-08
3470
=back
update pod
Yuki Kimoto authored on 2011-03-13
3471

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

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

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

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

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

            
3483
Create update parameter tag.
3484

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

            
- added EXPERIMENTAL update_...
Yuki Kimoto authored on 2011-09-12
3487
=head2 C<insert_timestamp EXPERIMENTAL>
3488

            
3489
    $dbi->update_timestamp(updated_at => sub { localtime });
3490

            
3491
Parameter for timestamp columns when C<update> method is executed
3492
with C<timestamp> option.
3493

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

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

            
3501
Create a new L<DBIx::Custom::Where> object.
3502

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

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

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

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

            
3512
    $dbi->show_datatype($table);
3513

            
3514
Show data type of the columns of specified table.
3515

            
3516
    book
3517
    title: 5
3518
    issue_date: 91
3519

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

            
test cleanup
Yuki Kimoto authored on 2011-08-15
3522
=head2 C<show_tables EXPERIMETNAL>
3523

            
3524
    $dbi->show_tables;
3525

            
3526
Show tables.
3527

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

            
3530
    $dbi->show_typename($table);
3531

            
3532
Show type name of the columns of specified table.
3533

            
3534
    book
3535
    title: varchar
3536
    issue_date: date
3537

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

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

            
3542
=head2 C<DBIX_CUSTOM_DEBUG>
3543

            
3544
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true,
3545
executed SQL and bind values are printed to STDERR.
3546

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

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

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

            
3553
L<DBIx::Custom>
3554

            
3555
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3556
    data_source # will be removed at 2017/1/1
3557
    dbi_options # will be removed at 2017/1/1
3558
    filter_check # will be removed at 2017/1/1
3559
    reserved_word_quote # will be removed at 2017/1/1
3560
    cache_method # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3561
    
3562
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3563
    create_query # will be removed at 2017/1/1
3564
    apply_filter # will be removed at 2017/1/1
3565
    select_at # will be removed at 2017/1/1
3566
    delete_at # will be removed at 2017/1/1
3567
    update_at # will be removed at 2017/1/1
3568
    insert_at # will be removed at 2017/1/1
3569
    register_tag # will be removed at 2017/1/1
3570
    default_bind_filter # will be removed at 2017/1/1
3571
    default_fetch_filter # will be removed at 2017/1/1
3572
    insert_param_tag # will be removed at 2017/1/1
update pod
Yuki Kimoto authored on 2011-08-10
3573
    register_tag # will be removed at 2017/1/1
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3574
    register_tag_processor # will be removed at 2017/1/1
3575
    update_param_tag # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3576
    
3577
    # Options
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3578
    select method relation option # will be removed at 2017/1/1
3579
    select method param option # will be removed at 2017/1/1
3580
    select method column option [COLUMN, as => ALIAS] format
3581
      # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3582
    
3583
    # Others
cleanup
Yuki Kimoto authored on 2011-07-28
3584
    execute("select * from {= title}"); # execute method's
3585
                                        # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3586
                                        # will be removed at 2017/1/1
3587
    Query caching # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3588

            
3589
L<DBIx::Custom::Model>
3590

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3591
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3592
    filter # will be removed at 2017/1/1
3593
    name # will be removed at 2017/1/1
3594
    type # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3595

            
3596
L<DBIx::Custom::Query>
3597
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3598
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3599
    default_filter # will be removed at 2017/1/1
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3600
    table # will be removed at 2017/1/1
3601
    filters # will be removed at 2017/1/1
3602
    
3603
    # Methods
3604
    filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3605

            
3606
L<DBIx::Custom::QueryBuilder>
3607
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3608
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3609
    tags # will be removed at 2017/1/1
3610
    tag_processors # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3611
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3612
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3613
    register_tag # will be removed at 2017/1/1
3614
    register_tag_processor # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3615
    
3616
    # Others
3617
    build_query("select * from {= title}"); # tag parsing functionality
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3618
                                            # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3619

            
3620
L<DBIx::Custom::Result>
3621
    
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
3622
    # Attribute methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3623
    filter_check # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3624
    
3625
    # Methods
added EXPERIMENTAL each_tabl...
Yuki Kimoto authored on 2011-07-11
3626
    end_filter # will be removed at 2017/1/1
3627
    remove_end_filter # will be removed at 2017/1/1
3628
    remove_filter # will be removed at 2017/1/1
3629
    default_filter # will be removed at 2017/1/1
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3630

            
3631
L<DBIx::Custom::Tag>
3632

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

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

            
3637
If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
3638
except for attribute method.
3639
You can check all DEPRECATED functionalities by document.
3640
DEPRECATED functionality is removed after five years,
3641
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
3642
I extend one year each time he tell me it.
- added EXPERIMENTAL order m...
Yuki Kimoto authored on 2011-06-28
3643

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

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

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

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

            
3652
C<< <kimoto.yuki at gmail.com> >>
3653

            
3654
L<http://github.com/yuki-kimoto/DBIx-Custom>
3655

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
3656
=head1 AUTHOR
3657

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

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

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

            
3664
This program is free software; you can redistribute it and/or modify it
3665
under the same terms as Perl itself.
3666

            
3667
=cut