cleanup
|
1 |
package DBIx::Custom; |
2 | ||
update pod
|
3 |
our $VERSION = '0.1660'; |
fixed DBIx::Custom::QueryBui...
|
4 | |
5 |
use 5.008001; |
|
cleanup
|
6 |
use strict; |
7 |
use warnings; |
|
8 | ||
remove run_transaction().
|
9 |
use base 'Object::Simple'; |
many change
|
10 | |
packaging one directory
|
11 |
use Carp 'croak'; |
12 |
use DBI; |
|
13 |
use DBIx::Custom::Result; |
|
cleanup
|
14 |
use DBIx::Custom::Query; |
cleanup
|
15 |
use DBIx::Custom::QueryBuilder; |
added experimental DBIx::Cus...
|
16 |
use DBIx::Custom::Where; |
add feture. all model class ...
|
17 |
use DBIx::Custom::Model; |
cleanup
|
18 |
use DBIx::Custom::Tag; |
all filter can receive array...
|
19 |
use DBIx::Custom::Util; |
update document
|
20 |
use Encode qw/encode_utf8 decode_utf8/; |
packaging one directory
|
21 | |
fix tests
|
22 |
__PACKAGE__->attr( |
EXPERIMETAL fork safety impl...
|
23 |
[qw/data_source password pid user/], |
fix tests
|
24 |
cache => 1, |
many changed
|
25 |
cache_method => sub { |
26 |
sub { |
|
27 |
my $self = shift; |
|
28 |
|
|
29 |
$self->{_cached} ||= {}; |
|
30 |
|
|
31 |
if (@_ > 1) { |
|
update pod
|
32 |
$self->{_cached}{$_[0]} = $_[1]; |
many changed
|
33 |
} |
34 |
else { |
|
update pod
|
35 |
return $self->{_cached}{$_[0]}; |
many changed
|
36 |
} |
37 |
} |
|
update pod
|
38 |
}, |
39 |
dbi_option => sub { {} }, |
|
40 |
default_dbi_option => sub { |
|
41 |
{ |
|
42 |
RaiseError => 1, |
|
43 |
PrintError => 0, |
|
44 |
AutoCommit => 1 |
|
45 |
} |
|
46 |
}, |
|
fix tests
|
47 |
filters => sub { |
48 |
{ |
|
49 |
encode_utf8 => sub { encode_utf8($_[0]) }, |
|
50 |
decode_utf8 => sub { decode_utf8($_[0]) } |
|
51 |
} |
|
update pod
|
52 |
}, |
53 |
models => sub { {} }, |
|
54 |
query_builder => sub { DBIx::Custom::QueryBuilder->new }, |
|
55 |
result_class => 'DBIx::Custom::Result', |
|
56 |
safety_character => '\w', |
|
57 |
stash => sub { {} } |
|
fix tests
|
58 |
); |
cleanup
|
59 | |
added helper method
|
60 |
our $AUTOLOAD; |
61 |
sub AUTOLOAD { |
|
62 |
my $self = shift; |
|
63 | ||
renamed helper to method.
|
64 |
# Method name |
65 |
my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/; |
|
added helper method
|
66 | |
renamed helper to method.
|
67 |
# Method |
68 |
$self->{_methods} ||= {}; |
|
add feture. all model class ...
|
69 |
if (my $method = $self->{_methods}->{$mname}) { |
70 |
return $self->$method(@_) |
|
71 |
} |
|
72 |
elsif ($self->dbh->can($mname)) { |
|
73 |
$self->dbh->$mname(@_); |
|
74 |
} |
|
75 |
else { |
|
76 |
croak qq/Can't locate object method "$mname" via "$package"/ |
|
77 |
} |
|
added helper method
|
78 |
} |
79 | ||
renamed auto_filter to apply...
|
80 |
sub apply_filter { |
many changed
|
81 |
my ($self, $table, @cinfos) = @_; |
82 | ||
83 |
# Initialize filters |
|
cleanup
|
84 |
$self->{filter} ||= {}; |
many changed
|
85 |
$self->{filter}{out} ||= {}; |
86 |
$self->{filter}{in} ||= {}; |
|
all filter can receive array...
|
87 |
$self->{filter}{end} ||= {}; |
cleanup
|
88 |
|
many changed
|
89 |
# Create filters |
90 |
my $usage = "Usage: \$dbi->apply_filter(" . |
|
fix bug : filter can't over...
|
91 |
"TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " . |
92 |
"COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)"; |
|
many changed
|
93 | |
94 |
for (my $i = 0; $i < @cinfos; $i += 2) { |
|
added auto_filter method
|
95 |
|
many changed
|
96 |
# Column |
97 |
my $column = $cinfos[$i]; |
|
added auto_filter method
|
98 |
|
all filter can receive array...
|
99 |
if (ref $column eq 'ARRAY') { |
100 |
foreach my $c (@$column) { |
|
101 |
push @cinfos, $c, $cinfos[$i + 1]; |
|
102 |
} |
|
103 |
next; |
|
104 |
} |
|
105 |
|
|
fix bug : filter can't over...
|
106 |
# Filter info |
107 |
my $finfo = $cinfos[$i + 1] || {}; |
|
all filter can receive array...
|
108 |
croak "$usage (table: $table)" unless ref $finfo eq 'HASH'; |
fix bug : filter can't over...
|
109 |
foreach my $ftype (keys %$finfo) { |
all filter can receive array...
|
110 |
croak "$usage (table: $table 2)" unless $ftype eq 'in' || $ftype eq 'out' |
fix bug : filter can't over...
|
111 |
|| $ftype eq 'end'; |
many changed
|
112 |
} |
113 |
|
|
fix bug : filter can't over...
|
114 |
foreach my $way (qw/in out end/) { |
115 |
my $filter = $finfo->{$way}; |
|
cleanup
|
116 |
|
fix bug : filter can't over...
|
117 |
# State |
118 |
my $state = !exists $finfo->{$way} ? 'not_exists' |
|
119 |
: !defined $filter ? 'not_defined' |
|
120 |
: ref $filter eq 'CODE' ? 'code' |
|
121 |
: 'name'; |
|
122 |
|
|
123 |
next if $state eq 'not_exists'; |
|
124 |
|
|
125 |
# Check filter |
|
126 |
croak qq{Filter "$filter" is not registered} |
|
127 |
if $state eq 'name' |
|
128 |
&& ! exists $self->filters->{$filter}; |
|
129 |
|
|
130 |
# Filter |
|
131 |
my $f = $state eq 'not_defined' ? undef |
|
132 |
: $state eq 'code' ? $filter |
|
133 |
: $self->filters->{$filter}; |
|
134 |
$self->{filter}{$way}{$table}{$column} = $f; |
|
135 |
$self->{filter}{$way}{$table}{"$table.$column"} = $f; |
|
136 |
$self->{filter}{$way}{$table}{"${table}__$column"} = $f; |
|
many changed
|
137 |
} |
added auto_filter method
|
138 |
} |
139 |
|
|
many changed
|
140 |
return $self; |
added auto_filter method
|
141 |
} |
142 | ||
renamed helper to method.
|
143 |
sub method { |
added helper method
|
144 |
my $self = shift; |
145 |
|
|
146 |
# Merge |
|
renamed helper to method.
|
147 |
my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_}; |
148 |
$self->{_methods} = {%{$self->{_methods} || {}}, %$methods}; |
|
added helper method
|
149 |
|
150 |
return $self; |
|
151 |
} |
|
152 | ||
packaging one directory
|
153 |
sub connect { |
cleanup
|
154 |
my $self = ref $_[0] ? shift : shift->new(@_);; |
removed register_format()
|
155 |
|
EXPERIMETAL fork safety impl...
|
156 |
my $dbh = $self->_connect; |
packaging one directory
|
157 |
|
update document
|
158 |
# Database handle |
packaging one directory
|
159 |
$self->dbh($dbh); |
update document
|
160 |
|
EXPERIMETAL fork safety impl...
|
161 |
# Process ID |
162 |
$self->pid($$); |
|
163 |
|
|
packaging one directory
|
164 |
return $self; |
165 |
} |
|
166 | ||
cleanup
|
167 |
sub create_query { |
168 |
my ($self, $source) = @_; |
|
update document
|
169 |
|
cleanup
|
170 |
# Cache |
171 |
my $cache = $self->cache; |
|
update document
|
172 |
|
cleanup
|
173 |
# Create query |
174 |
my $query; |
|
175 |
if ($cache) { |
|
176 |
|
|
177 |
# Get query |
|
178 |
my $q = $self->cache_method->($self, $source); |
|
179 |
|
|
180 |
# Create query |
|
add table tag
|
181 |
if ($q) { |
182 |
$query = DBIx::Custom::Query->new($q); |
|
183 |
$query->filters($self->filters); |
|
184 |
} |
|
cleanup
|
185 |
} |
186 |
|
|
187 |
unless ($query) { |
|
cleanup insert
|
188 | |
cleanup
|
189 |
# Create SQL object |
190 |
my $builder = $self->query_builder; |
|
191 |
|
|
192 |
# Create query |
|
193 |
$query = $builder->build_query($source); |
|
removed register_format()
|
194 | |
cleanup
|
195 |
# Cache query |
196 |
$self->cache_method->($self, $source, |
|
197 |
{sql => $query->sql, |
|
add table tag
|
198 |
columns => $query->columns, |
199 |
tables => $query->tables}) |
|
cleanup
|
200 |
if $cache; |
cleanup insert
|
201 |
} |
202 |
|
|
cleanup
|
203 |
# Prepare statement handle |
204 |
my $sth; |
|
205 |
eval { $sth = $self->dbh->prepare($query->{sql})}; |
|
renamed DBIx::Custom::TagPro...
|
206 |
$self->_croak($@, qq{. Following SQL is executed. "$query->{sql}"}) if $@; |
packaging one directory
|
207 |
|
cleanup
|
208 |
# Set statement handle |
209 |
$query->sth($sth); |
|
packaging one directory
|
210 |
|
cleanup
|
211 |
# Set filters |
212 |
$query->filters($self->filters); |
|
213 |
|
|
cleanup
|
214 |
return $query; |
packaging one directory
|
215 |
} |
216 | ||
update pod
|
217 |
sub dbh { |
218 |
my $self = shift; |
|
219 | ||
220 |
if (@_) { |
|
221 |
$self->{dbh} = $_[0]; |
|
222 |
return $self; |
|
223 |
} |
|
224 |
else { |
|
225 |
my $pid = $$; |
|
226 |
if ($self->pid eq $pid) { |
|
227 |
return $self->{dbh}; |
|
228 |
} |
|
229 |
else { |
|
230 |
# Create new connection in child process |
|
231 |
croak "Process is forked in transaction" |
|
232 |
unless $self->{dbh}->{AutoCommit}; |
|
233 |
$self->pid($pid); |
|
234 |
$self->{dbh}->{InactiveDestroy} = 1; |
|
235 |
return $self->{dbh} = $self->_connect; |
|
236 |
} |
|
237 |
} |
|
238 |
} |
|
239 | ||
cleanup
|
240 |
our %VALID_DELETE_ARGS |
added experimental sugar met...
|
241 |
= map { $_ => 1 } qw/table where append filter allow_delete_all query/; |
cleanup update and update_al...
|
242 | |
cleanup
|
243 |
sub delete { |
select, insert, update, upda...
|
244 |
my ($self, %args) = @_; |
cleanup update and update_al...
|
245 |
|
cleanup
|
246 |
# Check argument names |
select, insert, update, upda...
|
247 |
foreach my $name (keys %args) { |
cleanup
|
248 |
croak qq{Argument "$name" is invalid name} |
cleanup
|
249 |
unless $VALID_DELETE_ARGS{$name}; |
cleanup update and update_al...
|
250 |
} |
251 |
|
|
252 |
# Arguments |
|
select, insert, update, upda...
|
253 |
my $table = $args{table} || ''; |
added table not specified ex...
|
254 |
croak qq{"table" option must be specified} unless $table; |
select, insert, update, upda...
|
255 |
my $where = $args{where} || {}; |
select() where can't receive...
|
256 |
my $append = $args{append}; |
select, insert, update, upda...
|
257 |
my $filter = $args{filter}; |
cleanup
|
258 |
my $allow_delete_all = $args{allow_delete_all}; |
added auto_filter method
|
259 | |
make delete() using where ob...
|
260 |
# Where |
261 |
my $w; |
|
262 |
if (ref $where eq 'HASH') { |
|
263 |
my $clause = ['and']; |
|
264 |
push @$clause, "{= $_}" for keys %$where; |
|
265 |
$w = $self->where; |
|
266 |
$w->clause($clause); |
|
improved delete() and update...
|
267 |
$w->param($where); |
packaging one directory
|
268 |
} |
select() where can't receive...
|
269 |
elsif (ref $where eq 'DBIx::Custom::Where') { |
270 |
$w = $where; |
|
271 |
$where = $w->param; |
|
272 |
} |
|
make delete() using where ob...
|
273 |
croak qq{"where" must be hash refernce or DBIx::Custom::Where object} |
274 |
unless ref $w eq 'DBIx::Custom::Where'; |
|
275 |
|
|
select() where can't receive...
|
276 |
# String where |
277 |
my $swhere = "$w"; |
|
improved delete() and update...
|
278 |
|
make delete() using where ob...
|
279 |
croak qq{"where" must be specified} |
select() where can't receive...
|
280 |
if $swhere eq '' && !$allow_delete_all; |
make delete() using where ob...
|
281 | |
cleanup
|
282 |
# SQL stack |
283 |
my @sql; |
|
284 | ||
285 |
# Delete |
|
286 |
push @sql, "delete from $table $swhere"; |
|
287 |
push @sql, $append if $append; |
|
288 |
|
|
289 |
my $sql = join(' ', @sql); |
|
packaging one directory
|
290 |
|
added experimental sugar met...
|
291 |
# Create query |
cleanup
|
292 |
my $query = $self->create_query($sql); |
added experimental sugar met...
|
293 |
return $query if $args{query}; |
294 |
|
|
packaging one directory
|
295 |
# Execute query |
added auto_filter method
|
296 |
my $ret_val = $self->execute( |
added experimental sugar met...
|
297 |
$query, param => $where, filter => $filter, |
renamed auto_filter to apply...
|
298 |
table => $table); |
packaging one directory
|
299 |
|
300 |
return $ret_val; |
|
301 |
} |
|
302 | ||
cleanup
|
303 |
sub delete_all { shift->delete(allow_delete_all => 1, @_) } |
packaging one directory
|
304 | |
add experimental update_at()...
|
305 |
our %VALID_DELETE_AT_ARGS |
update pod
|
306 |
= map { $_ => 1 } qw/table where append filter query primary_key param/; |
add experimental update_at()...
|
307 | |
308 |
sub delete_at { |
|
309 |
my ($self, %args) = @_; |
|
310 |
|
|
cleanup
|
311 |
# Check argument names |
add experimental update_at()...
|
312 |
foreach my $name (keys %args) { |
cleanup
|
313 |
croak qq{Argument "$name" is invalid name} |
add experimental update_at()...
|
314 |
unless $VALID_DELETE_AT_ARGS{$name}; |
315 |
} |
|
316 |
|
|
317 |
# Primary key |
|
318 |
my $primary_keys = delete $args{primary_key}; |
|
319 |
$primary_keys = [$primary_keys] unless ref $primary_keys; |
|
320 |
|
|
321 |
# Where clause |
|
322 |
my $where = {}; |
|
323 |
if (exists $args{where}) { |
|
324 |
my $where_columns = delete $args{where}; |
|
325 |
$where_columns = [$where_columns] unless ref $where_columns; |
|
- added experimental DBIx::C...
|
326 | |
327 |
croak qq{"where" must be constant value or array reference} |
|
328 |
unless !ref $where_columns || ref $where_columns eq 'ARRAY'; |
|
add experimental update_at()...
|
329 |
|
330 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
331 |
$where->{$primary_keys->[$i]} = $where_columns->[$i]; |
|
332 |
} |
|
333 |
} |
|
- added experimental DBIx::C...
|
334 |
|
335 |
if (exists $args{param}) { |
|
add experimental update_at()...
|
336 |
my $param = delete $args{param}; |
337 |
|
|
338 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
- added experimental DBIx::C...
|
339 |
delete $param->{$primary_keys->[$i]}; |
add experimental update_at()...
|
340 |
} |
341 |
} |
|
342 |
|
|
343 |
return $self->delete(where => $where, %args); |
|
344 |
} |
|
345 | ||
added helper method
|
346 |
sub DESTROY { } |
347 | ||
renamed auto_filter to apply...
|
348 |
our %VALID_EXECUTE_ARGS = map { $_ => 1 } qw/param filter table/; |
refactoring delete and delet...
|
349 | |
cleanup
|
350 |
sub execute{ |
351 |
my ($self, $query, %args) = @_; |
|
refactoring delete and delet...
|
352 |
|
cleanup
|
353 |
# Check argument names |
select, insert, update, upda...
|
354 |
foreach my $name (keys %args) { |
cleanup
|
355 |
croak qq{Argument "$name" is invalid name} |
cleanup
|
356 |
unless $VALID_EXECUTE_ARGS{$name}; |
refactoring delete and delet...
|
357 |
} |
358 |
|
|
cleanup
|
359 |
my $params = $args{param} || {}; |
packaging one directory
|
360 |
|
cleanup
|
361 |
# First argument is the soruce of SQL |
362 |
$query = $self->create_query($query) |
|
363 |
unless ref $query; |
|
packaging one directory
|
364 |
|
add table tag
|
365 |
# Applied filter |
cleanup
|
366 |
my $filter = {}; |
all filter can receive array...
|
367 |
|
add table tag
|
368 |
my $tables = $query->tables; |
369 |
my $arg_tables = $args{table} || []; |
|
370 |
$arg_tables = [$arg_tables] |
|
371 |
unless ref $arg_tables eq 'ARRAY'; |
|
372 |
push @$tables, @$arg_tables; |
|
cleanup
|
373 | |
374 |
# Organize tables |
|
375 |
my %table_set = map {defined $_ ? ($_ => 1) : ()} @$tables; |
|
376 |
my $main_table = pop @$tables; |
|
377 |
delete $table_set{$main_table} if $main_table; |
|
378 |
$tables = [keys %table_set]; |
|
379 |
push @$tables, $main_table if $main_table; |
|
remove experimental DBIx::Cu...
|
380 |
|
renamed auto_filter to apply...
|
381 |
foreach my $table (@$tables) { |
remove experimental DBIx::Cu...
|
382 |
next unless $table; |
cleanup
|
383 |
$filter = { |
384 |
%$filter, |
|
385 |
%{$self->{filter}{out}->{$table} || {}} |
|
added auto_filter method
|
386 |
} |
387 |
} |
|
388 |
|
|
cleanup
|
389 |
# Filter argument |
all filter can receive array...
|
390 |
my $f = DBIx::Custom::Util::array_filter_to_hash($args{filter}) |
391 |
|| $query->filter || {}; |
|
cleanup
|
392 |
foreach my $column (keys %$f) { |
393 |
my $fname = $f->{$column}; |
|
renamed auto_filter to apply...
|
394 |
if (!defined $fname) { |
cleanup
|
395 |
$f->{$column} = undef; |
renamed auto_filter to apply...
|
396 |
} |
397 |
elsif (ref $fname ne 'CODE') { |
|
many changed
|
398 |
croak qq{Filter "$fname" is not registered"} |
cleanup
|
399 |
unless exists $self->filters->{$fname}; |
400 |
|
|
cleanup
|
401 |
$f->{$column} = $self->filters->{$fname}; |
cleanup
|
402 |
} |
403 |
} |
|
cleanup
|
404 |
$filter = {%$filter, %$f}; |
packaging one directory
|
405 |
|
added experimental not_exist...
|
406 |
# Bind |
407 |
my $bind = $self->_bind($params, $query->columns, $filter); |
|
cleanup
|
408 |
|
409 |
# Execute |
|
added experimental not_exist...
|
410 |
my $sth = $query->sth; |
cleanup
|
411 |
my $affected; |
added experimental not_exist...
|
412 |
eval {$affected = $sth->execute(@$bind)}; |
renamed DBIx::Custom::TagPro...
|
413 |
$self->_croak($@, qq{. Following SQL is executed. "$query->{sql}"}) if $@; |
cleanup
|
414 |
|
415 |
# Return resultset if select statement is executed |
|
416 |
if ($sth->{NUM_OF_FIELDS}) { |
|
417 |
|
|
fix bug : filter can't over...
|
418 |
# Result in and end filter |
419 |
my $in_filter = {}; |
|
420 |
my $end_filter = {}; |
|
cleanup
|
421 |
foreach my $table (@$tables) { |
remove experimental DBIx::Cu...
|
422 |
next unless $table; |
cleanup
|
423 |
$in_filter = { |
424 |
%$in_filter, |
|
425 |
%{$self->{filter}{in}{$table} || {}} |
|
fix bug : filter can't over...
|
426 |
}; |
427 |
$end_filter = { |
|
428 |
%$end_filter, |
|
429 |
%{$self->{filter}{end}{$table} || {}} |
|
430 |
}; |
|
cleanup
|
431 |
} |
432 |
|
|
433 |
# Result |
|
434 |
my $result = $self->result_class->new( |
|
cleanup
|
435 |
sth => $sth, |
436 |
filters => $self->filters, |
|
437 |
filter_check => $self->filter_check, |
|
cleanup
|
438 |
default_filter => $self->{default_in_filter}, |
fix bug : filter can't over...
|
439 |
filter => $in_filter || {}, |
440 |
end_filter => $end_filter || {} |
|
cleanup
|
441 |
); |
442 | ||
443 |
return $result; |
|
444 |
} |
|
445 |
return $affected; |
|
446 |
} |
|
447 | ||
update pod
|
448 |
our %VALID_INSERT_ARGS |
449 |
= map { $_ => 1 } qw/table param append filter query/; |
|
450 | ||
cleanup
|
451 |
sub insert { |
452 |
my ($self, %args) = @_; |
|
453 | ||
cleanup
|
454 |
# Check argument names |
cleanup
|
455 |
foreach my $name (keys %args) { |
cleanup
|
456 |
croak qq{Argument "$name" is invalid name} |
cleanup
|
457 |
unless $VALID_INSERT_ARGS{$name}; |
packaging one directory
|
458 |
} |
459 |
|
|
cleanup
|
460 |
# Arguments |
added table not specified ex...
|
461 |
my $table = $args{table}; |
462 |
croak qq{"table" option must be specified} unless $table; |
|
cleanup
|
463 |
my $param = $args{param} || {}; |
464 |
my $append = $args{append} || ''; |
|
465 |
my $filter = $args{filter}; |
|
466 |
|
|
select() where can't receive...
|
467 |
# Columns |
468 |
my @columns; |
|
- remaned experimental safty...
|
469 |
my $safety = $self->safety_character; |
select() where can't receive...
|
470 |
foreach my $column (keys %$param) { |
471 |
croak qq{"$column" is not safety column name} |
|
- remaned experimental safty...
|
472 |
unless $column =~ /^[$safety\.]+$/; |
select() where can't receive...
|
473 |
push @columns, $column; |
474 |
} |
|
cleanup
|
475 |
|
cleanup
|
476 |
# SQL stack |
477 |
my @sql; |
|
478 |
|
|
479 |
# Insert |
|
480 |
push @sql, "insert into $table {insert_param ". join(' ', @columns) . '}'; |
|
481 |
push @sql, $append if $append; |
|
482 |
|
|
select() where can't receive...
|
483 |
# SQL |
cleanup
|
484 |
my $sql = join (' ', @sql); |
packaging one directory
|
485 |
|
added experimental sugar met...
|
486 |
# Create query |
cleanup
|
487 |
my $query = $self->create_query($sql); |
added experimental sugar met...
|
488 |
return $query if $args{query}; |
489 |
|
|
packaging one directory
|
490 |
# Execute query |
added auto_filter method
|
491 |
my $ret_val = $self->execute( |
added experimental sugar met...
|
492 |
$query, |
added auto_filter method
|
493 |
param => $param, |
494 |
filter => $filter, |
|
renamed auto_filter to apply...
|
495 |
table => $table |
added auto_filter method
|
496 |
); |
packaging one directory
|
497 |
|
498 |
return $ret_val; |
|
499 |
} |
|
500 | ||
- added experimental DBIx::C...
|
501 |
our %VALID_INSERT_AT_ARGS |
update pod
|
502 |
= map { $_ => 1 } qw/table param where append filter |
503 |
query primary_key param/; |
|
- added experimental DBIx::C...
|
504 | |
505 |
sub insert_at { |
|
506 |
my ($self, %args) = @_; |
|
507 |
|
|
cleanup
|
508 |
# Check argument names |
- added experimental DBIx::C...
|
509 |
foreach my $name (keys %args) { |
cleanup
|
510 |
croak qq{Argument "$name" is invalid name} |
- added experimental DBIx::C...
|
511 |
unless $VALID_INSERT_AT_ARGS{$name}; |
512 |
} |
|
513 |
|
|
514 |
# Primary key |
|
515 |
my $primary_keys = delete $args{primary_key}; |
|
516 |
$primary_keys = [$primary_keys] unless ref $primary_keys; |
|
517 |
|
|
518 |
# Where clause |
|
519 |
my $where = {}; |
|
520 |
my $param = {}; |
|
521 |
|
|
522 |
if (exists $args{where}) { |
|
523 |
my $where_columns = delete $args{where}; |
|
524 |
$where_columns = [$where_columns] unless ref $where_columns; |
|
525 | ||
526 |
croak qq{"where" must be constant value or array reference} |
|
527 |
unless !ref $where_columns || ref $where_columns eq 'ARRAY'; |
|
528 |
|
|
529 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
530 |
$where->{$primary_keys->[$i]} = $where_columns->[$i]; |
|
531 |
} |
|
532 |
} |
|
533 |
|
|
534 |
if (exists $args{param}) { |
|
535 |
$param = delete $args{param}; |
|
536 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
537 |
delete $param->{$primary_keys->[$i]}; |
|
538 |
} |
|
539 |
} |
|
540 |
|
|
541 |
$param = {%$param, %$where}; |
|
542 |
|
|
543 |
return $self->insert(param => $param, %args); |
|
544 |
} |
|
545 | ||
remove experimental DBIx::Cu...
|
546 |
sub insert_param { |
547 |
my ($self, $param) = @_; |
|
548 |
|
|
update pod
|
549 |
# Insert parameter tag |
remove experimental DBIx::Cu...
|
550 |
my @tag; |
551 |
push @tag, '{insert_param'; |
|
- remaned experimental safty...
|
552 |
my $safety = $self->safety_character; |
remove experimental DBIx::Cu...
|
553 |
foreach my $column (keys %$param) { |
added experimental update_pa...
|
554 |
croak qq{"$column" is not safety column name} |
- remaned experimental safty...
|
555 |
unless $column =~ /^[$safety\.]+$/; |
remove experimental DBIx::Cu...
|
556 |
push @tag, $column; |
557 |
} |
|
558 |
push @tag, '}'; |
|
559 |
|
|
560 |
return join ' ', @tag; |
|
561 |
} |
|
562 | ||
pod fix
|
563 |
sub each_column { |
added experimental iterate_a...
|
564 |
my ($self, $cb) = @_; |
565 |
|
|
566 |
# Iterate all tables |
|
567 |
my $sth_tables = $self->dbh->table_info; |
|
568 |
while (my $table_info = $sth_tables->fetchrow_hashref) { |
|
569 |
|
|
570 |
# Table |
|
571 |
my $table = $table_info->{TABLE_NAME}; |
|
572 |
|
|
573 |
# Iterate all columns |
|
574 |
my $sth_columns = $self->dbh->column_info(undef, undef, $table, '%'); |
|
575 |
while (my $column_info = $sth_columns->fetchrow_hashref) { |
|
576 |
my $column = $column_info->{COLUMN_NAME}; |
|
removed experimental txn_sco...
|
577 |
$self->$cb($table, $column, $column_info); |
added experimental iterate_a...
|
578 |
} |
579 |
} |
|
580 |
} |
|
581 | ||
added dbi_options attribute
|
582 |
sub new { |
583 |
my $self = shift->SUPER::new(@_); |
|
584 |
|
|
585 |
# Check attribute names |
|
586 |
my @attrs = keys %$self; |
|
587 |
foreach my $attr (@attrs) { |
|
588 |
croak qq{"$attr" is invalid attribute name} |
|
589 |
unless $self->can($attr); |
|
590 |
} |
|
cleanup
|
591 | |
592 |
$self->register_tag( |
|
593 |
'?' => \&DBIx::Custom::Tag::placeholder, |
|
594 |
'=' => \&DBIx::Custom::Tag::equal, |
|
595 |
'<>' => \&DBIx::Custom::Tag::not_equal, |
|
596 |
'>' => \&DBIx::Custom::Tag::greater_than, |
|
597 |
'<' => \&DBIx::Custom::Tag::lower_than, |
|
598 |
'>=' => \&DBIx::Custom::Tag::greater_than_equal, |
|
599 |
'<=' => \&DBIx::Custom::Tag::lower_than_equal, |
|
600 |
'like' => \&DBIx::Custom::Tag::like, |
|
601 |
'in' => \&DBIx::Custom::Tag::in, |
|
602 |
'insert_param' => \&DBIx::Custom::Tag::insert_param, |
|
603 |
'update_param' => \&DBIx::Custom::Tag::update_param |
|
604 |
); |
|
added dbi_options attribute
|
605 |
|
606 |
return $self; |
|
607 |
} |
|
608 | ||
added experimental not_exist...
|
609 |
sub not_exists { bless {}, 'DBIx::Custom::NotExists' } |
610 | ||
cleanup
|
611 |
sub register_filter { |
612 |
my $invocant = shift; |
|
613 |
|
|
614 |
# Register filter |
|
615 |
my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_}; |
|
616 |
$invocant->filters({%{$invocant->filters}, %$filters}); |
|
617 |
|
|
618 |
return $invocant; |
|
619 |
} |
|
packaging one directory
|
620 | |
renamed DBIx::Custom::TagPro...
|
621 |
sub register_tag { shift->query_builder->register_tag(@_) } |
added register_tag_processor
|
622 | |
refactoring select
|
623 |
our %VALID_SELECT_ARGS |
added select() all_column op...
|
624 |
= map { $_ => 1 } qw/table column where append relation filter query |
625 |
selection join all_column/; |
|
refactoring select
|
626 | |
packaging one directory
|
627 |
sub select { |
select, insert, update, upda...
|
628 |
my ($self, %args) = @_; |
packaging one directory
|
629 |
|
cleanup
|
630 |
# Check argument names |
select, insert, update, upda...
|
631 |
foreach my $name (keys %args) { |
cleanup
|
632 |
croak qq{Argument "$name" is invalid name} |
refactoring select
|
633 |
unless $VALID_SELECT_ARGS{$name}; |
634 |
} |
|
packaging one directory
|
635 |
|
refactoring select
|
636 |
# Arguments |
added table not specified ex...
|
637 |
my $table = $args{table}; |
638 |
my $tables = ref $table eq 'ARRAY' ? $table |
|
639 |
: defined $table ? [$table] |
|
640 |
: []; |
|
add experimental selection o...
|
641 |
my $columns = $args{column} || []; |
added select() all_column op...
|
642 |
$columns = [$columns] unless ref $columns eq 'ARRAY'; |
643 |
my $all_column = $args{all_column}; |
|
add experimental selection o...
|
644 |
my $selection = $args{selection} || ''; |
645 |
my $where = $args{where} || {}; |
|
646 |
my $append = $args{append}; |
|
647 |
my $filter = $args{filter}; |
|
- added experimental DBIx::C...
|
648 |
my $join = $args{join} || []; |
649 |
croak qq{"join" must be array reference} |
|
650 |
unless ref $join eq 'ARRAY'; |
|
remove experimental DBIx::Cu...
|
651 |
|
cleanup
|
652 |
# Add relation tables(DEPRECATED!); |
653 |
$self->_add_relation_table($tables, $args{relation}); |
|
packaging one directory
|
654 |
|
cleanup
|
655 |
# SQL stack |
656 |
my @sql; |
|
657 |
push @sql, 'select'; |
|
packaging one directory
|
658 |
|
cleanup
|
659 |
# Selection |
fixed some select() join opi...
|
660 |
if ($selection) { |
add experimental selection o...
|
661 |
push @sql, $selection; |
fixed some select() join opi...
|
662 |
if ($selection =~ /from\s+(?:\{table\s+)?([^\s\{]+?)\b/) { |
663 |
unshift @$tables, $1; |
|
664 |
} |
|
665 |
unshift @$tables, @{$self->_tables($selection)}; |
|
add experimental selection o...
|
666 |
} |
cleanup
|
667 |
|
added select() all_column op...
|
668 |
# Clumn clause, countains all columns of joined tables |
669 |
elsif ($all_column) { |
|
670 |
|
|
671 |
# Find tables |
|
- added EXPERIMENTAL DBIx::C...
|
672 |
my $main_table; |
added select() all_column op...
|
673 |
my %tables; |
- added EXPERIMENTAL DBIx::C...
|
674 |
if (ref $all_column eq 'ARRAY') { |
675 |
foreach my $table (@$all_column) { |
|
676 |
if (($table || '') eq $tables->[-1]) { |
|
677 |
$main_table = $table; |
|
678 |
} |
|
679 |
else { |
|
680 |
$tables{$table} = 1; |
|
681 |
} |
|
682 |
} |
|
683 |
} |
|
684 |
else { |
|
685 |
$main_table = $tables->[-1] || ''; |
|
686 |
foreach my $j (@$join) { |
|
687 |
my $tables = $self->_tables($j); |
|
688 |
foreach my $table (@$tables) { |
|
689 |
$tables{$table} = 1; |
|
690 |
} |
|
add experimental selection o...
|
691 |
} |
- added EXPERIMENTAL DBIx::C...
|
692 |
delete $tables{$main_table}; |
add experimental selection o...
|
693 |
} |
694 |
|
|
added select() all_column op...
|
695 |
# Column clause of main table |
- added EXPERIMENTAL DBIx::C...
|
696 |
if ($main_table) { |
697 |
push @sql, $self->model($main_table)->column_clause; |
|
698 |
push @sql, ','; |
|
699 |
} |
|
added select() all_column op...
|
700 |
|
701 |
# Column cluase of other tables |
|
702 |
foreach my $table (keys %tables) { |
|
703 |
unshift @$tables, $table; |
|
704 |
push @sql, $self->model($table) |
|
705 |
->column_clause(prefix => "${table}__"); |
|
706 |
push @sql, ','; |
|
707 |
} |
|
708 |
pop @sql if $sql[-1] eq ','; |
|
709 |
} |
|
710 |
|
|
711 |
# Column clause |
|
712 |
elsif (@$columns) { |
|
713 |
foreach my $column (@$columns) { |
|
714 |
unshift @$tables, @{$self->_tables($column)}; |
|
715 |
push @sql, ($column, ','); |
|
716 |
} |
|
717 |
pop @sql if $sql[-1] eq ','; |
|
718 |
} |
|
719 |
|
|
720 |
# "*" is default |
|
721 |
else { push @sql, '*' } |
|
722 |
|
|
723 |
# Table |
|
724 |
unless ($selection) { |
|
add experimental selection o...
|
725 |
push @sql, 'from'; |
fixed some select() join opi...
|
726 |
if ($args{relation}) { |
727 |
my $found = {}; |
|
728 |
foreach my $table (@$tables) { |
|
729 |
push @sql, ($table, ',') unless $found->{$table}; |
|
730 |
$found->{$table} = 1; |
|
731 |
} |
|
packaging one directory
|
732 |
} |
- added EXPERIMENTAL DBIx::C...
|
733 |
else { |
734 |
my $main_table = $tables->[-1] || ''; |
|
735 |
push @sql, $self->view($main_table) |
|
736 |
? $self->view($main_table) |
|
737 |
: $main_table; |
|
738 |
} |
|
fixed some select() join opi...
|
739 |
pop @sql if ($sql[-1] || '') eq ','; |
packaging one directory
|
740 |
} |
741 |
|
|
fixed some select() join opi...
|
742 |
# Main table |
743 |
croak "Not found table name" unless $tables->[-1]; |
|
744 |
|
|
select() where can't receive...
|
745 |
# Where |
746 |
my $w; |
|
added experimental DBIx::Cus...
|
747 |
if (ref $where eq 'HASH') { |
select() where can't receive...
|
748 |
my $clause = ['and']; |
749 |
push @$clause, "{= $_}" for keys %$where; |
|
cleanup
|
750 |
$w = $self->where(clause => $clause, param => $where); |
added experimental DBIx::Cus...
|
751 |
} |
752 |
elsif (ref $where eq 'DBIx::Custom::Where') { |
|
select() where can't receive...
|
753 |
$w = $where; |
754 |
$where = $w->param; |
|
packaging one directory
|
755 |
} |
756 |
|
|
select() where can't receive...
|
757 |
croak qq{"where" must be hash reference or DBIx::Custom::Where object} |
758 |
unless ref $w eq 'DBIx::Custom::Where'; |
|
759 |
|
|
760 |
# String where |
|
761 |
my $swhere = "$w"; |
|
remove experimental DBIx::Cu...
|
762 |
|
fixed some select() join opi...
|
763 |
# Add table names in where clause |
764 |
unshift @$tables, @{$self->_tables($swhere)}; |
|
remove experimental DBIx::Cu...
|
765 |
|
fixed some select() join opi...
|
766 |
# Push join |
767 |
$self->_push_join(\@sql, $join, $tables); |
|
remove experimental DBIx::Cu...
|
768 |
|
cleanup
|
769 |
# Add where clause |
cleanup
|
770 |
push @sql, $swhere; |
select() where can't receive...
|
771 |
|
cleanup
|
772 |
# Relation(DEPRECATED!); |
773 |
$self->_push_relation(\@sql, $tables, $args{relation}, $swhere eq '' ? 1 : 0); |
|
774 |
|
|
cleanup
|
775 |
# Append statement |
776 |
push @sql, $append if $append; |
|
777 |
|
|
778 |
# SQL |
|
779 |
my $sql = join (' ', @sql); |
|
packaging one directory
|
780 |
|
added experimental sugar met...
|
781 |
# Create query |
cleanup
|
782 |
my $query = $self->create_query($sql); |
added experimental sugar met...
|
783 |
return $query if $args{query}; |
784 |
|
|
packaging one directory
|
785 |
# Execute query |
added auto_filter method
|
786 |
my $result = $self->execute( |
select() where can't receive...
|
787 |
$query, param => $where, filter => $filter, |
788 |
table => $tables); |
|
packaging one directory
|
789 |
|
790 |
return $result; |
|
791 |
} |
|
792 | ||
add experimental update_at()...
|
793 |
our %VALID_SELECT_AT_ARGS |
794 |
= map { $_ => 1 } qw/table column where append relation filter query selection |
|
added select() all_column op...
|
795 |
param primary_key join all_column/; |
add experimental update_at()...
|
796 | |
797 |
sub select_at { |
|
798 |
my ($self, %args) = @_; |
|
799 |
|
|
cleanup
|
800 |
# Check argument names |
add experimental update_at()...
|
801 |
foreach my $name (keys %args) { |
cleanup
|
802 |
croak qq{Argument "$name" is invalid name} |
add experimental update_at()...
|
803 |
unless $VALID_SELECT_AT_ARGS{$name}; |
804 |
} |
|
805 |
|
|
806 |
# Primary key |
|
807 |
my $primary_keys = delete $args{primary_key}; |
|
808 |
$primary_keys = [$primary_keys] unless ref $primary_keys; |
|
809 |
|
|
DBIx::Custom::Model select()...
|
810 |
# Table |
811 |
croak qq{"table" option must be specified} unless $args{table}; |
|
812 |
my $table = ref $args{table} ? $args{table}->[-1] : $args{table}; |
|
813 |
|
|
add experimental update_at()...
|
814 |
# Where clause |
815 |
my $where = {}; |
|
816 |
if (exists $args{where}) { |
|
817 |
my $where_columns = delete $args{where}; |
|
- added experimental DBIx::C...
|
818 |
|
819 |
croak qq{"where" must be constant value or array reference} |
|
820 |
unless !ref $where_columns || ref $where_columns eq 'ARRAY'; |
|
821 |
|
|
add experimental update_at()...
|
822 |
$where_columns = [$where_columns] unless ref $where_columns; |
823 |
|
|
824 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
DBIx::Custom::Model select()...
|
825 |
$where->{$table . '.' . $primary_keys->[$i]} = $where_columns->[$i]; |
add experimental update_at()...
|
826 |
} |
827 |
} |
|
- added experimental DBIx::C...
|
828 |
|
829 |
if (exists $args{param}) { |
|
add experimental update_at()...
|
830 |
my $param = delete $args{param}; |
831 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
- added experimental DBIx::C...
|
832 |
delete $param->{$primary_keys->[$i]}; |
add experimental update_at()...
|
833 |
} |
834 |
} |
|
835 |
|
|
836 |
return $self->select(where => $where, %args); |
|
837 |
} |
|
838 | ||
add feture. all model class ...
|
839 |
sub model { |
840 |
my ($self, $name, $model) = @_; |
|
removed experimental base_ta...
|
841 |
|
842 |
# Set |
|
add feture. all model class ...
|
843 |
if ($model) { |
add models() attribute
|
844 |
$self->models->{$name} = $model; |
removed experimental base_ta...
|
845 |
return $self; |
846 |
} |
|
847 |
|
|
add feture. all model class ...
|
848 |
# Check model existance |
849 |
croak qq{Model "$name" is not included} |
|
add models() attribute
|
850 |
unless $self->models->{$name}; |
removed experimental base_ta...
|
851 |
|
852 |
# Get |
|
add models() attribute
|
853 |
return $self->models->{$name}; |
removed experimental base_ta...
|
854 |
} |
855 | ||
add feture. all model class ...
|
856 |
sub include_model { |
857 |
my ($self, $name_space, $model_infos) = @_; |
|
remove DBIx::Custom::Model
|
858 |
|
add feture. all model class ...
|
859 |
$name_space ||= ''; |
860 |
unless ($model_infos) { |
|
861 |
# Load name space module |
|
862 |
croak qq{"$name_space" is invalid class name} |
|
863 |
if $name_space =~ /[^\w:]/; |
|
864 |
eval "use $name_space"; |
|
865 |
croak qq{Name space module "$name_space.pm" is needed. $@} if $@; |
|
table object call dbi object...
|
866 |
|
add feture. all model class ...
|
867 |
# Search model modules |
868 |
my $path = $INC{"$name_space.pm"}; |
|
869 |
$path =~ s/\.pm$//; |
|
870 |
opendir my $dh, $path |
|
871 |
or croak qq{Can't open directory "$path": $!}; |
|
872 |
$model_infos = []; |
|
873 |
while (my $module = readdir $dh) { |
|
874 |
push @$model_infos, $module |
|
875 |
if $module =~ s/\.pm$//; |
|
removed experimental base_ta...
|
876 |
} |
add feture. all model class ...
|
877 |
|
878 |
close $dh; |
|
879 |
} |
|
880 |
|
|
881 |
foreach my $model_info (@$model_infos) { |
|
882 |
|
|
add experimental DBIx::Custo...
|
883 |
# Model class, name, table |
add feture. all model class ...
|
884 |
my $model_class; |
add experimental DBIx::Custo...
|
885 |
my $model_name; |
886 |
my $model_table; |
|
add feture. all model class ...
|
887 |
if (ref $model_info eq 'HASH') { |
add experimental DBIx::Custo...
|
888 |
$model_class = $model_info->{class}; |
889 |
$model_name = $model_info->{name}; |
|
890 |
$model_table = $model_info->{table}; |
|
891 |
|
|
892 |
$model_name ||= $model_class; |
|
893 |
$model_table ||= $model_name; |
|
add feture. all model class ...
|
894 |
} |
add experimental DBIx::Custo...
|
895 |
else { $model_class =$model_name = $model_table = $model_info } |
add feture. all model class ...
|
896 |
my $mclass = "${name_space}::$model_class"; |
table object call dbi object...
|
897 |
|
removed experimental base_ta...
|
898 |
# Load |
add feture. all model class ...
|
899 |
croak qq{"$mclass" is invalid class name} |
900 |
if $mclass =~ /[^\w:]/; |
|
901 |
unless ($mclass->can('isa')) { |
|
902 |
eval "use $mclass"; |
|
removed experimental base_ta...
|
903 |
croak $@ if $@; |
904 |
} |
|
table object call dbi object...
|
905 |
|
removed experimental base_ta...
|
906 |
# Instantiate |
add feture. all model class ...
|
907 |
my $model = $mclass->new(dbi => $self); |
add experimental DBIx::Custo...
|
908 |
$model->name($model_name) unless $model->name; |
909 |
$model->table($model_table) unless $model->table; |
|
removed experimental DBIx::C...
|
910 |
|
removed experimental base_ta...
|
911 |
# Set |
add experimental DBIx::Custo...
|
912 |
$self->model($model->name, $model); |
add experimental DBIx::Custo...
|
913 |
|
- added EXPERIMENTAL DBIx::C...
|
914 |
# View |
915 |
$self->view($model->table, $model->view) if $model->view; |
|
916 |
|
|
add experimental DBIx::Custo...
|
917 |
# Apply filter |
all filter can receive array...
|
918 |
croak "${name_space}::$model_class filter must be array reference" |
919 |
unless ref $model->filter eq 'ARRAY'; |
|
920 |
$self->apply_filter($model->table, @{$model->filter}); |
|
table object call dbi object...
|
921 |
} |
removed experimental base_ta...
|
922 |
return $self; |
remove DBIx::Custom::Model
|
923 |
} |
924 | ||
add experimental setup_model...
|
925 |
sub setup_model { |
926 |
my $self = shift; |
|
927 |
|
|
928 |
$self->each_column( |
|
929 |
sub { |
|
930 |
my ($self, $table, $column, $column_info) = @_; |
|
931 |
|
|
932 |
if (my $model = $self->models->{$table}) { |
|
933 |
push @{$model->columns}, $column; |
|
934 |
} |
|
935 |
} |
|
936 |
); |
|
add experimental DBIx::Custo...
|
937 |
return $self; |
add experimental setup_model...
|
938 |
} |
939 | ||
cleanup
|
940 |
our %VALID_UPDATE_ARGS |
update pod
|
941 |
= map { $_ => 1 } qw/table param where append filter |
942 |
allow_update_all query/; |
|
cleanup
|
943 | |
944 |
sub update { |
|
945 |
my ($self, %args) = @_; |
|
version 0.0901
|
946 |
|
cleanup
|
947 |
# Check argument names |
cleanup
|
948 |
foreach my $name (keys %args) { |
cleanup
|
949 |
croak qq{Argument "$name" is invalid name} |
cleanup
|
950 |
unless $VALID_UPDATE_ARGS{$name}; |
removed reconnect method
|
951 |
} |
added cache_method attribute
|
952 |
|
cleanup
|
953 |
# Arguments |
954 |
my $table = $args{table} || ''; |
|
added table not specified ex...
|
955 |
croak qq{"table" option must be specified} unless $table; |
cleanup
|
956 |
my $param = $args{param} || {}; |
957 |
my $where = $args{where} || {}; |
|
select() where can't receive...
|
958 |
my $append = $args{append} || ''; |
cleanup
|
959 |
my $filter = $args{filter}; |
960 |
my $allow_update_all = $args{allow_update_all}; |
|
version 0.0901
|
961 |
|
cleanup
|
962 |
# Update keys |
select() where can't receive...
|
963 |
my @clumns = keys %$param; |
964 | ||
965 |
# Columns |
|
966 |
my @columns; |
|
- remaned experimental safty...
|
967 |
my $safety = $self->safety_character; |
select() where can't receive...
|
968 |
foreach my $column (keys %$param) { |
969 |
croak qq{"$column" is not safety column name} |
|
- remaned experimental safty...
|
970 |
unless $column =~ /^[$safety\.]+$/; |
select() where can't receive...
|
971 |
push @columns, $column; |
972 |
} |
|
973 |
|
|
cleanup
|
974 |
# Update clause |
select() where can't receive...
|
975 |
my $update_clause = '{update_param ' . join(' ', @clumns) . '}'; |
improved delete() and update...
|
976 | |
977 |
# Where |
|
978 |
my $w; |
|
979 |
if (ref $where eq 'HASH') { |
|
980 |
my $clause = ['and']; |
|
981 |
push @$clause, "{= $_}" for keys %$where; |
|
982 |
$w = $self->where; |
|
983 |
$w->clause($clause); |
|
984 |
$w->param($where); |
|
985 |
} |
|
select() where can't receive...
|
986 |
elsif (ref $where eq 'DBIx::Custom::Where') { |
987 |
$w = $where; |
|
988 |
$where = $w->param; |
|
989 |
} |
|
removed experimental registe...
|
990 |
|
improved delete() and update...
|
991 |
croak qq{"where" must be hash refernce or DBIx::Custom::Where object} |
992 |
unless ref $w eq 'DBIx::Custom::Where'; |
|
removed reconnect method
|
993 |
|
select() where can't receive...
|
994 |
# String where |
995 |
my $swhere = "$w"; |
|
improved delete() and update...
|
996 |
|
997 |
croak qq{"where" must be specified} |
|
select() where can't receive...
|
998 |
if "$swhere" eq '' && !$allow_update_all; |
removed reconnect method
|
999 |
|
cleanup
|
1000 |
# SQL stack |
1001 |
my @sql; |
|
1002 |
|
|
1003 |
# Update |
|
1004 |
push @sql, "update $table $update_clause $swhere"; |
|
1005 |
push @sql, $append if $append; |
|
removed reconnect method
|
1006 |
|
cleanup
|
1007 |
# Rearrange parameters |
improved delete() and update...
|
1008 |
foreach my $wkey (keys %$where) { |
removed reconnect method
|
1009 |
|
cleanup
|
1010 |
if (exists $param->{$wkey}) { |
1011 |
$param->{$wkey} = [$param->{$wkey}] |
|
1012 |
unless ref $param->{$wkey} eq 'ARRAY'; |
|
1013 |
|
|
1014 |
push @{$param->{$wkey}}, $where->{$wkey}; |
|
1015 |
} |
|
1016 |
else { |
|
1017 |
$param->{$wkey} = $where->{$wkey}; |
|
1018 |
} |
|
removed reconnect method
|
1019 |
} |
cleanup
|
1020 |
|
cleanup
|
1021 |
# SQL |
1022 |
my $sql = join(' ', @sql); |
|
1023 |
|
|
added experimental sugar met...
|
1024 |
# Create query |
cleanup
|
1025 |
my $query = $self->create_query($sql); |
added experimental sugar met...
|
1026 |
return $query if $args{query}; |
1027 |
|
|
cleanup
|
1028 |
# Execute query |
added experimental sugar met...
|
1029 |
my $ret_val = $self->execute($query, param => $param, |
added auto_filter method
|
1030 |
filter => $filter, |
renamed auto_filter to apply...
|
1031 |
table => $table); |
cleanup
|
1032 |
|
1033 |
return $ret_val; |
|
removed reconnect method
|
1034 |
} |
1035 | ||
cleanup
|
1036 |
sub update_all { shift->update(allow_update_all => 1, @_) }; |
1037 | ||
add experimental update_at()...
|
1038 |
our %VALID_UPDATE_AT_ARGS |
update pod
|
1039 |
= map { $_ => 1 } qw/table param where append filter |
1040 |
query primary_key param/; |
|
add experimental update_at()...
|
1041 | |
1042 |
sub update_at { |
|
1043 |
my ($self, %args) = @_; |
|
1044 |
|
|
cleanup
|
1045 |
# Check argument names |
add experimental update_at()...
|
1046 |
foreach my $name (keys %args) { |
cleanup
|
1047 |
croak qq{Argument "$name" is invalid name} |
add experimental update_at()...
|
1048 |
unless $VALID_UPDATE_AT_ARGS{$name}; |
1049 |
} |
|
1050 |
|
|
1051 |
# Primary key |
|
1052 |
my $primary_keys = delete $args{primary_key}; |
|
1053 |
$primary_keys = [$primary_keys] unless ref $primary_keys; |
|
1054 |
|
|
1055 |
# Where clause |
|
1056 |
my $where = {}; |
|
1057 |
my $param = {}; |
|
1058 |
|
|
1059 |
if (exists $args{where}) { |
|
1060 |
my $where_columns = delete $args{where}; |
|
1061 |
$where_columns = [$where_columns] unless ref $where_columns; |
|
- added experimental DBIx::C...
|
1062 | |
1063 |
croak qq{"where" must be constant value or array reference} |
|
1064 |
unless !ref $where_columns || ref $where_columns eq 'ARRAY'; |
|
add experimental update_at()...
|
1065 |
|
1066 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
1067 |
$where->{$primary_keys->[$i]} = $where_columns->[$i]; |
|
1068 |
} |
|
1069 |
} |
|
- added experimental DBIx::C...
|
1070 |
|
1071 |
if (exists $args{param}) { |
|
add experimental update_at()...
|
1072 |
$param = delete $args{param}; |
1073 |
for(my $i = 0; $i < @$primary_keys; $i ++) { |
|
- added experimental DBIx::C...
|
1074 |
delete $param->{$primary_keys->[$i]}; |
add experimental update_at()...
|
1075 |
} |
1076 |
} |
|
1077 |
|
|
1078 |
return $self->update(where => $where, param => $param, %args); |
|
1079 |
} |
|
1080 | ||
remove experimental DBIx::Cu...
|
1081 |
sub update_param { |
1082 |
my ($self, $param) = @_; |
|
1083 |
|
|
added experimental update_pa...
|
1084 |
# Update parameter tag |
remove experimental DBIx::Cu...
|
1085 |
my @tag; |
1086 |
push @tag, '{update_param'; |
|
- remaned experimental safty...
|
1087 |
my $safety = $self->safety_character; |
remove experimental DBIx::Cu...
|
1088 |
foreach my $column (keys %$param) { |
added experimental update_pa...
|
1089 |
croak qq{"$column" is not safety column name} |
- remaned experimental safty...
|
1090 |
unless $column =~ /^[$safety\.]+$/; |
remove experimental DBIx::Cu...
|
1091 |
push @tag, $column; |
1092 |
} |
|
1093 |
push @tag, '}'; |
|
1094 |
|
|
1095 |
return join ' ', @tag; |
|
1096 |
} |
|
1097 | ||
- added EXPERIMENTAL DBIx::C...
|
1098 |
sub view { |
1099 |
my $self = shift; |
|
1100 |
my $name = shift; |
|
1101 |
|
|
1102 |
# View |
|
1103 |
$self->{view} ||= {}; |
|
1104 |
if (@_) { |
|
1105 |
$self->{view}->{$name} = $_[0]; |
|
1106 |
return $self; |
|
1107 |
} |
|
1108 |
else { |
|
1109 |
return $name && $self->{view}->{$name} |
|
1110 |
? "(" . $self->{view}->{$name} . ") as $name" |
|
1111 |
: undef; |
|
1112 |
} |
|
1113 |
} |
|
1114 | ||
cleanup
|
1115 |
sub where { |
select() where can't receive...
|
1116 |
my $self = shift; |
1117 | ||
1118 |
return DBIx::Custom::Where->new( |
|
1119 |
query_builder => $self->query_builder, |
|
- remaned experimental safty...
|
1120 |
safety_character => $self->safety_character, |
cleanup
|
1121 |
@_ |
select() where can't receive...
|
1122 |
); |
cleanup
|
1123 |
} |
added experimental DBIx::Cus...
|
1124 | |
added experimental not_exist...
|
1125 |
sub _bind { |
cleanup
|
1126 |
my ($self, $params, $columns, $filter) = @_; |
removed reconnect method
|
1127 |
|
cleanup
|
1128 |
# bind values |
added experimental not_exist...
|
1129 |
my @bind; |
add tests
|
1130 |
|
removed reconnect method
|
1131 |
# Build bind values |
1132 |
my $count = {}; |
|
added experimental not_exist...
|
1133 |
my $not_exists = {}; |
cleanup
|
1134 |
foreach my $column (@$columns) { |
removed reconnect method
|
1135 |
|
1136 |
# Value |
|
added experimental not_exist...
|
1137 |
my $value; |
1138 |
if(ref $params->{$column} eq 'ARRAY') { |
|
1139 |
my $i = $count->{$column} || 0; |
|
1140 |
$i += $not_exists->{$column} || 0; |
|
1141 |
my $found; |
|
1142 |
for (my $k = $i; $i < @{$params->{$column}}; $k++) { |
|
1143 |
if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') { |
|
1144 |
$not_exists->{$column}++; |
|
1145 |
} |
|
1146 |
else { |
|
1147 |
$value = $params->{$column}->[$k]; |
|
1148 |
$found = 1; |
|
1149 |
last |
|
1150 |
} |
|
1151 |
} |
|
1152 |
next unless $found; |
|
1153 |
} |
|
1154 |
else { $value = $params->{$column} } |
|
removed reconnect method
|
1155 |
|
cleanup
|
1156 |
# Filter |
1157 |
my $f = $filter->{$column} || $self->{default_out_filter} || ''; |
|
cleanup
|
1158 |
|
added experimental not_exist...
|
1159 |
push @bind, $f ? $f->($value) : $value; |
removed reconnect method
|
1160 |
|
1161 |
# Count up |
|
1162 |
$count->{$column}++; |
|
1163 |
} |
|
1164 |
|
|
added experimental not_exist...
|
1165 |
return \@bind; |
removed reconnect method
|
1166 |
} |
1167 | ||
EXPERIMETAL fork safety impl...
|
1168 |
sub _connect { |
1169 |
my $self = shift; |
|
1170 |
|
|
1171 |
# Attributes |
|
1172 |
my $data_source = $self->data_source; |
|
1173 |
croak qq{"data_source" must be specified to connect()"} |
|
1174 |
unless $data_source; |
|
1175 |
my $user = $self->user; |
|
1176 |
my $password = $self->password; |
|
1177 |
my $dbi_option = {%{$self->dbi_options}, %{$self->dbi_option}}; |
|
1178 |
|
|
1179 |
# Connect |
|
1180 |
my $dbh = eval {DBI->connect( |
|
1181 |
$data_source, |
|
1182 |
$user, |
|
1183 |
$password, |
|
1184 |
{ |
|
1185 |
%{$self->default_dbi_option}, |
|
1186 |
%$dbi_option |
|
1187 |
} |
|
1188 |
)}; |
|
1189 |
|
|
1190 |
# Connect error |
|
1191 |
croak $@ if $@; |
|
1192 |
|
|
1193 |
return $dbh; |
|
1194 |
} |
|
1195 | ||
cleanup
|
1196 |
sub _croak { |
1197 |
my ($self, $error, $append) = @_; |
|
1198 |
$append ||= ""; |
|
1199 |
|
|
1200 |
# Verbose |
|
1201 |
if ($Carp::Verbose) { croak $error } |
|
1202 |
|
|
1203 |
# Not verbose |
|
1204 |
else { |
|
1205 |
|
|
1206 |
# Remove line and module infromation |
|
1207 |
my $at_pos = rindex($error, ' at '); |
|
1208 |
$error = substr($error, 0, $at_pos); |
|
1209 |
$error =~ s/\s+$//; |
|
1210 |
|
|
1211 |
croak "$error$append"; |
|
1212 |
} |
|
1213 |
} |
|
1214 | ||
added select() all_column op...
|
1215 |
sub _need_tables { |
1216 |
my ($self, $tree, $need_tables, $tables) = @_; |
|
1217 |
|
|
1218 |
foreach my $table (@$tables) { |
|
1219 |
|
|
1220 |
if ($tree->{$table}) { |
|
1221 |
$need_tables->{$table} = 1; |
|
1222 |
$self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}]) |
|
1223 |
} |
|
1224 |
} |
|
1225 |
} |
|
1226 | ||
remove experimental DBIx::Cu...
|
1227 |
sub _tables { |
1228 |
my ($self, $source) = @_; |
|
1229 |
|
|
1230 |
my $tables = []; |
|
1231 |
|
|
- remaned experimental safty...
|
1232 |
my $safety_character = $self->safety_character; |
remove experimental DBIx::Cu...
|
1233 |
|
- remaned experimental safty...
|
1234 |
while ($source =~ /\b($safety_character+)\./g) { |
remove experimental DBIx::Cu...
|
1235 |
push @$tables, $1; |
1236 |
} |
|
1237 |
|
|
1238 |
return $tables; |
|
1239 |
} |
|
1240 | ||
fixed some select() join opi...
|
1241 |
sub _push_join { |
1242 |
my ($self, $sql, $join, $join_tables) = @_; |
|
1243 |
|
|
1244 |
return unless @$join; |
|
1245 |
|
|
1246 |
my $tree = {}; |
|
1247 |
|
|
1248 |
for (my $i = 0; $i < @$join; $i++) { |
|
1249 |
|
|
1250 |
my $join_clause = $join->[$i]; |
|
1251 |
|
|
- added experimental DBIx::C...
|
1252 |
if ($join_clause =~ /\s([^\.\s]+?)\..+\s([^\.\s]+?)\..+?$/) { |
fixed some select() join opi...
|
1253 |
|
1254 |
my $table1 = $1; |
|
1255 |
my $table2 = $2; |
|
1256 |
|
|
1257 |
croak qq{right side table of "$join_clause" must be uniq} |
|
1258 |
if exists $tree->{$table2}; |
|
1259 |
|
|
1260 |
$tree->{$table2} |
|
1261 |
= {position => $i, parent => $table1, join => $join_clause}; |
|
1262 |
} |
|
1263 |
else { |
|
1264 |
croak qq{join "$join_clause" must be two table name}; |
|
1265 |
} |
|
1266 |
} |
|
1267 |
|
|
1268 |
my $need_tables = {}; |
|
1269 |
$self->_need_tables($tree, $need_tables, $join_tables); |
|
1270 |
|
|
1271 |
my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} } keys %$need_tables; |
|
cleanup
|
1272 | |
fixed some select() join opi...
|
1273 |
foreach my $need_table (@need_tables) { |
1274 |
push @$sql, $tree->{$need_table}{join}; |
|
1275 |
} |
|
1276 |
} |
|
cleanup
|
1277 | |
cleanup
|
1278 |
# DEPRECATED! |
cleanup
|
1279 |
__PACKAGE__->attr( |
1280 |
dbi_options => sub { {} }, |
|
1281 |
filter_check => 1 |
|
1282 |
); |
|
renamed dbi_options to dbi_o...
|
1283 | |
cleanup
|
1284 |
# DEPRECATED! |
cleanup
|
1285 |
sub default_bind_filter { |
1286 |
my $self = shift; |
|
1287 |
|
|
1288 |
if (@_) { |
|
1289 |
my $fname = $_[0]; |
|
1290 |
|
|
1291 |
if (@_ && !$fname) { |
|
1292 |
$self->{default_out_filter} = undef; |
|
1293 |
} |
|
1294 |
else { |
|
many changed
|
1295 |
croak qq{Filter "$fname" is not registered} |
cleanup
|
1296 |
unless exists $self->filters->{$fname}; |
1297 |
|
|
1298 |
$self->{default_out_filter} = $self->filters->{$fname}; |
|
1299 |
} |
|
1300 |
return $self; |
|
1301 |
} |
|
1302 |
|
|
1303 |
return $self->{default_out_filter}; |
|
1304 |
} |
|
1305 | ||
cleanup
|
1306 |
# DEPRECATED! |
cleanup
|
1307 |
sub default_fetch_filter { |
1308 |
my $self = shift; |
|
1309 |
|
|
1310 |
if (@_) { |
|
many changed
|
1311 |
my $fname = $_[0]; |
1312 | ||
cleanup
|
1313 |
if (@_ && !$fname) { |
1314 |
$self->{default_in_filter} = undef; |
|
1315 |
} |
|
1316 |
else { |
|
many changed
|
1317 |
croak qq{Filter "$fname" is not registered} |
cleanup
|
1318 |
unless exists $self->filters->{$fname}; |
1319 |
|
|
1320 |
$self->{default_in_filter} = $self->filters->{$fname}; |
|
1321 |
} |
|
1322 |
|
|
1323 |
return $self; |
|
1324 |
} |
|
1325 |
|
|
many changed
|
1326 |
return $self->{default_in_filter}; |
cleanup
|
1327 |
} |
1328 | ||
cleanup
|
1329 |
# DEPRECATED! |
renamed DBIx::Custom::TagPro...
|
1330 |
sub register_tag_processor { |
1331 |
return shift->query_builder->register_tag_processor(@_); |
|
1332 |
} |
|
1333 | ||
cleanup
|
1334 |
# DEPRECATED! |
1335 |
sub _push_relation { |
|
1336 |
my ($self, $sql, $tables, $relation, $need_where) = @_; |
|
1337 |
|
|
1338 |
if (keys %{$relation || {}}) { |
|
1339 |
push @$sql, $need_where ? 'where' : 'and'; |
|
1340 |
foreach my $rcolumn (keys %$relation) { |
|
1341 |
my $table1 = (split (/\./, $rcolumn))[0]; |
|
1342 |
my $table2 = (split (/\./, $relation->{$rcolumn}))[0]; |
|
1343 |
push @$tables, ($table1, $table2); |
|
1344 |
push @$sql, ("$rcolumn = " . $relation->{$rcolumn}, 'and'); |
|
1345 |
} |
|
1346 |
} |
|
1347 |
pop @$sql if $sql->[-1] eq 'and'; |
|
1348 |
} |
|
1349 | ||
1350 |
# DEPRECATED! |
|
1351 |
sub _add_relation_table { |
|
cleanup
|
1352 |
my ($self, $tables, $relation) = @_; |
cleanup
|
1353 |
|
1354 |
if (keys %{$relation || {}}) { |
|
1355 |
foreach my $rcolumn (keys %$relation) { |
|
1356 |
my $table1 = (split (/\./, $rcolumn))[0]; |
|
1357 |
my $table2 = (split (/\./, $relation->{$rcolumn}))[0]; |
|
1358 |
my $table1_exists; |
|
1359 |
my $table2_exists; |
|
1360 |
foreach my $table (@$tables) { |
|
1361 |
$table1_exists = 1 if $table eq $table1; |
|
1362 |
$table2_exists = 1 if $table eq $table2; |
|
1363 |
} |
|
1364 |
unshift @$tables, $table1 unless $table1_exists; |
|
1365 |
unshift @$tables, $table2 unless $table2_exists; |
|
1366 |
} |
|
1367 |
} |
|
1368 |
} |
|
1369 | ||
fixed DBIx::Custom::QueryBui...
|
1370 |
1; |
1371 | ||
removed reconnect method
|
1372 |
=head1 NAME |
1373 | ||
- remaned experimental safty...
|
1374 |
DBIx::Custom - Useful database access, respecting SQL! |
removed reconnect method
|
1375 | |
1376 |
=head1 SYNOPSYS |
|
cleanup
|
1377 | |
renamed build_query to creat...
|
1378 |
use DBIx::Custom; |
- remaned experimental safty...
|
1379 |
|
1380 |
# Connect |
|
1381 |
my $dbi = DBIx::Custom->connect( |
|
1382 |
data_source => "dbi:mysql:database=dbname", |
|
1383 |
user => 'ken', |
|
1384 |
password => '!LFKD%$&', |
|
1385 |
dbi_option => {mysql_enable_utf8 => 1} |
|
1386 |
); |
|
cleanup
|
1387 | |
removed reconnect method
|
1388 |
# Insert |
- remaned experimental safty...
|
1389 |
$dbi->insert( |
1390 |
table => 'book', |
|
1391 |
param => {title => 'Perl', author => 'Ken'} |
|
1392 |
); |
|
removed reconnect method
|
1393 |
|
1394 |
# Update |
|
- remaned experimental safty...
|
1395 |
$dbi->update( |
1396 |
table => 'book', |
|
1397 |
param => {title => 'Perl', author => 'Ken'}, |
|
1398 |
where => {id => 5}, |
|
1399 |
); |
|
removed reconnect method
|
1400 |
|
1401 |
# Delete |
|
- remaned experimental safty...
|
1402 |
$dbi->delete( |
1403 |
table => 'book', |
|
1404 |
where => {author => 'Ken'}, |
|
1405 |
); |
|
cleanup
|
1406 | |
removed reconnect method
|
1407 |
# Select |
renamed fetch_rows to fetch_...
|
1408 |
my $result = $dbi->select( |
added insert, update, update...
|
1409 |
table => 'book', |
update document
|
1410 |
where => {author => 'Ken'}, |
added commit method
|
1411 |
); |
cleanup
|
1412 | |
- remaned experimental safty...
|
1413 |
# Select, more complex |
1414 |
my $result = $dbi->select( |
|
1415 |
table => 'book', |
|
1416 |
column => [ |
|
1417 |
'book.author as book__author', |
|
1418 |
'company.name as company__name' |
|
1419 |
], |
|
1420 |
where => {'book.author' => 'Ken'}, |
|
1421 |
join => ['left outer join company on book.company_id = company.id'], |
|
1422 |
append => 'order by id limit 5' |
|
removed reconnect method
|
1423 |
); |
- remaned experimental safty...
|
1424 |
|
removed register_format()
|
1425 |
# Fetch |
1426 |
while (my $row = $result->fetch) { |
|
- remaned experimental safty...
|
1427 |
|
removed register_format()
|
1428 |
} |
1429 |
|
|
- remaned experimental safty...
|
1430 |
# Fetch as hash |
removed register_format()
|
1431 |
while (my $row = $result->fetch_hash) { |
1432 |
|
|
1433 |
} |
|
1434 |
|
|
- remaned experimental safty...
|
1435 |
# Execute SQL with parameter. |
1436 |
$dbi->execute( |
|
1437 |
"select id from book where {= author} and {like title}", |
|
1438 |
param => {author => 'ken', title => '%Perl%'} |
|
1439 |
); |
|
1440 |
|
|
renamed update tag to update...
|
1441 |
=head1 DESCRIPTIONS |
removed reconnect method
|
1442 | |
- remaned experimental safty...
|
1443 |
L<DBIx::Custom> is L<DBI> wrapper module. |
1444 | ||
1445 |
=head1 FEATURES |
|
removed reconnect method
|
1446 | |
- remaned experimental safty...
|
1447 |
=over 4 |
removed reconnect method
|
1448 | |
- remaned experimental safty...
|
1449 |
=item * |
removed reconnect method
|
1450 | |
- remaned experimental safty...
|
1451 |
There are many basic methods to execute various queries. |
1452 |
C<insert()>, C<update()>, C<update_all()>,C<delete()>, |
|
1453 |
C<delete_all()>, C<select()>, |
|
1454 |
C<insert_at()>, C<update_at()>, |
|
1455 |
C<delete_at()>, C<select_at()>, C<execute()> |
|
removed reconnect method
|
1456 | |
- remaned experimental safty...
|
1457 |
=item * |
1458 | ||
1459 |
Filter when data is send or receive. |
|
1460 | ||
1461 |
=item * |
|
1462 | ||
1463 |
Data filtering system |
|
1464 | ||
1465 |
=item * |
|
1466 | ||
1467 |
Model support. |
|
1468 | ||
1469 |
=item * |
|
1470 | ||
1471 |
Generate where clause dinamically. |
|
1472 | ||
1473 |
=item * |
|
1474 | ||
1475 |
Generate join clause dinamically. |
|
1476 | ||
1477 |
=back |
|
pod fix
|
1478 | |
1479 |
=head1 GUIDE |
|
1480 | ||
- remaned experimental safty...
|
1481 |
L<DBIx::Custom::Guide> - L<DBIx::Custom> Guide |
pod fix
|
1482 | |
- remaned experimental safty...
|
1483 |
=head1 Wiki |
pod fix
|
1484 | |
- remaned experimental safty...
|
1485 |
L<DBIx::Custom Wiki|https://github.com/yuki-kimoto/DBIx-Custom/wiki> |
updated document
|
1486 | |
update document
|
1487 |
=head1 ATTRIBUTES |
packaging one directory
|
1488 | |
cleanup
|
1489 |
=head2 C<cache> |
packaging one directory
|
1490 | |
cleanup
|
1491 |
my $cache = $dbi->cache; |
1492 |
$dbi = $dbi->cache(1); |
|
removed DESTROY method(not b...
|
1493 | |
update pod
|
1494 |
Enable caching L<DBIx::Custom::Query>, |
- remaned experimental safty...
|
1495 |
default to 1. |
packaging one directory
|
1496 | |
removed DBIx::Custom commit ...
|
1497 |
=head2 C<data_source> |
packaging one directory
|
1498 | |
cleanup
|
1499 |
my $data_source = $dbi->data_source; |
cleanup
|
1500 |
$dbi = $dbi->data_source("DBI:mysql:database=dbname"); |
removed DESTROY method(not b...
|
1501 | |
- remaned experimental safty...
|
1502 |
Data source, used when C<connect()> is executed. |
removed DESTROY method(not b...
|
1503 | |
renamed dbi_options to dbi_o...
|
1504 |
=head2 C<dbi_option> |
added dbi_options attribute
|
1505 | |
renamed dbi_options to dbi_o...
|
1506 |
my $dbi_option = $dbi->dbi_option; |
- remaned experimental safty...
|
1507 |
$dbi = $dbi->dbi_option($dbi_option); |
add default_dbi_option()
|
1508 | |
- remaned experimental safty...
|
1509 |
L<DBI> option, used when C<connect()> is executed. |
1510 |
Each value in option override the value of C<default_dbi_option>. |
|
add default_dbi_option()
|
1511 | |
1512 |
=head2 C<default_dbi_option> |
|
1513 | ||
1514 |
my $default_dbi_option = $dbi->default_dbi_option; |
|
1515 |
$dbi = $dbi->default_dbi_option($default_dbi_option); |
|
1516 | ||
- remaned experimental safty...
|
1517 |
L<DBI> default option, used when C<connect()> is executed, |
1518 |
default to the following values. |
|
add default_dbi_option()
|
1519 | |
- remaned experimental safty...
|
1520 |
{ |
1521 |
RaiseError => 1, |
|
1522 |
PrintError => 0, |
|
1523 |
AutoCommit => 1, |
|
1524 |
} |
|
packaging one directory
|
1525 | |
update pod
|
1526 |
You should not change C<AutoCommit> value directly, |
1527 |
the value is used to check if the process is in transaction. |
|
EXPERIMETAL fork safety impl...
|
1528 | |
cleanup
|
1529 |
=head2 C<filters> |
bind_filter argument is chan...
|
1530 | |
cleanup
|
1531 |
my $filters = $dbi->filters; |
1532 |
$dbi = $dbi->filters(\%filters); |
|
packaging one directory
|
1533 | |
- remaned experimental safty...
|
1534 |
Filters, registered by C<register_filter()>. |
add models() attribute
|
1535 | |
update pod
|
1536 |
=head2 C<models> EXPERIMENTAL |
add models() attribute
|
1537 | |
1538 |
my $models = $dbi->models; |
|
1539 |
$dbi = $dbi->models(\%models); |
|
1540 | ||
- remaned experimental safty...
|
1541 |
Models, included by C<include_model()>. |
add models() attribute
|
1542 | |
cleanup
|
1543 |
=head2 C<password> |
1544 | ||
1545 |
my $password = $dbi->password; |
|
1546 |
$dbi = $dbi->password('lkj&le`@s'); |
|
1547 | ||
- remaned experimental safty...
|
1548 |
Password, used when C<connect()> is executed. |
update document
|
1549 | |
renamed update tag to update...
|
1550 |
=head2 C<query_builder> |
added commit method
|
1551 | |
renamed update tag to update...
|
1552 |
my $sql_class = $dbi->query_builder; |
1553 |
$dbi = $dbi->query_builder(DBIx::Custom::QueryBuilder->new); |
|
added commit method
|
1554 | |
- remaned experimental safty...
|
1555 |
Query builder, default to L<DBIx::Custom::QueryBuilder> object. |
cleanup
|
1556 | |
cleanup
|
1557 |
=head2 C<result_class> |
cleanup
|
1558 | |
cleanup
|
1559 |
my $result_class = $dbi->result_class; |
1560 |
$dbi = $dbi->result_class('DBIx::Custom::Result'); |
|
cleanup
|
1561 | |
- remaned experimental safty...
|
1562 |
Result class, default to L<DBIx::Custom::Result>. |
cleanup
|
1563 | |
update pod
|
1564 |
=head2 C<safety_character> EXPERIMENTAL |
update pod
|
1565 | |
- remaned experimental safty...
|
1566 |
my $safety_character = $self->safety_character; |
cleanup
|
1567 |
$dbi = $self->safety_character($character); |
update pod
|
1568 | |
update pod
|
1569 |
Regex of safety character for table and column name, default to '\w'. |
cleanup
|
1570 |
Note that you don't have to specify like '[\w]'. |
update pod
|
1571 | |
cleanup
|
1572 |
=head2 C<user> |
cleanup
|
1573 | |
cleanup
|
1574 |
my $user = $dbi->user; |
1575 |
$dbi = $dbi->user('Ken'); |
|
cleanup
|
1576 | |
cleanup
|
1577 |
User name, used when C<connect()> is executed. |
update pod
|
1578 | |
cleanup
|
1579 |
=head1 METHODS |
added commit method
|
1580 | |
cleanup
|
1581 |
L<DBIx::Custom> inherits all methods from L<Object::Simple> |
cleanup
|
1582 |
and use all methods of L<DBI> |
cleanup
|
1583 |
and implements the following new ones. |
added check_filter attribute
|
1584 | |
update pod
|
1585 |
=head2 C<apply_filter> EXPERIMENTAL |
added auto_filter method
|
1586 | |
renamed auto_filter to apply...
|
1587 |
$dbi->apply_filter( |
cleanup
|
1588 |
'book', |
update pod
|
1589 |
'issue_date' => { |
1590 |
out => 'tp_to_date', |
|
1591 |
in => 'date_to_tp', |
|
1592 |
end => 'tp_to_displaydate' |
|
1593 |
}, |
|
1594 |
'write_date' => { |
|
1595 |
out => 'tp_to_date', |
|
1596 |
in => 'date_to_tp', |
|
1597 |
end => 'tp_to_displaydate' |
|
1598 |
} |
|
added auto_filter method
|
1599 |
); |
1600 | ||
update pod
|
1601 |
Apply filter to columns. |
1602 |
C<out> filter is executed before data is send to database. |
|
1603 |
C<in> filter is executed after a row is fetch. |
|
1604 |
C<end> filter is execute after C<in> filter is executed. |
|
1605 | ||
1606 |
Filter is applied to the follwoing tree column name pattern. |
|
cleanup
|
1607 | |
update pod
|
1608 |
PETTERN EXAMPLE |
1609 |
1. Column : author |
|
1610 |
2. Table.Column : book.author |
|
1611 |
3. Table__Column : book__author |
|
fix bug : filter can't over...
|
1612 | |
update pod
|
1613 |
If column name is duplicate with other table, |
1614 |
Main filter specified by C<table> option is used. |
|
1615 | ||
1616 |
You can set multiple filters at once. |
|
1617 | ||
1618 |
$dbi->apply_filter( |
|
1619 |
'book', |
|
1620 |
[qw/issue_date write_date/] => { |
|
1621 |
out => 'tp_to_date', |
|
1622 |
in => 'date_to_tp', |
|
1623 |
end => 'tp_to_displaydate' |
|
1624 |
} |
|
1625 |
); |
|
fix bug : filter can't over...
|
1626 | |
update pod
|
1627 |
=head2 C<cache_method> |
1628 | ||
1629 |
$dbi = $dbi->cache_method(\&cache_method); |
|
1630 |
$cache_method = $dbi->cache_method |
|
1631 | ||
update pod
|
1632 |
Method to set and get cache. |
1633 |
Default to the following one. |
|
1634 | ||
1635 |
sub { |
|
1636 |
my $self = shift; |
|
1637 |
|
|
1638 |
$self->{_cached} ||= {}; |
|
1639 |
|
|
1640 |
if (@_ > 1) { |
|
1641 |
$self->{_cached}{$_[0]} = $_[1]; |
|
1642 |
} |
|
1643 |
else { |
|
1644 |
return $self->{_cached}{$_[0]}; |
|
1645 |
} |
|
1646 |
} |
|
update pod
|
1647 | |
removed DBIx::Custom commit ...
|
1648 |
=head2 C<connect> |
packaging one directory
|
1649 | |
update pod
|
1650 |
my $dbi = DBIx::Custom->connect( |
1651 |
data_source => "dbi:mysql:database=dbname", |
|
1652 |
user => 'ken', |
|
1653 |
password => '!LFKD%$&', |
|
1654 |
dbi_option => {mysql_enable_utf8 => 1} |
|
1655 |
); |
|
1656 | ||
1657 |
Connect to the database and create a new L<DBIx::Custom> object. |
|
bind_filter argument is chan...
|
1658 | |
renamed build_query to creat...
|
1659 |
L<DBIx::Custom> is a wrapper of L<DBI>. |
cleanup
|
1660 |
C<AutoCommit> and C<RaiseError> options are true, |
update pod
|
1661 |
and C<PrintError> option is false by default. |
packaging one directory
|
1662 | |
cleanup
|
1663 |
=head2 C<create_query> |
1664 |
|
|
1665 |
my $query = $dbi->create_query( |
|
update pod
|
1666 |
"insert into book {insert_param title author};"; |
cleanup
|
1667 |
); |
update document
|
1668 | |
update pod
|
1669 |
Create L<DBIx::Custom::Query> object. |
1670 | ||
cleanup
|
1671 |
If you want to get high performance, |
update pod
|
1672 |
create L<DBIx::Custom::Query> object and execute the query by C<execute()> |
1673 |
instead of other methods, such as C<insert>, C<update>. |
|
bind_filter argument is chan...
|
1674 | |
cleanup
|
1675 |
$dbi->execute($query, {author => 'Ken', title => '%Perl%'}); |
version 0.0901
|
1676 | |
EXPERIMETAL fork safety impl...
|
1677 |
=head2 C<dbh> |
1678 | ||
1679 |
my $dbh = $dbi->dbh; |
|
1680 |
$dbi = $dbi->dbh($dbh); |
|
1681 | ||
1682 |
Get and set database handle of L<DBI>. |
|
1683 | ||
update pod
|
1684 |
If process is spawn by forking, new connection is created automatically. |
1685 |
This feature is EXPERIMETNAL. |
|
EXPERIMETAL fork safety impl...
|
1686 | |
cleanup
|
1687 |
=head2 C<execute> |
packaging one directory
|
1688 | |
update pod
|
1689 |
my $result = $dbi->execute( |
1690 |
"select * from book where {= title} and {like author}", |
|
1691 |
param => {title => 'Perl', author => '%Ken%'} |
|
1692 |
); |
|
1693 | ||
1694 |
Execute SQL, containing tags. |
|
1695 |
Return value is L<DBIx::Custom::Result> in select statement, or |
|
1696 |
the count of affected rows in insert, update, delete statement. |
|
1697 | ||
1698 |
Tag is turned into the statement containing place holder |
|
1699 |
before SQL is executed. |
|
1700 | ||
1701 |
select * from where title = ? and author like ?; |
|
1702 | ||
1703 |
See also L<Tags/Tags>. |
|
1704 | ||
1705 |
The following opitons are currently available. |
|
1706 | ||
1707 |
=over 4 |
|
1708 | ||
1709 |
=item C<filter> |
|
1710 | ||
1711 |
Filter, executed before data is send to database. This is array reference. |
|
1712 |
Filter value is code reference or |
|
1713 |
filter name registerd by C<register_filter()>. |
|
1714 | ||
1715 |
# Basic |
|
1716 |
$dbi->execute( |
|
1717 |
$sql, |
|
1718 |
filter => [ |
|
1719 |
title => sub { uc $_[0] } |
|
1720 |
author => sub { uc $_[0] } |
|
1721 |
] |
|
1722 |
); |
|
1723 |
|
|
1724 |
# At once |
|
1725 |
$dbi->execute( |
|
1726 |
$sql, |
|
1727 |
filter => [ |
|
1728 |
[qw/title author/] => sub { uc $_[0] } |
|
1729 |
] |
|
1730 |
); |
|
1731 |
|
|
1732 |
# Filter name |
|
1733 |
$dbi->execute( |
|
1734 |
$sql, |
|
1735 |
filter => [ |
|
1736 |
title => 'upper_case', |
|
1737 |
author => 'upper_case' |
|
1738 |
] |
|
1739 |
); |
|
1740 | ||
1741 |
These filters are added to the C<out> filters, set by C<apply_filter()>. |
|
update document
|
1742 | |
update pod
|
1743 |
=back |
version 0.0901
|
1744 | |
removed DBIx::Custom commit ...
|
1745 |
=head2 C<delete> |
packaging one directory
|
1746 | |
update pod
|
1747 |
$dbi->delete(table => 'book', where => {title => 'Perl'}); |
1748 | ||
1749 |
Delete statement. |
|
1750 | ||
1751 |
The following opitons are currently available. |
|
1752 | ||
update pod
|
1753 |
=over 4 |
1754 | ||
update pod
|
1755 |
=item C<table> |
1756 | ||
1757 |
Table name. |
|
1758 | ||
1759 |
$dbi->delete(table => 'book'); |
|
1760 | ||
1761 |
=item C<where> |
|
1762 | ||
1763 |
Where clause. This is hash reference or L<DBIx::Custom::Where> object. |
|
1764 |
|
|
1765 |
# Hash reference |
|
1766 |
$dbi->delete(where => {title => 'Perl'}); |
|
1767 |
|
|
1768 |
# DBIx::Custom::Where object |
|
1769 |
my $where = $dbi->where( |
|
1770 |
clause => ['and', '{= author}', '{like title}'], |
|
1771 |
param => {author => 'Ken', title => '%Perl%'} |
|
1772 |
); |
|
1773 |
$dbi->delete(where => $where); |
|
1774 | ||
1775 |
=item C<append> |
|
1776 | ||
1777 |
Append statement to last of SQL. This is string. |
|
1778 | ||
1779 |
$dbi->delete(append => 'order by title'); |
|
1780 | ||
1781 |
=item C<filter> |
|
1782 | ||
1783 |
Filter, executed before data is send to database. This is array reference. |
|
1784 |
Filter value is code reference or |
|
1785 |
filter name registerd by C<register_filter()>. |
|
1786 | ||
1787 |
# Basic |
|
1788 |
$dbi->delete( |
|
1789 |
filter => [ |
|
1790 |
title => sub { uc $_[0] } |
|
1791 |
author => sub { uc $_[0] } |
|
1792 |
] |
|
1793 |
); |
|
1794 |
|
|
1795 |
# At once |
|
1796 |
$dbi->delete( |
|
1797 |
filter => [ |
|
1798 |
[qw/title author/] => sub { uc $_[0] } |
|
1799 |
] |
|
1800 |
); |
|
1801 |
|
|
1802 |
# Filter name |
|
1803 |
$dbi->delete( |
|
1804 |
filter => [ |
|
1805 |
title => 'upper_case', |
|
1806 |
author => 'upper_case' |
|
1807 |
] |
|
1808 |
); |
|
1809 | ||
1810 |
These filters are added to the C<out> filters, set by C<apply_filter()>. |
|
1811 | ||
update pod
|
1812 |
=item C<query> EXPERIMENTAL |
update pod
|
1813 | |
1814 |
Get L<DBIx::Custom::Query> object instead of executing SQL. |
|
1815 |
This is true or false value. |
|
1816 | ||
1817 |
my $query = $dbi->delete(query => 1); |
|
1818 | ||
1819 |
You can check SQL. |
|
1820 | ||
1821 |
my $sql = $query->sql; |
|
renamed build_query to creat...
|
1822 | |
update pod
|
1823 |
=back |
1824 | ||
removed DBIx::Custom commit ...
|
1825 |
=head2 C<delete_all> |
packaging one directory
|
1826 | |
cleanup
|
1827 |
$dbi->delete_all(table => $table); |
packaging one directory
|
1828 | |
update pod
|
1829 |
Delete statement to delete all rows. |
1830 |
Options is same as C<delete()>. |
|
bind_filter argument is chan...
|
1831 | |
update pod
|
1832 |
=head2 C<delete_at()> EXPERIMENTAL |
add experimental update_at()...
|
1833 | |
update pod
|
1834 |
Delete statement, using primary key. |
add experimental update_at()...
|
1835 | |
1836 |
$dbi->delete_at( |
|
1837 |
table => 'book', |
|
update pod
|
1838 |
primary_key => 'id', |
1839 |
where => '5' |
|
add experimental update_at()...
|
1840 |
); |
1841 | ||
update pod
|
1842 |
This method is same as C<delete()> exept that |
1843 |
C<primary_key> is specified and C<where> is constant value or array refrence. |
|
1844 |
all option of C<delete()> is available. |
|
add experimental update_at()...
|
1845 | |
update pod
|
1846 |
=over 4 |
1847 | ||
1848 |
=item C<primary_key> |
|
add experimental update_at()...
|
1849 | |
update pod
|
1850 |
Primary key. This is constant value or array reference. |
1851 |
|
|
1852 |
# Constant value |
|
1853 |
$dbi->delete(primary_key => 'id'); |
|
1854 | ||
1855 |
# Array reference |
|
1856 |
$dbi->delete(primary_key => ['id1', 'id2' ]); |
|
1857 | ||
1858 |
This is used to create where clause. |
|
1859 | ||
update pod
|
1860 |
=item C<where> |
update pod
|
1861 | |
1862 |
Where clause, created from primary key information. |
|
1863 |
This is constant value or array reference. |
|
1864 | ||
1865 |
# Constant value |
|
1866 |
$dbi->delete(where => 5); |
|
1867 | ||
1868 |
# Array reference |
|
1869 |
$dbi->delete(where => [3, 5]); |
|
1870 | ||
1871 |
In first examle, the following SQL is created. |
|
1872 | ||
1873 |
delete from book where id = ?; |
|
1874 | ||
1875 |
Place holder is set to 5. |
|
add experimental update_at()...
|
1876 | |
update pod
|
1877 |
=back |
1878 | ||
cleanup
|
1879 |
=head2 C<insert> |
1880 | ||
update pod
|
1881 |
$dbi->insert( |
1882 |
table => 'book', |
|
1883 |
param => {title => 'Perl', author => 'Ken'} |
|
1884 |
); |
|
1885 | ||
1886 |
Insert statement. |
|
1887 | ||
1888 |
The following opitons are currently available. |
|
1889 | ||
update pod
|
1890 |
=over 4 |
1891 | ||
update pod
|
1892 |
=item C<table> |
1893 | ||
1894 |
Table name. |
|
1895 | ||
1896 |
$dbi->insert(table => 'book'); |
|
1897 | ||
1898 |
=item C<param> |
|
1899 | ||
1900 |
Insert data. This is hash reference. |
|
1901 | ||
1902 |
$dbi->insert(param => {title => 'Perl'}); |
|
1903 | ||
1904 |
=item C<append> |
|
1905 | ||
1906 |
Append statement to last of SQL. This is string. |
|
1907 | ||
1908 |
$dbi->insert(append => 'order by title'); |
|
1909 | ||
1910 |
=item C<filter> |
|
1911 | ||
1912 |
Filter, executed before data is send to database. This is array reference. |
|
1913 |
Filter value is code reference or |
|
1914 |
filter name registerd by C<register_filter()>. |
|
1915 | ||
1916 |
# Basic |
|
1917 |
$dbi->insert( |
|
1918 |
filter => [ |
|
1919 |
title => sub { uc $_[0] } |
|
1920 |
author => sub { uc $_[0] } |
|
1921 |
] |
|
1922 |
); |
|
1923 |
|
|
1924 |
# At once |
|
1925 |
$dbi->insert( |
|
1926 |
filter => [ |
|
1927 |
[qw/title author/] => sub { uc $_[0] } |
|
1928 |
] |
|
1929 |
); |
|
1930 |
|
|
1931 |
# Filter name |
|
1932 |
$dbi->insert( |
|
1933 |
filter => [ |
|
1934 |
title => 'upper_case', |
|
1935 |
author => 'upper_case' |
|
1936 |
] |
|
1937 |
); |
|
1938 | ||
1939 |
These filters are added to the C<out> filters, set by C<apply_filter()>. |
|
1940 | ||
update pod
|
1941 |
=item C<query> EXPERIMENTAL |
update pod
|
1942 | |
1943 |
Get L<DBIx::Custom::Query> object instead of executing SQL. |
|
1944 |
This is true or false value. |
|
1945 | ||
1946 |
my $query = $dbi->insert(query => 1); |
|
cleanup
|
1947 | |
update pod
|
1948 |
You can check SQL. |
cleanup
|
1949 | |
update pod
|
1950 |
my $sql = $query->sql; |
1951 | ||
update pod
|
1952 |
=back |
1953 | ||
1954 |
=head2 C<insert_at()> EXPERIMENTAL |
|
added experimental DBIx::Cus...
|
1955 | |
update pod
|
1956 |
Insert statement, using primary key. |
added experimental DBIx::Cus...
|
1957 | |
1958 |
$dbi->insert_at( |
|
1959 |
table => 'book', |
|
update pod
|
1960 |
primary_key => 'id', |
1961 |
where => '5', |
|
1962 |
param => {title => 'Perl'} |
|
added experimental DBIx::Cus...
|
1963 |
); |
1964 | ||
update pod
|
1965 |
This method is same as C<insert()> exept that |
1966 |
C<primary_key> is specified and C<where> is constant value or array refrence. |
|
1967 |
all option of C<insert()> is available. |
|
1968 | ||
update pod
|
1969 |
=over 4 |
1970 | ||
1971 |
=item C<primary_key> |
|
update pod
|
1972 | |
1973 |
Primary key. This is constant value or array reference. |
|
1974 |
|
|
1975 |
# Constant value |
|
1976 |
$dbi->insert(primary_key => 'id'); |
|
1977 | ||
1978 |
# Array reference |
|
1979 |
$dbi->insert(primary_key => ['id1', 'id2' ]); |
|
1980 | ||
1981 |
This is used to create parts of insert data. |
|
1982 | ||
update pod
|
1983 |
=item C<where> |
update pod
|
1984 | |
1985 |
Parts of Insert data, create from primary key information. |
|
1986 |
This is constant value or array reference. |
|
1987 | ||
1988 |
# Constant value |
|
1989 |
$dbi->insert(where => 5); |
|
1990 | ||
1991 |
# Array reference |
|
1992 |
$dbi->insert(where => [3, 5]); |
|
1993 | ||
1994 |
In first examle, the following SQL is created. |
|
1995 | ||
1996 |
insert into book (id, title) values (?, ?); |
|
1997 | ||
1998 |
Place holders are set to 5 and 'Perl'. |
|
added experimental DBIx::Cus...
|
1999 | |
update pod
|
2000 |
=back |
2001 | ||
2002 |
=head2 C<insert_param> EXPERIMENTAL |
|
added experimental update_pa...
|
2003 | |
2004 |
my $insert_param = $dbi->insert_param({title => 'a', age => 2}); |
|
2005 | ||
2006 |
Create insert parameter tag. |
|
2007 | ||
update pod
|
2008 |
{insert_param title age} |
added experimental update_pa...
|
2009 | |
update pod
|
2010 |
=head2 C<each_column> EXPERIMENTAL |
added experimental iterate_a...
|
2011 | |
pod fix
|
2012 |
$dbi->each_column( |
added experimental iterate_a...
|
2013 |
sub { |
update pod
|
2014 |
my ($dbi, $table, $column, $column_info) = @_; |
added experimental iterate_a...
|
2015 |
|
add experimental setup_model...
|
2016 |
my $type = $column_info->{TYPE_NAME}; |
pod fix
|
2017 |
|
2018 |
if ($type eq 'DATE') { |
|
2019 |
# ... |
|
2020 |
} |
|
added experimental iterate_a...
|
2021 |
} |
2022 |
); |
|
update pod
|
2023 | |
2024 |
Iterate all column informations of all table from database. |
|
2025 |
Argument is callback when one column is found. |
|
added experimental not_exist...
|
2026 |
Callback receive four arguments, dbi object, table name, |
add experimental setup_model...
|
2027 |
column name and column information. |
added experimental not_exist...
|
2028 | |
update pod
|
2029 |
=head2 C<include_model> EXPERIMENTAL |
removed experimental base_ta...
|
2030 | |
update pod
|
2031 |
$dbi->include_model('MyModel'); |
removed experimental base_ta...
|
2032 | |
update pod
|
2033 |
Include models from specified namespace, |
2034 |
the following layout is needed to include models. |
|
removed experimental base_ta...
|
2035 | |
update pod
|
2036 |
lib / MyModel.pm |
2037 |
/ MyModel / book.pm |
|
2038 |
/ company.pm |
|
add feture. all model class ...
|
2039 | |
update pod
|
2040 |
Name space module, extending L<DBIx::Custom::Model>. |
add feture. all model class ...
|
2041 | |
update pod
|
2042 |
B<MyModel.pm> |
add feture. all model class ...
|
2043 | |
2044 |
package MyModel; |
|
2045 |
|
|
2046 |
use base 'DBIx::Custom::Model'; |
|
update pod
|
2047 |
|
2048 |
1; |
|
add feture. all model class ...
|
2049 | |
update pod
|
2050 |
Model modules, extending name space module. |
removed experimental base_ta...
|
2051 | |
update pod
|
2052 |
B<MyModel/book.pm> |
removed experimental base_ta...
|
2053 | |
update pod
|
2054 |
package MyModel::book; |
2055 |
|
|
2056 |
use base 'MyModel'; |
|
2057 |
|
|
2058 |
1; |
|
removed experimental base_ta...
|
2059 | |
update pod
|
2060 |
B<MyModel/company.pm> |
removed experimental base_ta...
|
2061 | |
update pod
|
2062 |
package MyModel::company; |
2063 |
|
|
2064 |
use base 'MyModel'; |
|
2065 |
|
|
2066 |
1; |
|
2067 |
|
|
2068 |
MyModel::book and MyModel::company is included by C<include_model()>. |
|
removed experimental base_ta...
|
2069 | |
update pod
|
2070 |
You can get model object by C<model()>. |
2071 | ||
2072 |
my $book_model = $dbi->model('book'); |
|
2073 |
my $company_model = $dbi->model('company'); |
|
removed experimental base_ta...
|
2074 | |
update pod
|
2075 |
See L<DBIx::Custom::Model> to know model features. |
2076 | ||
2077 |
=head2 C<method> EXPERIMENTAL |
|
added experimental not_exist...
|
2078 | |
2079 |
$dbi->method( |
|
2080 |
update_or_insert => sub { |
|
2081 |
my $self = shift; |
|
update pod
|
2082 |
|
2083 |
# Process |
|
added experimental not_exist...
|
2084 |
}, |
2085 |
find_or_create => sub { |
|
2086 |
my $self = shift; |
|
update pod
|
2087 |
|
2088 |
# Process |
|
added experimental not_exist...
|
2089 |
} |
2090 |
); |
|
2091 | ||
update pod
|
2092 |
Register method. These method is called directly from L<DBIx::Custom> object. |
added experimental not_exist...
|
2093 | |
2094 |
$dbi->update_or_insert; |
|
2095 |
$dbi->find_or_create; |
|
2096 | ||
update pod
|
2097 |
=head2 C<model> EXPERIMENTAL |
2098 | ||
2099 |
$dbi->model('book')->method( |
|
2100 |
insert => sub { ... }, |
|
2101 |
update => sub { ... } |
|
2102 |
); |
|
2103 |
|
|
2104 |
my $model = $dbi->model('book'); |
|
2105 | ||
2106 |
Set and get a L<DBIx::Custom::Model> object, |
|
2107 | ||
added experimental not_exist...
|
2108 |
=head2 C<new> |
2109 | ||
update pod
|
2110 |
my $dbi = DBIx::Custom->new( |
2111 |
data_source => "dbi:mysql:database=dbname", |
|
2112 |
user => 'ken', |
|
2113 |
password => '!LFKD%$&', |
|
2114 |
dbi_option => {mysql_enable_utf8 => 1} |
|
2115 |
); |
|
added experimental not_exist...
|
2116 | |
2117 |
Create a new L<DBIx::Custom> object. |
|
2118 | ||
update pod
|
2119 |
=head2 C<not_exists> EXPERIMENTAL |
added experimental not_exist...
|
2120 | |
2121 |
my $not_exists = $dbi->not_exists; |
|
2122 | ||
update pod
|
2123 |
DBIx::Custom::NotExists object, indicating the column is not exists. |
2124 |
This is used by C<clause> of L<DBIx::Custom::Where> . |
|
experimental extended select...
|
2125 | |
cleanup
|
2126 |
=head2 C<register_filter> |
2127 | ||
update pod
|
2128 |
$dbi->register_filter( |
2129 |
# Time::Piece object to database DATE format |
|
2130 |
tp_to_date => sub { |
|
2131 |
my $tp = shift; |
|
2132 |
return $tp->strftime('%Y-%m-%d'); |
|
2133 |
}, |
|
2134 |
# database DATE format to Time::Piece object |
|
2135 |
date_to_tp => sub { |
|
2136 |
my $date = shift; |
|
2137 |
return Time::Piece->strptime($date, '%Y-%m-%d'); |
|
2138 |
} |
|
2139 |
); |
|
cleanup
|
2140 |
|
update pod
|
2141 |
Register filters, used by C<filter> option of many methods. |
cleanup
|
2142 | |
update pod
|
2143 |
=head2 C<register_tag> |
cleanup
|
2144 | |
update pod
|
2145 |
$dbi->register_tag( |
2146 |
update => sub { |
|
2147 |
my @columns = @_; |
|
2148 |
|
|
2149 |
# Update parameters |
|
2150 |
my $s = 'set '; |
|
2151 |
$s .= "$_ = ?, " for @columns; |
|
2152 |
$s =~ s/, $//; |
|
2153 |
|
|
2154 |
return [$s, \@columns]; |
|
2155 |
} |
|
2156 |
); |
|
cleanup
|
2157 | |
update pod
|
2158 |
Register tag, used by C<execute()>. |
cleanup
|
2159 | |
update pod
|
2160 |
See also L<Tags/Tags> about tag registered by default. |
cleanup
|
2161 | |
update pod
|
2162 |
Tag parser receive arguments specified in tag. |
2163 |
In the following tag, 'title' and 'author' is parser arguments |
|
cleanup
|
2164 | |
update pod
|
2165 |
{update_param title author} |
cleanup
|
2166 | |
update pod
|
2167 |
Tag parser must return array refrence, |
2168 |
first element is the result statement, |
|
2169 |
second element is column names corresponding to place holders. |
|
cleanup
|
2170 | |
update pod
|
2171 |
In this example, result statement is |
cleanup
|
2172 | |
update pod
|
2173 |
set title = ?, author = ? |
added register_tag_processor
|
2174 | |
update pod
|
2175 |
Column names is |
added register_tag_processor
|
2176 | |
update pod
|
2177 |
['title', 'author'] |
added register_tag_processor
|
2178 | |
removed DBIx::Custom commit ...
|
2179 |
=head2 C<select> |
added select() all_column op...
|
2180 | |
select method column option ...
|
2181 |
my $result = $dbi->select( |
added select() all_column op...
|
2182 |
table => 'book', |
2183 |
column => ['author', 'title'], |
|
2184 |
where => {author => 'Ken'}, |
|
select method column option ...
|
2185 |
); |
added select() all_column op...
|
2186 |
|
update pod
|
2187 |
Select statement. |
added select() all_column op...
|
2188 | |
2189 |
The following opitons are currently available. |
|
2190 | ||
2191 |
=over 4 |
|
2192 | ||
2193 |
=item C<table> |
|
2194 | ||
2195 |
Table name. |
|
2196 | ||
update pod
|
2197 |
$dbi->select(table => 'book'); |
added select() all_column op...
|
2198 | |
2199 |
=item C<column> |
|
2200 | ||
2201 |
Column clause. This is array reference or constant value. |
|
2202 | ||
2203 |
# Hash refernce |
|
2204 |
$dbi->select(column => ['author', 'title']); |
|
2205 |
|
|
2206 |
# Constant value |
|
2207 |
$dbi->select(column => 'author'); |
|
2208 | ||
2209 |
Default is '*' unless C<column> is specified. |
|
2210 | ||
2211 |
# Default |
|
2212 |
$dbi->select(column => '*'); |
|
2213 | ||
update pod
|
2214 |
=item C<all_column> EXPERIMENTAL |
added select() all_column op...
|
2215 | |
update pod
|
2216 |
Colum clause, contains all columns of joined table. This is true or false value |
added select() all_column op...
|
2217 | |
update pod
|
2218 |
$dbi->select(all_column => 1); |
added select() all_column op...
|
2219 | |
2220 |
If main table is C<book> and joined table is C<company>, |
|
2221 |
This create the following column clause. |
|
2222 | ||
2223 |
book.author as author |
|
2224 |
book.company_id as company_id |
|
2225 |
company.id as company__id |
|
2226 |
company.name as company__name |
|
2227 | ||
2228 |
Columns of main table is consist of only column name, |
|
2229 |
Columns of joined table is consist of table and column name joined C<__>. |
|
2230 | ||
- added EXPERIMENTAL DBIx::C...
|
2231 |
Note that this option is failed unless modles is included and |
2232 |
C<columns> attribute is set. |
|
update pod
|
2233 | |
2234 |
# Generally do the following way before using all_column option |
|
2235 |
$dbi->include_model('MyModel')->setup_model; |
|
2236 | ||
- added EXPERIMENTAL DBIx::C...
|
2237 |
You can also specify table names to C<all_column>. |
2238 | ||
2239 |
$dbi->select(all_column => ['book', 'company']); |
|
2240 | ||
added select() all_column op...
|
2241 |
=item C<where> |
2242 | ||
2243 |
Where clause. This is hash reference or L<DBIx::Custom::Where> object. |
|
2244 |
|
|
2245 |
# Hash reference |
|
update pod
|
2246 |
$dbi->select(where => {author => 'Ken', 'title' => 'Perl'}); |
added select() all_column op...
|
2247 |
|
update pod
|
2248 |
# DBIx::Custom::Where object |
added select() all_column op...
|
2249 |
my $where = $dbi->where( |
2250 |
clause => ['and', '{= author}', '{like title}'], |
|
2251 |
param => {author => 'Ken', title => '%Perl%'} |
|
2252 |
); |
|
update pod
|
2253 |
$dbi->select(where => $where); |
added select() all_column op...
|
2254 | |
update pod
|
2255 |
=item C<join> EXPERIMENTAL |
added select() all_column op...
|
2256 | |
update pod
|
2257 |
Join clause used in need. This is array reference. |
2258 | ||
2259 |
$dbi->select(join => |
|
2260 |
[ |
|
2261 |
'left outer join company on book.company_id = company_id', |
|
2262 |
'left outer join location on company.location_id = location.id' |
|
2263 |
] |
|
2264 |
); |
|
2265 | ||
2266 |
If column cluase or where clause contain table name like "company.name", |
|
2267 |
needed join clause is used automatically. |
|
2268 | ||
2269 |
$dbi->select( |
|
2270 |
table => 'book', |
|
2271 |
column => ['company.location_id as company__location_id'], |
|
2272 |
where => {'company.name' => 'Orange'}, |
|
2273 |
join => [ |
|
2274 |
'left outer join company on book.company_id = company.id', |
|
2275 |
'left outer join location on company.location_id = location.id' |
|
2276 |
] |
|
2277 |
); |
|
2278 | ||
2279 |
In above select, the following SQL is created. |
|
2280 | ||
2281 |
select company.location_id as company__location_id |
|
2282 |
from book |
|
2283 |
left outer join company on book.company_id = company.id |
|
2284 |
where company.name = Orange |
|
2285 | ||
2286 |
=item C<append> |
|
2287 | ||
update pod
|
2288 |
Append statement to last of SQL. This is string. |
update pod
|
2289 | |
2290 |
$dbi->select(append => 'order by title'); |
|
2291 | ||
2292 |
=item C<filter> |
|
2293 | ||
update pod
|
2294 |
Filter, executed before data is send to database. This is array reference. |
2295 |
Filter value is code reference or |
|
update pod
|
2296 |
filter name registerd by C<register_filter()>. |
2297 | ||
2298 |
# Basic |
|
2299 |
$dbi->select( |
|
2300 |
filter => [ |
|
2301 |
title => sub { uc $_[0] } |
|
2302 |
author => sub { uc $_[0] } |
|
2303 |
] |
|
2304 |
); |
|
2305 |
|
|
2306 |
# At once |
|
2307 |
$dbi->select( |
|
2308 |
filter => [ |
|
2309 |
[qw/title author/] => sub { uc $_[0] } |
|
2310 |
] |
|
2311 |
); |
|
2312 |
|
|
2313 |
# Filter name |
|
2314 |
$dbi->select( |
|
2315 |
filter => [ |
|
2316 |
title => 'upper_case', |
|
2317 |
author => 'upper_case' |
|
2318 |
] |
|
2319 |
); |
|
add experimental selection o...
|
2320 | |
update pod
|
2321 |
These filters are added to the C<out> filters, set by C<apply_filter()>. |
update document
|
2322 | |
update pod
|
2323 |
=item C<query> EXPERIMENTAL |
cleanup
|
2324 | |
update pod
|
2325 |
Get L<DBIx::Custom::Query> object instead of executing SQL. |
2326 |
This is true or false value. |
|
2327 | ||
update pod
|
2328 |
my $query = $dbi->select(query => 1); |
update pod
|
2329 | |
update pod
|
2330 |
You can check SQL. |
update pod
|
2331 | |
2332 |
my $sql = $query->sql; |
|
2333 | ||
2334 |
=back |
|
cleanup
|
2335 | |
update pod
|
2336 |
=head2 C<select_at()> EXPERIMENTAL |
add experimental update_at()...
|
2337 | |
update pod
|
2338 |
Select statement, using primary key. |
2339 | ||
2340 |
$dbi->select_at( |
|
2341 |
table => 'book', |
|
2342 |
primary_key => 'id', |
|
2343 |
where => '5' |
|
2344 |
); |
|
2345 | ||
update pod
|
2346 |
This method is same as C<select()> exept that |
2347 |
C<primary_key> is specified and C<where> is constant value or array refrence. |
|
update pod
|
2348 |
all option of C<select()> is available. |
add experimental update_at()...
|
2349 | |
update pod
|
2350 |
=over 4 |
2351 | ||
2352 |
=item C<primary_key> |
|
add experimental update_at()...
|
2353 | |
update pod
|
2354 |
Primary key. This is constant value or array reference. |
2355 |
|
|
2356 |
# Constant value |
|
2357 |
$dbi->select(primary_key => 'id'); |
|
2358 | ||
2359 |
# Array reference |
|
2360 |
$dbi->select(primary_key => ['id1', 'id2' ]); |
|
2361 | ||
update pod
|
2362 |
This is used to create where clause. |
2363 | ||
update pod
|
2364 |
=item C<where> |
update pod
|
2365 | |
update pod
|
2366 |
Where clause, created from primary key information. |
update pod
|
2367 |
This is constant value or array reference. |
2368 | ||
2369 |
# Constant value |
|
2370 |
$dbi->select(where => 5); |
|
2371 | ||
2372 |
# Array reference |
|
2373 |
$dbi->select(where => [3, 5]); |
|
2374 | ||
2375 |
In first examle, the following SQL is created. |
|
2376 | ||
2377 |
select * from book where id = ? |
|
2378 | ||
2379 |
Place holder is set to 5. |
|
add experimental update_at()...
|
2380 | |
update pod
|
2381 |
=back |
2382 | ||
cleanup
|
2383 |
=head2 C<update> |
removed reconnect method
|
2384 | |
update pod
|
2385 |
$dbi->update( |
2386 |
table => 'book', |
|
2387 |
param => {title => 'Perl'}, |
|
2388 |
where => {id => 4} |
|
2389 |
); |
|
removed reconnect method
|
2390 | |
update pod
|
2391 |
Update statement. |
added experimental update_pa...
|
2392 | |
update pod
|
2393 |
The following opitons are currently available. |
added experimental update_pa...
|
2394 | |
update pod
|
2395 |
=over 4 |
2396 | ||
update pod
|
2397 |
=item C<table> |
2398 | ||
update pod
|
2399 |
Table name. |
2400 | ||
2401 |
$dbi->update(table => 'book'); |
|
2402 | ||
2403 |
=item C<param> |
|
2404 | ||
2405 |
Update data. This is hash reference. |
|
2406 | ||
2407 |
$dbi->update(param => {title => 'Perl'}); |
|
2408 | ||
2409 |
=item C<where> |
|
2410 | ||
2411 |
Where clause. This is hash reference or L<DBIx::Custom::Where> object. |
|
2412 |
|
|
2413 |
# Hash reference |
|
2414 |
$dbi->update(where => {author => 'Ken', 'title' => 'Perl'}); |
|
2415 |
|
|
2416 |
# DBIx::Custom::Where object |
|
2417 |
my $where = $dbi->where( |
|
2418 |
clause => ['and', '{= author}', '{like title}'], |
|
2419 |
param => {author => 'Ken', title => '%Perl%'} |
|
2420 |
); |
|
2421 |
$dbi->update(where => $where); |
|
2422 | ||
2423 |
=item C<append> |
|
2424 | ||
2425 |
Append statement to last of SQL. This is string. |
|
2426 | ||
2427 |
$dbi->update(append => 'order by title'); |
|
2428 | ||
2429 |
=item C<filter> |
|
2430 | ||
2431 |
Filter, executed before data is send to database. This is array reference. |
|
2432 |
Filter value is code reference or |
|
2433 |
filter name registerd by C<register_filter()>. |
|
2434 | ||
2435 |
# Basic |
|
2436 |
$dbi->update( |
|
2437 |
filter => [ |
|
2438 |
title => sub { uc $_[0] } |
|
2439 |
author => sub { uc $_[0] } |
|
2440 |
] |
|
2441 |
); |
|
2442 |
|
|
2443 |
# At once |
|
2444 |
$dbi->update( |
|
2445 |
filter => [ |
|
2446 |
[qw/title author/] => sub { uc $_[0] } |
|
2447 |
] |
|
2448 |
); |
|
2449 |
|
|
2450 |
# Filter name |
|
2451 |
$dbi->update( |
|
2452 |
filter => [ |
|
2453 |
title => 'upper_case', |
|
2454 |
author => 'upper_case' |
|
2455 |
] |
|
2456 |
); |
|
added experimental update_pa...
|
2457 | |
update pod
|
2458 |
These filters are added to the C<out> filters, set by C<apply_filter()>. |
added experimental update_pa...
|
2459 | |
update pod
|
2460 |
=item C<query> EXPERIMENTAL |
add experimental setup_model...
|
2461 | |
update pod
|
2462 |
Get L<DBIx::Custom::Query> object instead of executing SQL. |
2463 |
This is true or false value. |
|
add experimental setup_model...
|
2464 | |
update pod
|
2465 |
my $query = $dbi->update(query => 1); |
2466 | ||
2467 |
You can check SQL. |
|
2468 | ||
2469 |
my $sql = $query->sql; |
|
add experimental setup_model...
|
2470 | |
update pod
|
2471 |
=back |
2472 | ||
cleanup
|
2473 |
=head2 C<update_all> |
renamed build_query to creat...
|
2474 | |
update pod
|
2475 |
$dbi->update_all(table => 'book', param => {title => 'Perl'}); |
renamed build_query to creat...
|
2476 | |
update pod
|
2477 |
Update statement to update all rows. |
2478 |
Options is same as C<update()>. |
|
removed DBIx::Custom commit ...
|
2479 | |
update pod
|
2480 |
=head2 C<update_at()> EXPERIMENTAL |
add experimental update_at()...
|
2481 | |
update pod
|
2482 |
Update statement, using primary key. |
add experimental update_at()...
|
2483 | |
2484 |
$dbi->update_at( |
|
2485 |
table => 'book', |
|
update pod
|
2486 |
primary_key => 'id', |
2487 |
where => '5', |
|
2488 |
param => {title => 'Perl'} |
|
add experimental update_at()...
|
2489 |
); |
2490 | ||
update pod
|
2491 |
This method is same as C<update()> exept that |
2492 |
C<primary_key> is specified and C<where> is constant value or array refrence. |
|
2493 |
all option of C<update()> is available. |
|
2494 | ||
update pod
|
2495 |
=over 4 |
2496 | ||
2497 |
=item C<primary_key> |
|
update pod
|
2498 | |
2499 |
Primary key. This is constant value or array reference. |
|
2500 |
|
|
2501 |
# Constant value |
|
2502 |
$dbi->update(primary_key => 'id'); |
|
2503 | ||
2504 |
# Array reference |
|
2505 |
$dbi->update(primary_key => ['id1', 'id2' ]); |
|
2506 | ||
2507 |
This is used to create where clause. |
|
2508 | ||
update pod
|
2509 |
=item C<where> |
update pod
|
2510 | |
2511 |
Where clause, created from primary key information. |
|
2512 |
This is constant value or array reference. |
|
2513 | ||
2514 |
# Constant value |
|
2515 |
$dbi->update(where => 5); |
|
2516 | ||
2517 |
# Array reference |
|
2518 |
$dbi->update(where => [3, 5]); |
|
2519 | ||
2520 |
In first examle, the following SQL is created. |
|
2521 | ||
2522 |
update book set title = ? where id = ? |
|
2523 | ||
2524 |
Place holders are set to 'Perl' and 5. |
|
2525 | ||
update pod
|
2526 |
=back |
2527 | ||
2528 |
=head2 C<update_param> EXPERIMENTAL |
|
update pod
|
2529 | |
2530 |
my $update_param = $dbi->update_param({title => 'a', age => 2}); |
|
2531 | ||
2532 |
Create update parameter tag. |
|
2533 | ||
2534 |
{update_param title age} |
|
add experimental update_at()...
|
2535 | |
update pod
|
2536 |
=head2 C<where> EXPERIMENTAL |
fix tests
|
2537 | |
cleanup
|
2538 |
my $where = $dbi->where( |
2539 |
clause => ['and', '{= title}', '{= author}'], |
|
2540 |
param => {title => 'Perl', author => 'Ken'} |
|
2541 |
); |
|
fix tests
|
2542 | |
2543 |
Create a new L<DBIx::Custom::Where> object. |
|
2544 | ||
update pod
|
2545 |
=head2 C<setup_model> EXPERIMENTAL |
cleanup
|
2546 | |
update pod
|
2547 |
$dbi->setup_model; |
cleanup
|
2548 | |
update pod
|
2549 |
Setup all model objects. |
update pod
|
2550 |
C<columns> of model object is automatically set, parsing database information. |
cleanup
|
2551 | |
- added EXPERIMENTAL DBIx::C...
|
2552 |
=head2 C<view> EXPERIMENTAL |
2553 | ||
2554 |
# Register view |
|
2555 |
$dbi->view( |
|
2556 |
book_issue_data |
|
2557 |
=> 'select id, DATE(issue_datatime) as issue_date from book'); |
|
2558 |
); |
|
2559 |
|
|
2560 |
# Get view |
|
2561 |
my $view = $dbi->view('book_issue_date'); |
|
2562 | ||
2563 |
View. |
|
2564 | ||
2565 |
C<view()> return the following statement when you get a view. |
|
2566 | ||
2567 |
(select id, DATE(issue_datetime) from book) as book_issue_date |
|
2568 | ||
2569 |
You can use this view in from clause |
|
2570 | ||
2571 |
"select issue_date from " . $dbi->view('book_issue_date') |
|
2572 | ||
cleanup
|
2573 |
=head1 Tags |
2574 | ||
2575 |
The following tags is available. |
|
2576 | ||
update pod
|
2577 |
=head2 C<table> EXPERIMENTAL |
add table tag
|
2578 | |
2579 |
Table tag |
|
2580 | ||
2581 |
{table TABLE} -> TABLE |
|
2582 | ||
update pod
|
2583 |
This is used to tell C<execute()> what table is needed . |
add table tag
|
2584 | |
cleanup
|
2585 |
=head2 C<?> |
2586 | ||
2587 |
Placeholder tag. |
|
2588 | ||
2589 |
{? NAME} -> ? |
|
2590 | ||
2591 |
=head2 C<=> |
|
2592 | ||
2593 |
Equal tag. |
|
2594 | ||
2595 |
{= NAME} -> NAME = ? |
|
2596 | ||
2597 |
=head2 C<E<lt>E<gt>> |
|
2598 | ||
2599 |
Not equal tag. |
|
2600 | ||
2601 |
{<> NAME} -> NAME <> ? |
|
2602 | ||
2603 |
=head2 C<E<lt>> |
|
2604 | ||
2605 |
Lower than tag |
|
2606 | ||
2607 |
{< NAME} -> NAME < ? |
|
2608 | ||
2609 |
=head2 C<E<gt>> |
|
2610 | ||
2611 |
Greater than tag |
|
2612 | ||
2613 |
{> NAME} -> NAME > ? |
|
2614 | ||
2615 |
=head2 C<E<gt>=> |
|
2616 | ||
2617 |
Greater than or equal tag |
|
2618 | ||
2619 |
{>= NAME} -> NAME >= ? |
|
2620 | ||
2621 |
=head2 C<E<lt>=> |
|
2622 | ||
2623 |
Lower than or equal tag |
|
2624 | ||
2625 |
{<= NAME} -> NAME <= ? |
|
2626 | ||
2627 |
=head2 C<like> |
|
2628 | ||
2629 |
Like tag |
|
2630 | ||
2631 |
{like NAME} -> NAME like ? |
|
2632 | ||
2633 |
=head2 C<in> |
|
2634 | ||
2635 |
In tag. |
|
2636 | ||
2637 |
{in NAME COUNT} -> NAME in [?, ?, ..] |
|
2638 | ||
2639 |
=head2 C<insert_param> |
|
2640 | ||
2641 |
Insert parameter tag. |
|
2642 | ||
2643 |
{insert_param NAME1 NAME2} -> (NAME1, NAME2) values (?, ?) |
|
2644 | ||
2645 |
=head2 C<update_param> |
|
2646 | ||
2647 |
Updata parameter tag. |
|
2648 | ||
2649 |
{update_param NAME1 NAME2} -> set NAME1 = ?, NAME2 = ? |
|
2650 | ||
DBIx::Custom is now stable
|
2651 |
=head1 STABILITY |
2652 | ||
cleanup
|
2653 |
L<DBIx::Custom> is stable. APIs keep backword compatible |
added select() all_column op...
|
2654 |
except EXPERIMENTAL one in the feature. |
DBIx::Custom is now stable
|
2655 | |
removed DESTROY method(not b...
|
2656 |
=head1 BUGS |
2657 | ||
renamed build_query to creat...
|
2658 |
Please tell me bugs if found. |
removed DESTROY method(not b...
|
2659 | |
2660 |
C<< <kimoto.yuki at gmail.com> >> |
|
2661 | ||
2662 |
L<http://github.com/yuki-kimoto/DBIx-Custom> |
|
2663 | ||
removed reconnect method
|
2664 |
=head1 AUTHOR |
2665 | ||
2666 |
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >> |
|
version 0.0901
|
2667 | |
packaging one directory
|
2668 |
=head1 COPYRIGHT & LICENSE |
2669 | ||
cleanup
|
2670 |
Copyright 2009-2011 Yuki Kimoto, all rights reserved. |
packaging one directory
|
2671 | |
2672 |
This program is free software; you can redistribute it and/or modify it |
|
2673 |
under the same terms as Perl itself. |
|
2674 | ||
2675 |
=cut |
|
added cache_method attribute
|
2676 | |
2677 |