... | ... |
@@ -497,25 +497,46 @@ sub execute { |
497 | 497 |
$filter->{$column} = $self->filters->{$name}; |
498 | 498 |
} |
499 | 499 |
} |
500 |
- |
|
501 |
- # Create bind values |
|
502 |
- my ($bind, $bind_types) = $self->_create_bind_values($param, $query->{columns}, |
|
503 |
- $filter, $type_filters, $opt{bind_type} || $opt{type} || {}); |
|
504 | 500 |
|
505 | 501 |
# Execute |
506 | 502 |
my $sth = $query->{sth}; |
507 | 503 |
my $affected; |
508 |
- eval { |
|
509 |
- if ($opt{bind_type} || $opt{type}) { |
|
510 |
- $sth->bind_param($_ + 1, $bind->[$_], |
|
511 |
- $bind_types->[$_] ? $bind_types->[$_] : ()) |
|
512 |
- for (0 .. @$bind - 1); |
|
513 |
- $affected = $sth->execute; |
|
514 |
- } |
|
515 |
- else { |
|
516 |
- $affected = $sth->execute(@$bind); |
|
517 |
- } |
|
518 |
- }; |
|
504 |
+ if (!$query->{duplicate} && $type_rule_off && !keys %$filter && |
|
505 |
+ !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG}) |
|
506 |
+ { |
|
507 |
+ eval { $affected = $sth->execute(map { $param->{$_} } @{$query->{columns}}) }; |
|
508 |
+ } |
|
509 |
+ else { |
|
510 |
+ # Create bind values |
|
511 |
+ my ($bind, $bind_types) = $self->_create_bind_values($param, $query->{columns}, |
|
512 |
+ $filter, $type_filters, $opt{bind_type} || $opt{type} || {}); |
|
513 |
+ |
|
514 |
+ # Execute |
|
515 |
+ eval { |
|
516 |
+ if ($opt{bind_type} || $opt{type}) { |
|
517 |
+ $sth->bind_param($_ + 1, $bind->[$_], |
|
518 |
+ $bind_types->[$_] ? $bind_types->[$_] : ()) |
|
519 |
+ for (0 .. @$bind - 1); |
|
520 |
+ $affected = $sth->execute; |
|
521 |
+ } |
|
522 |
+ else { |
|
523 |
+ $affected = $sth->execute(@$bind); |
|
524 |
+ } |
|
525 |
+ |
|
526 |
+ # DEBUG message |
|
527 |
+ if ($ENV{DBIX_CUSTOM_DEBUG}) { |
|
528 |
+ warn "SQL:\n" . $query->{sql} . "\n"; |
|
529 |
+ my @output; |
|
530 |
+ for my $value (@$bind) { |
|
531 |
+ $value = 'undef' unless defined $value; |
|
532 |
+ $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value) |
|
533 |
+ if utf8::is_utf8($value); |
|
534 |
+ push @output, $value; |
|
535 |
+ } |
|
536 |
+ warn "Bind values: " . join(', ', @output) . "\n\n"; |
|
537 |
+ } |
|
538 |
+ }; |
|
539 |
+ } |
|
519 | 540 |
|
520 | 541 |
$self->_croak($@, qq{. Following SQL is executed.\n} |
521 | 542 |
. qq{$query->{sql}\n} . _subname) if $@; |
... | ... |
@@ -523,19 +544,6 @@ sub execute { |
523 | 544 |
# Remove id from parameter |
524 | 545 |
delete $param->{$_} for (@cleanup, @{$opt{cleanup} || []}); |
525 | 546 |
|
526 |
- # DEBUG message |
|
527 |
- if ($ENV{DBIX_CUSTOM_DEBUG}) { |
|
528 |
- warn "SQL:\n" . $query->{sql} . "\n"; |
|
529 |
- my @output; |
|
530 |
- for my $value (@$bind) { |
|
531 |
- $value = 'undef' unless defined $value; |
|
532 |
- $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value) |
|
533 |
- if utf8::is_utf8($value); |
|
534 |
- push @output, $value; |
|
535 |
- } |
|
536 |
- warn "Bind values: " . join(', ', @output) . "\n\n"; |
|
537 |
- } |
|
538 |
- |
|
539 | 547 |
# Not select statement |
540 | 548 |
return $affected unless $sth->{NUM_OF_FIELDS}; |
541 | 549 |
|