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