cleanup
|
1 |
package DBIx::Custom; |
2 | ||
cleanup
|
3 |
our $VERSION = '0.1618'; |
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; |
update document
|
16 |
use Encode qw/encode_utf8 decode_utf8/; |
packaging one directory
|
17 | |
cleanup
|
18 |
__PACKAGE__->attr([qw/data_source dbh default_bind_filter |
19 |
default_fetch_filter password user/]); |
|
added cache_method attribute
|
20 | |
add cache attribute
|
21 |
__PACKAGE__->attr(cache => 1); |
added cache_method attribute
|
22 |
__PACKAGE__->attr(cache_method => sub { |
23 |
sub { |
|
24 |
my $self = shift; |
|
25 |
|
|
26 |
$self->{_cached} ||= {}; |
|
27 |
|
|
28 |
if (@_ > 1) { |
|
29 |
$self->{_cached}{$_[0]} = $_[1] |
|
30 |
} |
|
31 |
else { |
|
32 |
return $self->{_cached}{$_[0]} |
|
33 |
} |
|
34 |
} |
|
35 |
}); |
|
removed register_format()
|
36 | |
cleanup
|
37 |
__PACKAGE__->dual_attr('filters', default => sub { {} }, |
38 |
inherit => 'hash_copy'); |
|
added check_filter attribute
|
39 |
__PACKAGE__->attr(filter_check => 1); |
cleanup
|
40 |
__PACKAGE__->attr(query_builder => sub {DBIx::Custom::QueryBuilder->new}); |
41 |
__PACKAGE__->attr(result_class => 'DBIx::Custom::Result'); |
|
42 | ||
43 |
# DBI methods |
|
44 |
foreach my $method (qw/begin_work commit rollback/) { |
|
45 |
my $code = sub { |
|
46 |
my $self = shift; |
|
47 |
my $ret = eval {$self->dbh->$method}; |
|
48 |
croak $@ if $@; |
|
49 |
return $ret; |
|
50 |
}; |
|
51 |
no strict 'refs'; |
|
52 |
my $pkg = __PACKAGE__; |
|
53 |
*{"${pkg}::$method"} = $code; |
|
54 |
}; |
|
55 | ||
56 |
# Regster filter |
|
57 |
__PACKAGE__->register_filter( |
|
58 |
encode_utf8 => sub { encode_utf8($_[0]) }, |
|
59 |
decode_utf8 => sub { decode_utf8($_[0]) } |
|
60 |
); |
|
added check_filter attribute
|
61 | |
added helper method
|
62 |
our $AUTOLOAD; |
63 | ||
64 |
sub AUTOLOAD { |
|
65 |
my $self = shift; |
|
66 | ||
67 |
# Method |
|
68 |
my ($package, $method) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/; |
|
69 | ||
70 |
# Helper |
|
71 |
$self->{_helpers} ||= {}; |
|
72 |
croak qq/Can't locate object method "$method" via "$package"/ |
|
73 |
unless my $helper = $self->{_helpers}->{$method}; |
|
74 | ||
75 |
# Run |
|
76 |
return $self->$helper(@_); |
|
77 |
} |
|
78 | ||
79 |
sub helper { |
|
80 |
my $self = shift; |
|
81 |
|
|
82 |
# Merge |
|
83 |
my $helpers = ref $_[0] eq 'HASH' ? $_[0] : {@_}; |
|
84 |
$self->{_helpers} = {%{$self->{_helpers} || {}}, %$helpers}; |
|
85 |
|
|
86 |
return $self; |
|
87 |
} |
|
88 | ||
packaging one directory
|
89 |
sub connect { |
removed register_format()
|
90 |
my $proto = shift; |
91 |
|
|
92 |
# Create |
|
93 |
my $self = ref $proto ? $proto : $proto->new(@_); |
|
update document
|
94 |
|
95 |
# Information |
|
packaging one directory
|
96 |
my $data_source = $self->data_source; |
97 |
my $user = $self->user; |
|
98 |
my $password = $self->password; |
|
99 |
|
|
removed experimental registe...
|
100 |
|
update document
|
101 |
# Connect |
select, insert, update, upda...
|
102 |
my $dbh = eval {DBI->connect( |
packaging one directory
|
103 |
$data_source, |
104 |
$user, |
|
105 |
$password, |
|
106 |
{ |
|
107 |
RaiseError => 1, |
|
108 |
PrintError => 0, |
|
109 |
AutoCommit => 1, |
|
110 |
} |
|
111 |
)}; |
|
112 |
|
|
update document
|
113 |
# Connect error |
packaging one directory
|
114 |
croak $@ if $@; |
115 |
|
|
update document
|
116 |
# Database handle |
packaging one directory
|
117 |
$self->dbh($dbh); |
update document
|
118 |
|
packaging one directory
|
119 |
return $self; |
120 |
} |
|
121 | ||
cleanup
|
122 |
sub create_query { |
123 |
my ($self, $source) = @_; |
|
update document
|
124 |
|
cleanup
|
125 |
# Cache |
126 |
my $cache = $self->cache; |
|
update document
|
127 |
|
cleanup
|
128 |
# Create query |
129 |
my $query; |
|
130 |
if ($cache) { |
|
131 |
|
|
132 |
# Get query |
|
133 |
my $q = $self->cache_method->($self, $source); |
|
134 |
|
|
135 |
# Create query |
|
136 |
$query = DBIx::Custom::Query->new($q) if $q; |
|
137 |
} |
|
138 |
|
|
139 |
unless ($query) { |
|
cleanup insert
|
140 | |
cleanup
|
141 |
# Create SQL object |
142 |
my $builder = $self->query_builder; |
|
143 |
|
|
144 |
# Create query |
|
145 |
$query = $builder->build_query($source); |
|
removed register_format()
|
146 | |
cleanup
|
147 |
# Cache query |
148 |
$self->cache_method->($self, $source, |
|
149 |
{sql => $query->sql, |
|
150 |
columns => $query->columns}) |
|
151 |
if $cache; |
|
cleanup insert
|
152 |
} |
153 |
|
|
cleanup
|
154 |
# Prepare statement handle |
155 |
my $sth; |
|
156 |
eval { $sth = $self->dbh->prepare($query->{sql})}; |
|
157 |
$self->_croak($@, qq{. SQL: "$query->{sql}"}) if $@; |
|
packaging one directory
|
158 |
|
cleanup
|
159 |
# Set statement handle |
160 |
$query->sth($sth); |
|
packaging one directory
|
161 |
|
cleanup
|
162 |
return $query; |
packaging one directory
|
163 |
} |
164 | ||
cleanup
|
165 |
our %VALID_DELETE_ARGS |
166 |
= map { $_ => 1 } qw/table where append filter allow_delete_all/; |
|
cleanup update and update_al...
|
167 | |
cleanup
|
168 |
sub delete { |
select, insert, update, upda...
|
169 |
my ($self, %args) = @_; |
cleanup update and update_al...
|
170 |
|
171 |
# Check arguments |
|
select, insert, update, upda...
|
172 |
foreach my $name (keys %args) { |
add tests
|
173 |
croak qq{"$name" is invalid argument} |
cleanup
|
174 |
unless $VALID_DELETE_ARGS{$name}; |
cleanup update and update_al...
|
175 |
} |
176 |
|
|
177 |
# Arguments |
|
select, insert, update, upda...
|
178 |
my $table = $args{table} || ''; |
179 |
my $where = $args{where} || {}; |
|
cleanup
|
180 |
my $append = $args{append}; |
select, insert, update, upda...
|
181 |
my $filter = $args{filter}; |
cleanup
|
182 |
my $allow_delete_all = $args{allow_delete_all}; |
packaging one directory
|
183 |
|
184 |
# Where keys |
|
removed register_format()
|
185 |
my @where_keys = keys %$where; |
packaging one directory
|
186 |
|
187 |
# Not exists where keys |
|
add tests
|
188 |
croak qq{"where" argument must be specified and } . |
189 |
qq{contains the pairs of column name and value} |
|
cleanup
|
190 |
if !@where_keys && !$allow_delete_all; |
packaging one directory
|
191 |
|
192 |
# Where clause |
|
193 |
my $where_clause = ''; |
|
194 |
if (@where_keys) { |
|
195 |
$where_clause = 'where '; |
|
add tests
|
196 |
$where_clause .= "{= $_} and " for @where_keys; |
packaging one directory
|
197 |
$where_clause =~ s/ and $//; |
198 |
} |
|
199 |
|
|
add tests
|
200 |
# Source of SQL |
cleanup
|
201 |
my $source = "delete from $table $where_clause"; |
add tests
|
202 |
$source .= " $append" if $append; |
packaging one directory
|
203 |
|
204 |
# Execute query |
|
cleanup
|
205 |
my $ret_val = $self->execute($source, param => $where, |
add tests
|
206 |
filter => $filter); |
packaging one directory
|
207 |
|
208 |
return $ret_val; |
|
209 |
} |
|
210 | ||
cleanup
|
211 |
sub delete_all { shift->delete(allow_delete_all => 1, @_) } |
packaging one directory
|
212 | |
added helper method
|
213 |
sub DESTROY { } |
214 | ||
cleanup
|
215 |
our %VALID_EXECUTE_ARGS = map { $_ => 1 } qw/param filter/; |
refactoring delete and delet...
|
216 | |
cleanup
|
217 |
sub execute{ |
218 |
my ($self, $query, %args) = @_; |
|
refactoring delete and delet...
|
219 |
|
220 |
# Check arguments |
|
select, insert, update, upda...
|
221 |
foreach my $name (keys %args) { |
add tests
|
222 |
croak qq{"$name" is invalid argument} |
cleanup
|
223 |
unless $VALID_EXECUTE_ARGS{$name}; |
refactoring delete and delet...
|
224 |
} |
225 |
|
|
cleanup
|
226 |
my $params = $args{param} || {}; |
packaging one directory
|
227 |
|
cleanup
|
228 |
# First argument is the soruce of SQL |
229 |
$query = $self->create_query($query) |
|
230 |
unless ref $query; |
|
packaging one directory
|
231 |
|
cleanup
|
232 |
my $filter = $args{filter} || $query->filter || {}; |
packaging one directory
|
233 |
|
cleanup
|
234 |
# Create bind value |
235 |
my $bind_values = $self->_build_bind_values($query, $params, $filter); |
|
236 |
|
|
237 |
# Execute |
|
238 |
my $sth = $query->sth; |
|
239 |
my $affected; |
|
240 |
eval {$affected = $sth->execute(@$bind_values)}; |
|
241 |
$self->_croak($@) if $@; |
|
242 |
|
|
243 |
# Return resultset if select statement is executed |
|
244 |
if ($sth->{NUM_OF_FIELDS}) { |
|
245 |
|
|
246 |
# Create result |
|
247 |
my $result = $self->result_class->new( |
|
248 |
sth => $sth, |
|
249 |
default_filter => $self->default_fetch_filter, |
|
250 |
filters => $self->filters, |
|
251 |
filter_check => $self->filter_check |
|
252 |
); |
|
253 | ||
254 |
return $result; |
|
255 |
} |
|
256 |
return $affected; |
|
257 |
} |
|
258 | ||
259 |
our %VALID_INSERT_ARGS = map { $_ => 1 } qw/table param append filter/; |
|
260 | ||
261 |
sub insert { |
|
262 |
my ($self, %args) = @_; |
|
263 | ||
264 |
# Check arguments |
|
265 |
foreach my $name (keys %args) { |
|
266 |
croak qq{"$name" is invalid argument} |
|
267 |
unless $VALID_INSERT_ARGS{$name}; |
|
packaging one directory
|
268 |
} |
269 |
|
|
cleanup
|
270 |
# Arguments |
271 |
my $table = $args{table} || ''; |
|
272 |
my $param = $args{param} || {}; |
|
273 |
my $append = $args{append} || ''; |
|
274 |
my $filter = $args{filter}; |
|
275 |
|
|
276 |
# Insert keys |
|
277 |
my @insert_keys = keys %$param; |
|
278 |
|
|
279 |
# Templte for insert |
|
280 |
my $source = "insert into $table {insert_param " |
|
281 |
. join(' ', @insert_keys) . '}'; |
|
add tests
|
282 |
$source .= " $append" if $append; |
packaging one directory
|
283 |
|
284 |
# Execute query |
|
cleanup
|
285 |
my $ret_val = $self->execute($source, param => $param, |
286 |
filter => $filter); |
|
packaging one directory
|
287 |
|
288 |
return $ret_val; |
|
289 |
} |
|
290 | ||
cleanup
|
291 |
sub register_filter { |
292 |
my $invocant = shift; |
|
293 |
|
|
294 |
# Register filter |
|
295 |
my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_}; |
|
296 |
$invocant->filters({%{$invocant->filters}, %$filters}); |
|
297 |
|
|
298 |
return $invocant; |
|
299 |
} |
|
packaging one directory
|
300 | |
refactoring select
|
301 |
our %VALID_SELECT_ARGS |
added commit method
|
302 |
= map { $_ => 1 } qw/table column where append relation filter param/; |
refactoring select
|
303 | |
packaging one directory
|
304 |
sub select { |
select, insert, update, upda...
|
305 |
my ($self, %args) = @_; |
packaging one directory
|
306 |
|
refactoring select
|
307 |
# Check arguments |
select, insert, update, upda...
|
308 |
foreach my $name (keys %args) { |
add tests
|
309 |
croak qq{"$name" is invalid argument} |
refactoring select
|
310 |
unless $VALID_SELECT_ARGS{$name}; |
311 |
} |
|
packaging one directory
|
312 |
|
refactoring select
|
313 |
# Arguments |
select, insert, update, upda...
|
314 |
my $tables = $args{table} || []; |
removed register_format()
|
315 |
$tables = [$tables] unless ref $tables eq 'ARRAY'; |
select, insert, update, upda...
|
316 |
my $columns = $args{column} || []; |
update document
|
317 |
my $where = $args{where}; |
select, insert, update, upda...
|
318 |
my $relation = $args{relation}; |
319 |
my $append = $args{append}; |
|
320 |
my $filter = $args{filter}; |
|
packaging one directory
|
321 |
|
add tests
|
322 |
# Source of SQL |
renamed default_query_filter...
|
323 |
my $source = 'select '; |
packaging one directory
|
324 |
|
added commit method
|
325 |
# Column clause |
packaging one directory
|
326 |
if (@$columns) { |
327 |
foreach my $column (@$columns) { |
|
renamed default_query_filter...
|
328 |
$source .= "$column, "; |
packaging one directory
|
329 |
} |
renamed default_query_filter...
|
330 |
$source =~ s/, $/ /; |
packaging one directory
|
331 |
} |
332 |
else { |
|
renamed default_query_filter...
|
333 |
$source .= '* '; |
packaging one directory
|
334 |
} |
335 |
|
|
added commit method
|
336 |
# Table |
renamed default_query_filter...
|
337 |
$source .= 'from '; |
packaging one directory
|
338 |
foreach my $table (@$tables) { |
renamed default_query_filter...
|
339 |
$source .= "$table, "; |
packaging one directory
|
340 |
} |
renamed default_query_filter...
|
341 |
$source =~ s/, $/ /; |
packaging one directory
|
342 |
|
added commit method
|
343 |
# Where clause |
update document
|
344 |
my $param; |
345 |
if (ref $where eq 'HASH') { |
|
346 |
$param = $where; |
|
347 |
$source .= 'where ('; |
|
348 |
foreach my $where_key (keys %$where) { |
|
renamed default_query_filter...
|
349 |
$source .= "{= $where_key} and "; |
packaging one directory
|
350 |
} |
update document
|
351 |
$source =~ s/ and $//; |
352 |
$source .= ') '; |
|
353 |
} |
|
354 |
elsif (ref $where eq 'ARRAY') { |
|
355 |
my$where_str = $where->[0] || ''; |
|
356 |
$param = $where->[1]; |
|
357 |
|
|
358 |
$source .= "where ($where_str) "; |
|
packaging one directory
|
359 |
} |
360 |
|
|
added commit method
|
361 |
# Relation |
362 |
if ($relation) { |
|
update document
|
363 |
$source .= $where ? "and " : "where "; |
added commit method
|
364 |
foreach my $rkey (keys %$relation) { |
renamed default_query_filter...
|
365 |
$source .= "$rkey = " . $relation->{$rkey} . " and "; |
packaging one directory
|
366 |
} |
367 |
} |
|
renamed default_query_filter...
|
368 |
$source =~ s/ and $//; |
added commit method
|
369 |
|
370 |
# Append some statement |
|
renamed default_query_filter...
|
371 |
$source .= " $append" if $append; |
packaging one directory
|
372 |
|
373 |
# Execute query |
|
update document
|
374 |
my $result = $self->execute($source, param => $param, |
375 |
filter => $filter); |
|
packaging one directory
|
376 |
|
377 |
return $result; |
|
378 |
} |
|
379 | ||
cleanup
|
380 |
our %VALID_UPDATE_ARGS |
381 |
= map { $_ => 1 } qw/table param where append filter allow_update_all/; |
|
382 | ||
383 |
sub update { |
|
384 |
my ($self, %args) = @_; |
|
version 0.0901
|
385 |
|
cleanup
|
386 |
# Check arguments |
387 |
foreach my $name (keys %args) { |
|
388 |
croak qq{"$name" is invalid argument} |
|
389 |
unless $VALID_UPDATE_ARGS{$name}; |
|
removed reconnect method
|
390 |
} |
added cache_method attribute
|
391 |
|
cleanup
|
392 |
# Arguments |
393 |
my $table = $args{table} || ''; |
|
394 |
my $param = $args{param} || {}; |
|
395 |
my $where = $args{where} || {}; |
|
396 |
my $append = $args{append} || ''; |
|
397 |
my $filter = $args{filter}; |
|
398 |
my $allow_update_all = $args{allow_update_all}; |
|
version 0.0901
|
399 |
|
cleanup
|
400 |
# Update keys |
401 |
my @update_keys = keys %$param; |
|
renamed fetch_rows to fetch_...
|
402 |
|
cleanup
|
403 |
# Where keys |
404 |
my @where_keys = keys %$where; |
|
removed reconnect method
|
405 |
|
cleanup
|
406 |
# Not exists where keys |
407 |
croak qq{"where" argument must be specified and } . |
|
408 |
qq{contains the pairs of column name and value} |
|
409 |
if !@where_keys && !$allow_update_all; |
|
removed experimental registe...
|
410 |
|
cleanup
|
411 |
# Update clause |
412 |
my $update_clause = '{update_param ' . join(' ', @update_keys) . '}'; |
|
removed experimental registe...
|
413 |
|
cleanup
|
414 |
# Where clause |
415 |
my $where_clause = ''; |
|
416 |
my $new_where = {}; |
|
removed reconnect method
|
417 |
|
cleanup
|
418 |
if (@where_keys) { |
419 |
$where_clause = 'where '; |
|
420 |
$where_clause .= "{= $_} and " for @where_keys; |
|
421 |
$where_clause =~ s/ and $//; |
|
removed reconnect method
|
422 |
} |
423 |
|
|
cleanup
|
424 |
# Source of SQL |
425 |
my $source = "update $table $update_clause $where_clause"; |
|
426 |
$source .= " $append" if $append; |
|
removed reconnect method
|
427 |
|
cleanup
|
428 |
# Rearrange parameters |
429 |
foreach my $wkey (@where_keys) { |
|
removed reconnect method
|
430 |
|
cleanup
|
431 |
if (exists $param->{$wkey}) { |
432 |
$param->{$wkey} = [$param->{$wkey}] |
|
433 |
unless ref $param->{$wkey} eq 'ARRAY'; |
|
434 |
|
|
435 |
push @{$param->{$wkey}}, $where->{$wkey}; |
|
436 |
} |
|
437 |
else { |
|
438 |
$param->{$wkey} = $where->{$wkey}; |
|
439 |
} |
|
removed reconnect method
|
440 |
} |
cleanup
|
441 |
|
442 |
# Execute query |
|
443 |
my $ret_val = $self->execute($source, param => $param, |
|
444 |
filter => $filter); |
|
445 |
|
|
446 |
return $ret_val; |
|
removed reconnect method
|
447 |
} |
448 | ||
cleanup
|
449 |
sub update_all { shift->update(allow_update_all => 1, @_) }; |
450 | ||
removed reconnect method
|
451 |
sub _build_bind_values { |
452 |
my ($self, $query, $params, $filter) = @_; |
|
453 |
|
|
454 |
# binding values |
|
455 |
my @bind_values; |
|
add tests
|
456 | |
457 |
# Filter |
|
458 |
$filter ||= {}; |
|
459 |
|
|
460 |
# Parameter |
|
461 |
$params ||= {}; |
|
462 |
|
|
463 |
# Check filter |
|
464 |
$self->_check_filter($self->filters, $filter, |
|
465 |
$self->default_bind_filter, $params) |
|
466 |
if $self->filter_check; |
|
removed reconnect method
|
467 |
|
468 |
# Build bind values |
|
469 |
my $count = {}; |
|
470 |
foreach my $column (@{$query->columns}) { |
|
471 |
|
|
472 |
# Value |
|
473 |
my $value = ref $params->{$column} eq 'ARRAY' |
|
474 |
? $params->{$column}->[$count->{$column} || 0] |
|
475 |
: $params->{$column}; |
|
476 |
|
|
add tests
|
477 |
# Filtering |
renamed default_query_filter...
|
478 |
my $fname = $filter->{$column} || $self->default_bind_filter || ''; |
add tests
|
479 |
my $filter_func = $fname ? $self->filters->{$fname} : undef; |
removed reconnect method
|
480 |
push @bind_values, $filter_func |
481 |
? $filter_func->($value) |
|
482 |
: $value; |
|
483 |
|
|
484 |
# Count up |
|
485 |
$count->{$column}++; |
|
486 |
} |
|
487 |
|
|
488 |
return \@bind_values; |
|
489 |
} |
|
490 | ||
add tests
|
491 |
sub _check_filter { |
492 |
my ($self, $filters, $filter, $default_filter, $params) = @_; |
|
493 |
|
|
494 |
# Filter name not exists |
|
495 |
foreach my $fname (values %$filter) { |
|
496 |
croak qq{Bind filter "$fname" is not registered} |
|
497 |
unless exists $filters->{$fname}; |
|
498 |
} |
|
499 |
|
|
500 |
# Default filter name not exists |
|
501 |
croak qq{Default bind filter "$default_filter" is not registered} |
|
502 |
if $default_filter && ! exists $filters->{$default_filter}; |
|
503 |
|
|
504 |
# Column name not exists |
|
505 |
foreach my $column (keys %$filter) { |
|
506 |
|
|
507 |
croak qq{Column name "$column" in bind filter is not found in paramters} |
|
508 |
unless exists $params->{$column}; |
|
509 |
} |
|
510 |
} |
|
511 | ||
cleanup
|
512 |
sub _croak { |
513 |
my ($self, $error, $append) = @_; |
|
514 |
$append ||= ""; |
|
515 |
|
|
516 |
# Verbose |
|
517 |
if ($Carp::Verbose) { croak $error } |
|
518 |
|
|
519 |
# Not verbose |
|
520 |
else { |
|
521 |
|
|
522 |
# Remove line and module infromation |
|
523 |
my $at_pos = rindex($error, ' at '); |
|
524 |
$error = substr($error, 0, $at_pos); |
|
525 |
$error =~ s/\s+$//; |
|
526 |
|
|
527 |
croak "$error$append"; |
|
528 |
} |
|
529 |
} |
|
530 | ||
fixed DBIx::Custom::QueryBui...
|
531 |
1; |
532 | ||
removed reconnect method
|
533 |
=head1 NAME |
534 | ||
renamed build_query to creat...
|
535 |
DBIx::Custom - DBI interface, having hash parameter binding and filtering system |
removed reconnect method
|
536 | |
537 |
=head1 SYNOPSYS |
|
cleanup
|
538 | |
renamed build_query to creat...
|
539 |
Connect to the database. |
540 |
|
|
541 |
use DBIx::Custom; |
|
renamed update tag to update...
|
542 |
my $dbi = DBIx::Custom->connect(data_source => "dbi:mysql:database=dbname", |
removed reconnect method
|
543 |
user => 'ken', password => '!LFKD%$&'); |
cleanup
|
544 | |
renamed build_query to creat...
|
545 |
Insert, update, and delete |
cleanup
|
546 | |
removed reconnect method
|
547 |
# Insert |
548 |
$dbi->insert(table => 'books', |
|
renamed update tag to update...
|
549 |
param => {title => 'Perl', author => 'Ken'}, |
removed reconnect method
|
550 |
filter => {title => 'encode_utf8'}); |
551 |
|
|
552 |
# Update |
|
553 |
$dbi->update(table => 'books', |
|
renamed update tag to update...
|
554 |
param => {title => 'Perl', author => 'Ken'}, |
removed reconnect method
|
555 |
where => {id => 5}, |
556 |
filter => {title => 'encode_utf8'}); |
|
557 |
|
|
558 |
# Update all |
|
559 |
$dbi->update_all(table => 'books', |
|
renamed update tag to update...
|
560 |
param => {title => 'Perl'}, |
removed reconnect method
|
561 |
filter => {title => 'encode_utf8'}); |
562 |
|
|
563 |
# Delete |
|
564 |
$dbi->delete(table => 'books', |
|
565 |
where => {author => 'Ken'}, |
|
566 |
filter => {title => 'encode_utf8'}); |
|
567 |
|
|
568 |
# Delete all |
|
569 |
$dbi->delete_all(table => 'books'); |
|
cleanup
|
570 | |
renamed build_query to creat...
|
571 |
Select |
cleanup
|
572 | |
removed reconnect method
|
573 |
# Select |
574 |
my $result = $dbi->select(table => 'books'); |
|
renamed fetch_rows to fetch_...
|
575 |
|
renamed build_query to creat...
|
576 |
# Select, more complex |
renamed fetch_rows to fetch_...
|
577 |
my $result = $dbi->select( |
update document
|
578 |
table => 'books', |
579 |
column => [qw/author title/], |
|
580 |
where => {author => 'Ken'}, |
|
updated document
|
581 |
append => 'order by id limit 5', |
renamed build_query to creat...
|
582 |
filter => {title => 'encode_utf8'} |
renamed fetch_rows to fetch_...
|
583 |
); |
added commit method
|
584 |
|
renamed build_query to creat...
|
585 |
# Select, join table |
added commit method
|
586 |
my $result = $dbi->select( |
renamed build_query to creat...
|
587 |
table => ['books', 'rental'], |
588 |
column => ['books.name as book_name'] |
|
added commit method
|
589 |
relation => {'books.id' => 'rental.book_id'} |
590 |
); |
|
updated document
|
591 |
|
592 |
# Select, more flexible where |
|
593 |
my $result = $dbi->select( |
|
594 |
table => 'books', |
|
595 |
where => ['{= author} and {like title}', |
|
596 |
{author => 'Ken', title => '%Perl%'}] |
|
597 |
); |
|
cleanup
|
598 | |
renamed build_query to creat...
|
599 |
Execute SQL |
cleanup
|
600 | |
renamed build_query to creat...
|
601 |
# Execute SQL |
removed register_format()
|
602 |
$dbi->execute("select title from books"); |
603 |
|
|
renamed build_query to creat...
|
604 |
# Execute SQL with hash binding and filtering |
updated document
|
605 |
$dbi->execute("select id from books where {= author} and {like title}", |
removed register_format()
|
606 |
param => {author => 'ken', title => '%Perl%'}, |
renamed build_query to creat...
|
607 |
filter => {title => 'encode_utf8'}); |
removed reconnect method
|
608 | |
609 |
# Create query and execute it |
|
renamed build_query to creat...
|
610 |
my $query = $dbi->create_query( |
updated document
|
611 |
"select id from books where {= author} and {like title}" |
removed reconnect method
|
612 |
); |
updated document
|
613 |
$dbi->execute($query, param => {author => 'Ken', title => '%Perl%'}) |
cleanup
|
614 | |
updated document
|
615 |
Other features. |
cleanup
|
616 | |
removed register_format()
|
617 |
# Default filter |
renamed default_query_filter...
|
618 |
$dbi->default_bind_filter('encode_utf8'); |
removed register_format()
|
619 |
$dbi->default_fetch_filter('decode_utf8'); |
cleanup
|
620 | |
621 |
# Get DBI object |
|
622 |
my $dbh = $dbi->dbh; |
|
623 | ||
624 |
Fetch row. |
|
625 | ||
removed register_format()
|
626 |
# Fetch |
627 |
while (my $row = $result->fetch) { |
|
628 |
# ... |
|
629 |
} |
|
630 |
|
|
631 |
# Fetch hash |
|
632 |
while (my $row = $result->fetch_hash) { |
|
633 |
|
|
634 |
} |
|
635 |
|
|
renamed update tag to update...
|
636 |
=head1 DESCRIPTIONS |
removed reconnect method
|
637 | |
renamed build_query to creat...
|
638 |
=head2 1. Features |
removed reconnect method
|
639 | |
renamed build_query to creat...
|
640 |
L<DBIx::Custom> is one of L<DBI> interface modules, |
641 |
such as L<DBIx::Class>, L<DBIx::Simple>. |
|
removed reconnect method
|
642 | |
renamed build_query to creat...
|
643 |
This module is not O/R mapper. O/R mapper is useful, |
644 |
but you must learn many syntax of the O/R mapper, |
|
updated document
|
645 |
which is almost another language. |
646 |
Created SQL statement is offten not effcient and damage SQL performance. |
|
renamed build_query to creat...
|
647 |
so you have to execute raw SQL in the end. |
removed reconnect method
|
648 | |
renamed build_query to creat...
|
649 |
L<DBIx::Custom> is middle area between L<DBI> and O/R mapper. |
updated document
|
650 |
L<DBIx::Custom> provide flexible hash parameter binding and filtering system, |
651 |
and suger methods, such as C<select()>, C<update()>, C<delete()>, C<select()> |
|
652 |
to execute SQL easily. |
|
removed reconnect method
|
653 | |
updated document
|
654 |
L<DBIx::Custom> respects SQL. SQL is very complex and not beautiful, |
655 |
but de-facto standard, |
|
656 |
so all people learing database know it. |
|
renamed update tag to update...
|
657 |
If you already know SQL, |
658 |
you learn a little thing to use L<DBIx::Custom>. |
|
removed reconnect method
|
659 | |
renamed update tag to update...
|
660 |
=head2 2. Connect to the database |
removed reconnect method
|
661 | |
renamed build_query to creat...
|
662 |
C<connect()> method create a new L<DBIx::Custom> |
663 |
object and connect to the database. |
|
removed reconnect method
|
664 | |
renamed build_query to creat...
|
665 |
use DBIx::Custom; |
renamed update tag to update...
|
666 |
my $dbi = DBIx::Custom->connect(data_source => "dbi:mysql:database=dbname", |
renamed build_query to creat...
|
667 |
user => 'ken', password => '!LFKD%$&'); |
668 | ||
renamed update tag to update...
|
669 |
If database is SQLite, use L<DBIx::Custom::SQLite> instead. |
670 |
you connect database easily. |
|
update document
|
671 | |
672 |
use DBIx::Custom::SQLite; |
|
renamed update tag to update...
|
673 |
my $dbi = DBIx::Custom::SQLite->connect(database => 'dbname'); |
update document
|
674 |
|
cleanup
|
675 |
If database is MySQL, use L<DBIx::Custom::MySQL>. |
update document
|
676 | |
677 |
use DBIx::Custom::MySQL; |
|
renamed update tag to update...
|
678 |
my $dbi = DBIx::Custom::MySQL->connect( |
679 |
database => 'dbname', |
|
680 |
user => 'ken', |
|
681 |
password => '!LFKD%$&' |
|
682 |
); |
|
update document
|
683 | |
renamed update tag to update...
|
684 |
=head2 3. Suger methods |
renamed build_query to creat...
|
685 | |
686 |
L<DBIx::Custom> has suger methods, such as C<insert()>, C<update()>, |
|
renamed update tag to update...
|
687 |
C<delete()> or C<select()>. If you want to do small works, |
updated document
|
688 |
You don't have to create SQL statements. |
renamed build_query to creat...
|
689 | |
update document
|
690 |
=head3 insert() |
691 | ||
updated document
|
692 |
Execute insert statement. |
693 | ||
update document
|
694 |
$dbi->insert(table => 'books', |
renamed update tag to update...
|
695 |
param => {title => 'Perl', author => 'Ken'}); |
update document
|
696 | |
697 |
The following SQL is executed. |
|
698 | ||
updated document
|
699 |
insert into (title, author) values (?, ?); |
update document
|
700 | |
renamed update tag to update...
|
701 |
The values of C<title> and C<author> is embedded into the placeholders. |
update document
|
702 | |
renamed update tag to update...
|
703 |
C<append> and C<filter> argument can be specified. |
704 |
See also "METHODS" section. |
|
update document
|
705 | |
706 |
=head3 update() |
|
707 | ||
updated document
|
708 |
Execute update statement. |
709 | ||
update document
|
710 |
$dbi->update(table => 'books', |
renamed update tag to update...
|
711 |
param => {title => 'Perl', author => 'Ken'}, |
update document
|
712 |
where => {id => 5}); |
713 | ||
714 |
The following SQL is executed. |
|
715 | ||
716 |
update books set title = ?, author = ?; |
|
717 | ||
renamed update tag to update...
|
718 |
The values of C<title> and C<author> is embedded into the placeholders. |
update document
|
719 | |
renamed update tag to update...
|
720 |
C<append> and C<filter> argument can be specified. |
721 |
See also "METHOD" section. |
|
update document
|
722 | |
renamed update tag to update...
|
723 |
If you want to update all rows, use C<update_all()> method. |
update document
|
724 | |
725 |
=head3 delete() |
|
726 | ||
updated document
|
727 |
Execute delete statement. |
728 | ||
update document
|
729 |
$dbi->delete(table => 'books', |
730 |
where => {author => 'Ken'}); |
|
731 | ||
732 |
The following SQL is executed. |
|
733 | ||
734 |
delete from books where id = ?; |
|
735 | ||
updated document
|
736 |
The value of C<id> is embedded into the placehodler. |
update document
|
737 | |
renamed update tag to update...
|
738 |
C<append> and C<filter> argument can be specified. |
739 |
see also "METHODS" section. |
|
update document
|
740 | |
renamed update tag to update...
|
741 |
If you want to delete all rows, use C<delete_all()> method. |
update document
|
742 | |
743 |
=head3 select() |
|
744 | ||
updated document
|
745 |
Execute select statement, only C<table> argument specified : |
update document
|
746 | |
747 |
my $result = $dbi->select(table => 'books'); |
|
748 | ||
749 |
The following SQL is executed. |
|
750 | ||
751 |
select * from books; |
|
752 | ||
753 |
the result of C<select()> method is L<DBIx::Custom::Result> object. |
|
renamed update tag to update...
|
754 |
You can fetch a row by C<fetch()> method. |
update document
|
755 | |
756 |
while (my $row = $result->fetch) { |
|
757 |
my $title = $row->[0]; |
|
758 |
my $author = $row->[1]; |
|
759 |
} |
|
760 | ||
761 |
L<DBIx::Custom::Result> has various methods to fetch row. |
|
renamed update tag to update...
|
762 |
See "4. Fetch row". |
update document
|
763 | |
renamed update tag to update...
|
764 |
C<column> and C<where> arguments specified. |
update document
|
765 | |
766 |
my $result = $dbi->select( |
|
767 |
table => 'books', |
|
768 |
column => [qw/author title/], |
|
renamed update tag to update...
|
769 |
where => {author => 'Ken'} |
770 |
); |
|
update document
|
771 | |
772 |
The following SQL is executed. |
|
773 | ||
774 |
select author, title from books where author = ?; |
|
775 | ||
renamed update tag to update...
|
776 |
the value of C<author> is embdded into the placeholder. |
update document
|
777 | |
updated document
|
778 |
If you want to join tables, specify C<relation> argument. |
update document
|
779 | |
780 |
my $result = $dbi->select( |
|
781 |
table => ['books', 'rental'], |
|
782 |
column => ['books.name as book_name'] |
|
783 |
relation => {'books.id' => 'rental.book_id'} |
|
784 |
); |
|
785 | ||
786 |
The following SQL is executed. |
|
787 | ||
renamed update tag to update...
|
788 |
select books.name as book_name from books, rental |
update document
|
789 |
where books.id = rental.book_id; |
790 | ||
renamed update tag to update...
|
791 |
If you want to add some string to the end of SQL statement, |
792 |
use C<append> argument. |
|
update document
|
793 | |
794 |
my $result = $dbi->select( |
|
795 |
table => 'books', |
|
796 |
where => {author => 'Ken'}, |
|
797 |
append => 'order by price limit 5', |
|
798 |
); |
|
799 | ||
800 |
The following SQL is executed. |
|
801 | ||
802 |
select * books where author = ? order by price limit 5; |
|
803 | ||
renamed update tag to update...
|
804 |
C<filter> argument can be specified. |
805 |
see also "METHODS" section. |
|
update document
|
806 | |
renamed update tag to update...
|
807 |
=head2 4. Fetch row |
update document
|
808 | |
updated document
|
809 |
C<select()> method return L<DBIx::Custom::Result> object. |
810 |
You can fetch row by various methods. |
|
renamed update tag to update...
|
811 |
Note that in this section, array means array reference, |
812 |
and hash meanse hash reference. |
|
update document
|
813 | |
814 |
Fetch row into array. |
|
815 |
|
|
816 |
while (my $row = $result->fetch) { |
|
817 |
my $author = $row->[0]; |
|
818 |
my $title = $row->[1]; |
|
819 |
|
|
820 |
} |
|
821 | ||
822 |
Fetch only a first row into array. |
|
823 | ||
824 |
my $row = $result->fetch_first; |
|
825 | ||
826 |
Fetch multiple rows into array of array. |
|
827 | ||
828 |
while (my $rows = $result->fetch_multi(5)) { |
|
829 |
my $first_author = $rows->[0][0]; |
|
830 |
my $first_title = $rows->[0][1]; |
|
831 |
my $second_author = $rows->[1][0]; |
|
832 |
my $second_value = $rows->[1][1]; |
|
833 |
|
|
834 |
} |
|
835 |
|
|
836 |
Fetch all rows into array of array. |
|
837 | ||
838 |
my $rows = $result->fetch_all; |
|
839 | ||
840 |
Fetch row into hash. |
|
841 | ||
842 |
# Fetch a row into hash |
|
843 |
while (my $row = $result->fetch_hash) { |
|
844 |
my $title = $row->{title}; |
|
845 |
my $author = $row->{author}; |
|
846 |
|
|
847 |
} |
|
848 | ||
849 |
Fetch only a first row into hash |
|
850 | ||
851 |
my $row = $result->fetch_hash_first; |
|
852 |
|
|
853 |
Fetch multiple rows into array of hash |
|
854 | ||
855 |
while (my $rows = $result->fetch_hash_multi(5)) { |
|
856 |
my $first_title = $rows->[0]{title}; |
|
857 |
my $first_author = $rows->[0]{author}; |
|
858 |
my $second_title = $rows->[1]{title}; |
|
859 |
my $second_author = $rows->[1]{author}; |
|
860 |
|
|
861 |
} |
|
862 |
|
|
863 |
Fetch all rows into array of hash |
|
864 | ||
865 |
my $rows = $result->fetch_hash_all; |
|
removed DESTROY method(not b...
|
866 | |
cleanup
|
867 |
If you want to access statement handle of L<DBI>, use C<sth> attribute. |
removed DESTROY method(not b...
|
868 | |
update document
|
869 |
my $sth = $result->sth; |
removed DESTROY method(not b...
|
870 | |
renamed update tag to update...
|
871 |
=head2 5. Hash parameter binding |
removed reconnect method
|
872 | |
update document
|
873 |
L<DBIx::Custom> provides hash parameter binding. |
874 | ||
renamed update tag to update...
|
875 |
At frist, I show normal parameter binding. |
update document
|
876 | |
877 |
use DBI; |
|
878 |
my $dbh = DBI->connect(...); |
|
879 |
my $sth = $dbh->prepare( |
|
880 |
"select * from books where author = ? and title like ?;" |
|
881 |
); |
|
882 |
$sth->execute('Ken', '%Perl%'); |
|
883 | ||
updated document
|
884 |
This is very good way because database system can enable SQL caching, |
renamed update tag to update...
|
885 |
and parameter is quoted automatically. this is secure. |
update document
|
886 | |
updated document
|
887 |
L<DBIx::Custom> hash parameter binding system improve |
renamed update tag to update...
|
888 |
normal parameter binding to use hash parameter. |
update document
|
889 | |
890 |
my $result = $dbi->execute( |
|
891 |
"select * from books where {= author} and {like title};" |
|
892 |
param => {author => 'Ken', title => '%Perl%'} |
|
893 |
); |
|
894 | ||
895 |
This is same as the normal way, execpt that the parameter is hash. |
|
renamed update tag to update...
|
896 |
{= author} and {like title} is called C<tag>. |
897 |
tag is expand to placeholder string internally. |
|
update document
|
898 | |
899 |
select * from books where {= author} and {like title} |
|
900 |
-> select * from books where author = ? and title like ?; |
|
901 | ||
updated document
|
902 |
The following tags is available. |
903 | ||
904 |
[TAG] [REPLACED] |
|
905 |
{? NAME} -> ? |
|
906 |
{= NAME} -> NAME = ? |
|
907 |
{<> NAME} -> NAME <> ? |
|
908 |
|
|
909 |
{< NAME} -> NAME < ? |
|
910 |
{> NAME} -> NAME > ? |
|
911 |
{>= NAME} -> NAME >= ? |
|
912 |
{<= NAME} -> NAME <= ? |
|
913 |
|
|
914 |
{like NAME} -> NAME like ? |
|
915 |
{in NAME COUNT} -> NAME in [?, ?, ..] |
|
916 |
|
|
renamed update tag to update...
|
917 |
{insert_param NAME1 NAME2} -> (NAME1, NAME2) values (?, ?) |
918 |
{update_param NAME1 NAME2} -> set NAME1 = ?, NAME2 = ? |
|
updated document
|
919 | |
920 |
See also L<DBIx::Custom::QueryBuilder>. |
|
921 | ||
removed DBIx::Custom::Query ...
|
922 |
C<{> and C<}> is reserved. If you use these charactors, |
923 |
you must escape them using '\'. Note that '\' is |
|
924 |
already perl escaped charactor, so you must write '\\'. |
|
updated document
|
925 | |
removed DBIx::Custom::Query ...
|
926 |
'select * from books \\{ something statement \\}' |
update document
|
927 | |
renamed update tag to update...
|
928 |
=head2 6. Filtering |
update document
|
929 | |
930 |
Usually, Perl string is kept as internal string. |
|
931 |
If you want to save the string to database, You must encode the string. |
|
932 |
Filtering system help you to convert a data to another data |
|
933 |
when you save to the data and get the data form database. |
|
934 | ||
updated document
|
935 |
If you want to register filter, use C<register_filter()> method. |
update document
|
936 | |
937 |
$dbi->register_filter( |
|
938 |
to_upper_case => sub { |
|
939 |
my $value = shift; |
|
940 |
return uc $value; |
|
941 |
} |
|
942 |
); |
|
943 | ||
944 |
C<encode_utf8> and C<decode_utf8> filter is registerd by default. |
|
945 | ||
946 |
You can specify these filters to C<filter> argument of C<execute()> method. |
|
947 | ||
948 |
my $result = $dbi->execute( |
|
949 |
"select * from books where {= author} and {like title};" |
|
updated document
|
950 |
param => {author => 'Ken', title => '%Perl%'}, |
update document
|
951 |
filter => {author => 'to_upper_case, title => 'encode_utf8'} |
952 |
); |
|
953 | ||
renamed update tag to update...
|
954 |
C<filter> argument can be specified to suger methods, such as |
cleanup
|
955 |
C<insert()>, C<update()>, C<update_all()>, |
renamed update tag to update...
|
956 |
C<delete()>, C<delete_all()>, C<select()>. |
update document
|
957 | |
renamed update tag to update...
|
958 |
# insert(), having filter argument |
update document
|
959 |
$dbi->insert(table => 'books', |
renamed update tag to update...
|
960 |
param => {title => 'Perl', author => 'Ken'}, |
update document
|
961 |
filter => {title => 'encode_utf8'}); |
renamed update tag to update...
|
962 |
|
963 |
# select(), having filter argument |
|
update document
|
964 |
my $result = $dbi->select( |
965 |
table => 'books', |
|
966 |
column => [qw/author title/], |
|
967 |
where => {author => 'Ken'}, |
|
968 |
append => 'order by id limit 1', |
|
969 |
filter => {title => 'encode_utf8'} |
|
970 |
); |
|
971 | ||
updated document
|
972 |
Filter works each parmeter, but you prepare default filter for all parameters. |
update document
|
973 | |
974 |
$dbi->default_bind_filter('encode_utf8'); |
|
975 | ||
renamed update tag to update...
|
976 |
C<filter()> argument overwrites this default filter. |
update document
|
977 |
|
978 |
$dbi->default_bind_filter('encode_utf8'); |
|
979 |
$dbi->insert( |
|
980 |
table => 'books', |
|
renamed update tag to update...
|
981 |
param => {title => 'Perl', author => 'Ken', price => 1000}, |
update document
|
982 |
filter => {author => 'to_upper_case', price => undef} |
983 |
); |
|
984 | ||
renamed update tag to update...
|
985 |
This is same as the following example. |
update document
|
986 | |
987 |
$dbi->insert( |
|
988 |
table => 'books', |
|
renamed update tag to update...
|
989 |
param => {title => 'Perl', author => 'Ken', price => 1000}, |
update document
|
990 |
filter => {title => 'encode_uft8' author => 'to_upper_case'} |
991 |
); |
|
992 | ||
updated document
|
993 |
You can also specify filter when the row is fetched. This is reverse of bind filter. |
update document
|
994 | |
995 |
my $result = $dbi->select(table => 'books'); |
|
996 |
$result->filter({title => 'decode_utf8', author => 'to_upper_case'}); |
|
997 | ||
renamed update tag to update...
|
998 |
Filter works each column value, but you prepare a default filter |
999 |
for all clumn value. |
|
update document
|
1000 | |
1001 |
$dbi->default_fetch_filter('decode_utf8'); |
|
1002 | ||
renamed update tag to update...
|
1003 |
C<filter()> method of L<DBIx::Custom::Result> |
1004 |
overwrites this default filter. |
|
update document
|
1005 | |
1006 |
$dbi->default_fetch_filter('decode_utf8'); |
|
1007 |
my $result = $dbi->select( |
|
1008 |
table => 'books', |
|
1009 |
columns => ['title', 'author', 'price'] |
|
1010 |
); |
|
1011 |
$result->filter({author => 'to_upper_case', price => undef}); |
|
1012 | ||
1013 |
This is same as the following one. |
|
1014 | ||
1015 |
my $result = $dbi->select( |
|
1016 |
table => 'books', |
|
1017 |
columns => ['title', 'author', 'price'] |
|
1018 |
); |
|
1019 |
$result->filter({title => 'decode_utf8', author => 'to_upper_case'}); |
|
removed reconnect method
|
1020 | |
renamed update tag to update...
|
1021 |
Note that in fetch filter, column names must be lower case |
1022 |
even if the column name conatains upper case charactors. |
|
1023 |
This is requirment not to depend database systems. |
|
added check_filter attribute
|
1024 | |
cleanup
|
1025 |
=head2 7. Get high performance |
updated document
|
1026 | |
updated document
|
1027 |
=head3 Disable filter checking |
1028 | ||
renamed update tag to update...
|
1029 |
Filter checking is executed by default. |
1030 |
This is done to check right filter name is specified, |
|
1031 |
but sometimes damage performance. |
|
updated document
|
1032 | |
renamed update tag to update...
|
1033 |
If you disable this filter checking, |
1034 |
Set C<filter_check> attribute to 0. |
|
updated document
|
1035 | |
renamed update tag to update...
|
1036 |
$dbi->filter_check(0); |
updated document
|
1037 | |
renamed update tag to update...
|
1038 |
=head3 Use execute() method instead suger methods |
1039 | ||
1040 |
If you execute insert statement by C<insert()> method, |
|
1041 |
you sometimes can't get required performance. |
|
updated document
|
1042 | |
1043 |
C<insert()> method is a little slow because SQL statement and statement handle |
|
1044 |
is created every time. |
|
1045 | ||
1046 |
In that case, you can prepare a query by C<create_query()> method. |
|
1047 |
|
|
1048 |
my $query = $dbi->create_query( |
|
renamed update tag to update...
|
1049 |
"insert into books {insert_param title author};" |
updated document
|
1050 |
); |
cleanup
|
1051 | |
1052 |
Return value of C<create_query()> is L<DBIx::Custom::Query> object. |
|
1053 |
This keep the information of SQL and column names. |
|
1054 | ||
1055 |
{ |
|
1056 |
sql => 'insert into books (title, author) values (?, ?);', |
|
1057 |
columns => ['title', 'author'] |
|
1058 |
} |
|
1059 | ||
1060 |
Execute query repeatedly. |
|
updated document
|
1061 |
|
1062 |
my $inputs = [ |
|
1063 |
{title => 'Perl', author => 'Ken'}, |
|
1064 |
{title => 'Good days', author => 'Mike'} |
|
1065 |
]; |
|
1066 |
|
|
1067 |
foreach my $input (@$inputs) { |
|
1068 |
$dbi->execute($query, $input); |
|
1069 |
} |
|
1070 | ||
cleanup
|
1071 |
This is faster than C<insert()> method. |
updated document
|
1072 | |
cleanup
|
1073 |
=head3 caching |
updated document
|
1074 | |
cleanup
|
1075 |
C<execute()> method caches the parsed result of the source of SQL. |
updated document
|
1076 |
Default to 1 |
1077 | ||
1078 |
$dbi->cache(1); |
|
1079 | ||
1080 |
Caching is on memory, but you can change this by C<cache_method()>. |
|
1081 |
First argument is L<DBIx::Custom> object. |
|
cleanup
|
1082 |
Second argument is a source of SQL, |
1083 |
such as "select * from books where {= title} and {= author};"; |
|
updated document
|
1084 |
Third argument is parsed result, such as |
1085 |
{sql => "select * from books where title = ? and author = ?", |
|
1086 |
columns => ['title', 'author']}, this is hash reference. |
|
cleanup
|
1087 |
If arguments is more than two, this method is called to set cache. |
1088 |
If not, this method is called to get cache. |
|
updated document
|
1089 | |
cleanup
|
1090 |
$dbi->cache_method(sub { |
updated document
|
1091 |
sub { |
1092 |
my $self = shift; |
|
1093 |
|
|
1094 |
$self->{_cached} ||= {}; |
|
1095 |
|
|
1096 |
# Set cache |
|
1097 |
if (@_ > 1) { |
|
1098 |
$self->{_cached}{$_[0]} = $_[1] |
|
1099 |
} |
|
1100 |
|
|
1101 |
# Get cache |
|
1102 |
else { |
|
1103 |
return $self->{_cached}{$_[0]} |
|
1104 |
} |
|
1105 |
} |
|
1106 |
}); |
|
1107 | ||
renamed update tag to update...
|
1108 |
=head2 8. More features |
updated document
|
1109 | |
1110 |
=head3 Get DBI object |
|
1111 | ||
1112 |
You can get L<DBI> object and call any method of L<DBI>. |
|
1113 | ||
1114 |
$dbi->dbh->begin_work; |
|
1115 |
$dbi->dbh->commit; |
|
1116 |
$dbi->dbh->rollback; |
|
1117 | ||
1118 |
=head3 Change Result class |
|
1119 | ||
1120 |
You can change Result class if you need. |
|
1121 | ||
1122 |
package Your::Result; |
|
1123 |
use base 'DBIx::Custom::Result'; |
|
1124 |
|
|
1125 |
sub some_method { ... } |
|
1126 | ||
1127 |
1; |
|
1128 |
|
|
1129 |
package main; |
|
1130 |
|
|
1131 |
use Your::Result; |
|
1132 |
|
|
1133 |
my $dbi = DBIx::Custom->connect(...); |
|
1134 |
$dbi->result_class('Your::Result'); |
|
1135 | ||
1136 |
=head3 Custamize SQL builder object |
|
1137 | ||
1138 |
You can custamize SQL builder object |
|
1139 | ||
1140 |
my $dbi = DBIx::Custom->connect(...); |
|
1141 |
$dbi->query_builder->register_tag_processor( |
|
1142 |
name => sub { |
|
1143 |
... |
|
1144 |
} |
|
1145 |
); |
|
1146 | ||
update document
|
1147 |
=head1 ATTRIBUTES |
packaging one directory
|
1148 | |
cleanup
|
1149 |
=head2 C<cache> |
packaging one directory
|
1150 | |
cleanup
|
1151 |
my $cache = $dbi->cache; |
1152 |
$dbi = $dbi->cache(1); |
|
removed DESTROY method(not b...
|
1153 | |
cleanup
|
1154 |
Enable parsed L<DBIx::Custom::Query> object caching. |
1155 |
Default to 1. |
|
packaging one directory
|
1156 | |
cleanup
|
1157 |
=head2 C<cache_method> |
packaging one directory
|
1158 | |
cleanup
|
1159 |
$dbi = $dbi->cache_method(\&cache_method); |
1160 |
$cache_method = $dbi->cache_method |
|
1161 | ||
1162 |
Method to set and get caches. |
|
1163 | ||
1164 |
B<Example:> |
|
1165 | ||
1166 |
$dbi->cache_method( |
|
1167 |
sub { |
|
1168 |
my $self = shift; |
|
1169 |
|
|
1170 |
$self->{_cached} ||= {}; |
|
1171 |
|
|
1172 |
if (@_ > 1) { |
|
1173 |
$self->{_cached}{$_[0]} = $_[1] |
|
1174 |
} |
|
1175 |
else { |
|
1176 |
return $self->{_cached}{$_[0]} |
|
1177 |
} |
|
1178 |
} |
|
1179 |
); |
|
removed DESTROY method(not b...
|
1180 | |
removed DBIx::Custom commit ...
|
1181 |
=head2 C<data_source> |
packaging one directory
|
1182 | |
cleanup
|
1183 |
my $data_source = $dbi->data_source; |
cleanup
|
1184 |
$dbi = $dbi->data_source("DBI:mysql:database=dbname"); |
removed DESTROY method(not b...
|
1185 | |
cleanup
|
1186 |
Data source. |
1187 |
C<connect()> method use this value to connect the database. |
|
removed DESTROY method(not b...
|
1188 | |
removed DBIx::Custom commit ...
|
1189 |
=head2 C<dbh> |
packaging one directory
|
1190 | |
cleanup
|
1191 |
my $dbh = $dbi->dbh; |
1192 |
$dbi = $dbi->dbh($dbh); |
|
packaging one directory
|
1193 | |
cleanup
|
1194 |
L<DBI> object. You can call all methods of L<DBI>. |
packaging one directory
|
1195 | |
renamed default_query_filter...
|
1196 |
=head2 C<default_bind_filter> |
packaging one directory
|
1197 | |
cleanup
|
1198 |
my $default_bind_filter = $dbi->default_bind_filter |
1199 |
$dbi = $dbi->default_bind_filter('encode_utf8'); |
|
packaging one directory
|
1200 | |
cleanup
|
1201 |
Default filter when parameter binding is executed. |
packaging one directory
|
1202 | |
removed DESTROY method(not b...
|
1203 |
=head2 C<default_fetch_filter> |
bind_filter argument is chan...
|
1204 | |
cleanup
|
1205 |
my $default_fetch_filter = $dbi->default_fetch_filter; |
1206 |
$dbi = $dbi->default_fetch_filter('decode_utf8'); |
|
bind_filter argument is chan...
|
1207 | |
cleanup
|
1208 |
Default filter when row is fetched. |
packaging one directory
|
1209 | |
cleanup
|
1210 |
=head2 C<filters> |
bind_filter argument is chan...
|
1211 | |
cleanup
|
1212 |
my $filters = $dbi->filters; |
1213 |
$dbi = $dbi->filters(\%filters); |
|
packaging one directory
|
1214 | |
cleanup
|
1215 |
Filter functions. |
1216 |
"encode_utf8" and "decode_utf8" is registered by default. |
|
1217 | ||
1218 |
=head2 C<filter_check> |
|
1219 | ||
1220 |
my $filter_check = $dbi->filter_check; |
|
1221 |
$dbi = $dbi->filter_check(0); |
|
1222 | ||
1223 |
Enable filter check. |
|
1224 |
Default to 1. |
|
1225 |
This check maybe damege performance. |
|
1226 |
If you require performance, set C<filter_check> attribute to 0. |
|
1227 | ||
1228 |
=head2 C<password> |
|
1229 | ||
1230 |
my $password = $dbi->password; |
|
1231 |
$dbi = $dbi->password('lkj&le`@s'); |
|
1232 | ||
1233 |
Password. |
|
1234 |
C<connect()> method use this value to connect the database. |
|
update document
|
1235 | |
renamed update tag to update...
|
1236 |
=head2 C<query_builder> |
added commit method
|
1237 | |
renamed update tag to update...
|
1238 |
my $sql_class = $dbi->query_builder; |
1239 |
$dbi = $dbi->query_builder(DBIx::Custom::QueryBuilder->new); |
|
added commit method
|
1240 | |
renamed update tag to update...
|
1241 |
SQL builder. C<query_builder()> must be |
renamed build_query to creat...
|
1242 |
the instance of L<DBIx::Custom::QueryBuilder> subclass. |
1243 |
Default to L<DBIx::Custom::QueryBuilder> object. |
|
cleanup
|
1244 | |
cleanup
|
1245 |
=head2 C<result_class> |
cleanup
|
1246 | |
cleanup
|
1247 |
my $result_class = $dbi->result_class; |
1248 |
$dbi = $dbi->result_class('DBIx::Custom::Result'); |
|
cleanup
|
1249 | |
cleanup
|
1250 |
Result class for select statement. |
1251 |
Default to L<DBIx::Custom::Result>. |
|
cleanup
|
1252 | |
cleanup
|
1253 |
=head2 C<user> |
cleanup
|
1254 | |
cleanup
|
1255 |
my $user = $dbi->user; |
1256 |
$dbi = $dbi->user('Ken'); |
|
cleanup
|
1257 | |
cleanup
|
1258 |
User name. |
1259 |
C<connect()> method use this value to connect the database. |
|
1260 |
|
|
1261 |
=head1 METHODS |
|
added commit method
|
1262 | |
cleanup
|
1263 |
L<DBIx::Custom> inherits all methods from L<Object::Simple> |
1264 |
and implements the following new ones. |
|
added check_filter attribute
|
1265 | |
cleanup
|
1266 |
=head2 begin_work |
added check_filter attribute
|
1267 | |
cleanup
|
1268 |
$dbi->begin_work; |
added check_filter attribute
|
1269 | |
cleanup
|
1270 |
Start transaction. |
1271 |
This is same as L<DBI>'s C<begin_work>. |
|
added commit method
|
1272 | |
cleanup
|
1273 |
L<DBIx::Custom> inherits all methods from L<Object::Simple> |
1274 |
and implements the following new ones. |
|
added commit method
|
1275 | |
cleanup
|
1276 |
=head2 commit |
1277 | ||
1278 |
$dbi->commit; |
|
1279 | ||
1280 |
Commit transaction. |
|
1281 |
This is same as L<DBI>'s C<commit>. |
|
1282 | ||
removed DBIx::Custom commit ...
|
1283 |
=head2 C<connect> |
packaging one directory
|
1284 | |
cleanup
|
1285 |
my $dbi = DBIx::Custom->connect(data_source => "dbi:mysql:database=dbname", |
update document
|
1286 |
user => 'ken', password => '!LFKD%$&'); |
bind_filter argument is chan...
|
1287 | |
cleanup
|
1288 |
Create a new L<DBIx::Custom> object and connect to the database. |
renamed build_query to creat...
|
1289 |
L<DBIx::Custom> is a wrapper of L<DBI>. |
cleanup
|
1290 |
C<AutoCommit> and C<RaiseError> options are true, |
renamed build_query to creat...
|
1291 |
and C<PrintError> option is false by default. |
packaging one directory
|
1292 | |
cleanup
|
1293 |
=head2 C<create_query> |
1294 |
|
|
1295 |
my $query = $dbi->create_query( |
|
1296 |
"select * from books where {= author} and {like title};" |
|
1297 |
); |
|
update document
|
1298 | |
cleanup
|
1299 |
Create the instance of L<DBIx::Custom::Query> from the source of SQL. |
1300 |
If you want to get high performance, |
|
1301 |
use C<create_query()> method and execute it by C<execute()> method |
|
1302 |
instead of suger methods. |
|
bind_filter argument is chan...
|
1303 | |
cleanup
|
1304 |
$dbi->execute($query, {author => 'Ken', title => '%Perl%'}); |
version 0.0901
|
1305 | |
cleanup
|
1306 |
=head2 C<execute> |
packaging one directory
|
1307 | |
cleanup
|
1308 |
my $result = $dbi->execute($query, param => $params, filter => \%filter); |
1309 |
my $result = $dbi->execute($source, param => $params, filter => \%filter); |
|
update document
|
1310 | |
cleanup
|
1311 |
Execute query or the source of SQL. |
1312 |
Query is L<DBIx::Custom::Query> object. |
|
1313 |
Return value is L<DBIx::Custom::Result> if select statement is executed, |
|
1314 |
or the count of affected rows if insert, update, delete statement is executed. |
|
version 0.0901
|
1315 | |
removed DESTROY method(not b...
|
1316 |
B<Example:> |
update document
|
1317 | |
cleanup
|
1318 |
my $result = $dbi->execute( |
1319 |
"select * from books where {= author} and {like title}", |
|
1320 |
param => {author => 'Ken', title => '%Perl%'} |
|
1321 |
); |
|
1322 |
|
|
1323 |
while (my $row = $result->fetch) { |
|
1324 |
my $author = $row->[0]; |
|
1325 |
my $title = $row->[1]; |
|
1326 |
} |
|
packaging one directory
|
1327 | |
removed DBIx::Custom commit ...
|
1328 |
=head2 C<delete> |
packaging one directory
|
1329 | |
cleanup
|
1330 |
$dbi->delete(table => $table, |
1331 |
where => \%where, |
|
1332 |
append => $append, |
|
1333 |
filter => \%filter); |
|
bind_filter argument is chan...
|
1334 | |
renamed build_query to creat...
|
1335 |
Execute delete statement. |
1336 |
C<delete> method have C<table>, C<where>, C<append>, and C<filter> arguments. |
|
1337 |
C<table> is a table name. |
|
1338 |
C<where> is where clause. this must be hash reference. |
|
1339 |
C<append> is a string added at the end of the SQL statement. |
|
1340 |
C<filter> is filters when parameter binding is executed. |
|
cleanup
|
1341 |
Return value of C<delete()> is the count of affected rows. |
renamed build_query to creat...
|
1342 | |
removed DESTROY method(not b...
|
1343 |
B<Example:> |
packaging one directory
|
1344 | |
removed register_format()
|
1345 |
$dbi->delete(table => 'books', |
1346 |
where => {id => 5}, |
|
1347 |
append => 'some statement', |
|
removed reconnect method
|
1348 |
filter => {id => 'encode_utf8'}); |
version 0.0901
|
1349 | |
removed DBIx::Custom commit ...
|
1350 |
=head2 C<delete_all> |
packaging one directory
|
1351 | |
cleanup
|
1352 |
$dbi->delete_all(table => $table); |
packaging one directory
|
1353 | |
renamed build_query to creat...
|
1354 |
Execute delete statement to delete all rows. |
1355 |
Arguments is same as C<delete> method, |
|
1356 |
except that C<delete_all> don't have C<where> argument. |
|
cleanup
|
1357 |
Return value of C<delete_all()> is the count of affected rows. |
bind_filter argument is chan...
|
1358 | |
removed DESTROY method(not b...
|
1359 |
B<Example:> |
removed register_format()
|
1360 |
|
removed reconnect method
|
1361 |
$dbi->delete_all(table => 'books'); |
packaging one directory
|
1362 | |
added helper method
|
1363 |
=head2 C<(experimental) helper> |
1364 | ||
1365 |
$dbi->helper( |
|
1366 |
update_or_insert => sub { |
|
1367 |
my $self = shift; |
|
1368 |
# do something |
|
1369 |
}, |
|
1370 |
find_or_create => sub { |
|
1371 |
my $self = shift; |
|
1372 |
# do something |
|
1373 |
} |
|
1374 |
); |
|
1375 | ||
1376 |
Register helper methods. These method is called from L<DBIx::Custom> object directory. |
|
1377 | ||
1378 |
$dbi->update_or_insert; |
|
1379 |
$dbi->find_or_create; |
|
1380 | ||
cleanup
|
1381 |
=head2 C<insert> |
1382 | ||
1383 |
$dbi->insert(table => $table, |
|
1384 |
param => \%param, |
|
1385 |
append => $append, |
|
1386 |
filter => \%filter); |
|
1387 | ||
1388 |
Execute insert statement. |
|
1389 |
C<insert> method have C<table>, C<param>, C<append> |
|
1390 |
and C<filter> arguments. |
|
1391 |
C<table> is a table name. |
|
1392 |
C<param> is the pairs of column name value. this must be hash reference. |
|
1393 |
C<append> is a string added at the end of the SQL statement. |
|
1394 |
C<filter> is filters when parameter binding is executed. |
|
1395 |
This is overwrites C<default_bind_filter>. |
|
1396 |
Return value of C<insert()> is the count of affected rows. |
|
1397 | ||
1398 |
B<Example:> |
|
1399 | ||
1400 |
$dbi->insert(table => 'books', |
|
1401 |
param => {title => 'Perl', author => 'Taro'}, |
|
1402 |
append => "some statement", |
|
1403 |
filter => {title => 'encode_utf8'}) |
|
1404 | ||
1405 |
=head2 C<register_filter> |
|
1406 | ||
1407 |
$dbi->register_filter(%filters); |
|
1408 |
$dbi->register_filter(\%filters); |
|
1409 |
|
|
1410 |
Register filter. Registered filters is available in the following attributes |
|
1411 |
or arguments. |
|
1412 | ||
1413 |
=over 4 |
|
1414 | ||
1415 |
=item * |
|
1416 | ||
1417 |
C<default_bind_filter>, C<default_fetch_filter> |
|
1418 | ||
1419 |
=item * |
|
1420 | ||
1421 |
C<filter> argument of C<insert()>, C<update()>, |
|
1422 |
C<update_all()>, C<delete()>, C<delete_all()>, C<select()> |
|
1423 |
methods |
|
1424 | ||
1425 |
=item * |
|
1426 | ||
1427 |
C<execute()> method |
|
1428 | ||
1429 |
=item * |
|
1430 | ||
1431 |
C<default_filter> and C<filter> of C<DBIx::Custom::Query> |
|
1432 | ||
1433 |
=item * |
|
1434 | ||
1435 |
C<default_filter> and C<filter> of C<DBIx::Custom::Result> |
|
1436 | ||
1437 |
=back |
|
1438 | ||
1439 |
B<Example:> |
|
1440 | ||
1441 |
$dbi->register_filter( |
|
1442 |
encode_utf8 => sub { |
|
1443 |
my $value = shift; |
|
1444 |
|
|
1445 |
require Encode; |
|
1446 |
|
|
1447 |
return Encode::encode('UTF-8', $value); |
|
1448 |
}, |
|
1449 |
decode_utf8 => sub { |
|
1450 |
my $value = shift; |
|
1451 |
|
|
1452 |
require Encode; |
|
1453 |
|
|
1454 |
return Encode::decode('UTF-8', $value) |
|
1455 |
} |
|
1456 |
); |
|
1457 | ||
1458 |
=head2 rollback |
|
1459 | ||
1460 |
$dbi->rollback; |
|
1461 | ||
1462 |
Rollback transaction. |
|
1463 |
This is same as L<DBI>'s C<rollback>. |
|
1464 | ||
removed DBIx::Custom commit ...
|
1465 |
=head2 C<select> |
packaging one directory
|
1466 |
|
cleanup
|
1467 |
my $result = $dbi->select(table => $table, |
1468 |
column => [@column], |
|
1469 |
where => \%where, |
|
1470 |
append => $append, |
|
1471 |
relation => \%relation, |
|
1472 |
filter => \%filter); |
|
update document
|
1473 | |
renamed build_query to creat...
|
1474 |
Execute select statement. |
cleanup
|
1475 |
C<select> method have C<table>, C<column>, C<where>, C<append>, |
renamed build_query to creat...
|
1476 |
C<relation> and C<filter> arguments. |
1477 |
C<table> is a table name. |
|
cleanup
|
1478 |
C<where> is where clause. this is normally hash reference. |
renamed build_query to creat...
|
1479 |
C<append> is a string added at the end of the SQL statement. |
1480 |
C<filter> is filters when parameter binding is executed. |
|
update document
|
1481 | |
removed DESTROY method(not b...
|
1482 |
B<Example:> |
update document
|
1483 | |
added commit method
|
1484 |
# select * from books; |
cleanup
|
1485 |
my $result = $dbi->select(table => 'books'); |
packaging one directory
|
1486 |
|
renamed build_query to creat...
|
1487 |
# select * from books where title = ?; |
1488 |
my $result = $dbi->select(table => 'books', where => {title => 'Perl'}); |
|
update document
|
1489 |
|
renamed build_query to creat...
|
1490 |
# select title, author from books where id = ? for update; |
cleanup
|
1491 |
my $result = $dbi->select( |
removed register_format()
|
1492 |
table => 'books', |
removed reconnect method
|
1493 |
column => ['title', 'author'], |
removed register_format()
|
1494 |
where => {id => 1}, |
1495 |
appned => 'for update' |
|
update document
|
1496 |
); |
1497 |
|
|
renamed update tag to update...
|
1498 |
# select books.name as book_name from books, rental |
added commit method
|
1499 |
# where books.id = rental.book_id; |
1500 |
my $result = $dbi->select( |
|
removed reconnect method
|
1501 |
table => ['books', 'rental'], |
1502 |
column => ['books.name as book_name'] |
|
added commit method
|
1503 |
relation => {'books.id' => 'rental.book_id'} |
update document
|
1504 |
); |
1505 | ||
cleanup
|
1506 |
If you use more complex condition, |
1507 |
you can specify a array reference to C<where> argument. |
|
1508 | ||
1509 |
my $result = $dbi->select( |
|
1510 |
table => 'books', |
|
1511 |
column => ['title', 'author'], |
|
1512 |
where => ['{= title} or {like author}', |
|
1513 |
{title => '%Perl%', author => 'Ken'}] |
|
1514 |
); |
|
1515 | ||
1516 |
First element is a string. it contains tags, |
|
1517 |
such as "{= title} or {like author}". |
|
1518 |
Second element is paramters. |
|
1519 | ||
cleanup
|
1520 |
=head2 C<update> |
removed reconnect method
|
1521 | |
cleanup
|
1522 |
$dbi->update(table => $table, |
1523 |
param => \%params, |
|
1524 |
where => \%where, |
|
1525 |
append => $append, |
|
1526 |
filter => \%filter) |
|
removed reconnect method
|
1527 | |
cleanup
|
1528 |
Execute update statement. |
1529 |
C<update> method have C<table>, C<param>, C<where>, C<append> |
|
1530 |
and C<filter> arguments. |
|
1531 |
C<table> is a table name. |
|
1532 |
C<param> is column-value pairs. this must be hash reference. |
|
1533 |
C<where> is where clause. this must be hash reference. |
|
1534 |
C<append> is a string added at the end of the SQL statement. |
|
1535 |
C<filter> is filters when parameter binding is executed. |
|
1536 |
This is overwrites C<default_bind_filter>. |
|
1537 |
Return value of C<update()> is the count of affected rows. |
|
removed reconnect method
|
1538 | |
removed DBIx::Custom commit ...
|
1539 |
B<Example:> |
removed reconnect method
|
1540 | |
cleanup
|
1541 |
$dbi->update(table => 'books', |
1542 |
param => {title => 'Perl', author => 'Taro'}, |
|
1543 |
where => {id => 5}, |
|
1544 |
append => "some statement", |
|
1545 |
filter => {title => 'encode_utf8'}); |
|
renamed build_query to creat...
|
1546 | |
cleanup
|
1547 |
=head2 C<update_all> |
renamed build_query to creat...
|
1548 | |
cleanup
|
1549 |
$dbi->update_all(table => $table, |
1550 |
param => \%params, |
|
1551 |
filter => \%filter, |
|
1552 |
append => $append); |
|
renamed build_query to creat...
|
1553 | |
cleanup
|
1554 |
Execute update statement to update all rows. |
1555 |
Arguments is same as C<update> method, |
|
1556 |
except that C<update_all> don't have C<where> argument. |
|
1557 |
Return value of C<update_all()> is the count of affected rows. |
|
removed DBIx::Custom commit ...
|
1558 | |
1559 |
B<Example:> |
|
packaging one directory
|
1560 | |
cleanup
|
1561 |
$dbi->update_all(table => 'books', |
1562 |
param => {author => 'taro'}, |
|
1563 |
filter => {author => 'encode_utf8'}); |
|
removed reconnect method
|
1564 | |
DBIx::Custom is now stable
|
1565 |
=head1 STABILITY |
1566 | ||
1567 |
L<DBIx::Custom> is now stable. APIs keep backword compatible in the feature. |
|
1568 | ||
removed DESTROY method(not b...
|
1569 |
=head1 BUGS |
1570 | ||
renamed build_query to creat...
|
1571 |
Please tell me bugs if found. |
removed DESTROY method(not b...
|
1572 | |
1573 |
C<< <kimoto.yuki at gmail.com> >> |
|
1574 | ||
1575 |
L<http://github.com/yuki-kimoto/DBIx-Custom> |
|
1576 | ||
removed reconnect method
|
1577 |
=head1 AUTHOR |
1578 | ||
1579 |
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >> |
|
version 0.0901
|
1580 | |
packaging one directory
|
1581 |
=head1 COPYRIGHT & LICENSE |
1582 | ||
1583 |
Copyright 2009 Yuki Kimoto, all rights reserved. |
|
1584 | ||
1585 |
This program is free software; you can redistribute it and/or modify it |
|
1586 |
under the same terms as Perl itself. |
|
1587 | ||
1588 |
=cut |
|
added cache_method attribute
|
1589 | |
1590 |