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