Showing 3 changed files with 22 additions and 17 deletions
+7 -2
lib/DBIx/Custom.pm
... ...
@@ -417,7 +417,7 @@ sub execute{
417 417
     }
418 418
     
419 419
     # Filter argument
420
-    my $f = DBIx::Custom::Util::array_filter_to_hash($args{filter})
420
+    my $f = DBIx::Custom::Util::array_to_hash($args{filter})
421 421
          || $query->filter || {};
422 422
     foreach my $column (keys %$f) {
423 423
         my $fname = $f->{$column};
... ...
@@ -439,7 +439,12 @@ sub execute{
439 439
     # Execute
440 440
     my $sth = $query->sth;
441 441
     my $affected;
442
-    eval {$affected = $sth->execute(@$bind)};
442
+    eval {
443
+        for (my $i = 0; $i < @$bind; $i++) {
444
+            $sth->bind_param($i + 1, $bind->[$i]);
445
+        }
446
+        $affected = $sth->execute;
447
+    };
443 448
     $self->_croak($@, qq{. Following SQL is executed. "$query->{sql}"}) if $@;
444 449
     
445 450
     # Return resultset if select statement is executed
+2 -2
lib/DBIx/Custom/Result.pm
... ...
@@ -23,7 +23,7 @@ sub filter {
23 23
             $filter = $_[0];
24 24
         }
25 25
         else {
26
-            $filter = DBIx::Custom::Util::array_filter_to_hash(
26
+            $filter = DBIx::Custom::Util::array_to_hash(
27 27
                 @_ > 1 ? [@_] : $_[0]
28 28
             );
29 29
         }
... ...
@@ -60,7 +60,7 @@ sub end_filter {
60 60
             $end_filter = $_[0];
61 61
         }
62 62
         else {
63
-            $end_filter = DBIx::Custom::Util::array_filter_to_hash(
63
+            $end_filter = DBIx::Custom::Util::array_to_hash(
64 64
                 @_ > 1 ? [@_] : $_[0]
65 65
             );
66 66
         }
+13 -13
lib/DBIx/Custom/Util.pm
... ...
@@ -3,28 +3,28 @@ package DBIx::Custom::Util;
3 3
 use strict;
4 4
 use warnings;
5 5
 
6
-sub array_filter_to_hash {
7
-    my $array_filter = shift;
6
+sub array_to_hash {
7
+    my $array = shift;
8 8
     
9
-    return unless $array_filter;
10
-    return $array_filter if ref $array_filter eq 'HASH';
9
+    return unless $array;
10
+    return $array if ref $array eq 'HASH';
11 11
     
12
-    my $filter = {};
12
+    my $hash = {};
13 13
     
14
-    for (my $i = 0; $i < @$array_filter; $i += 2) {
15
-        my $column = $array_filter->[$i];
16
-        my $f = $array_filter->[$i + 1];
14
+    for (my $i = 0; $i < @$array; $i += 2) {
15
+        my $key = $array->[$i];
16
+        my $f = $array->[$i + 1];
17 17
         
18
-        if (ref $column eq 'ARRAY') {
19
-            foreach my $c (@$column) {
20
-                $filter->{$c} = $f;
18
+        if (ref $key eq 'ARRAY') {
19
+            foreach my $k (@$key) {
20
+                $hash->{$k} = $f;
21 21
             }
22 22
         }
23 23
         else {
24
-            $filter->{$column} = $f;
24
+            $hash->{$key} = $f;
25 25
         }
26 26
     }
27
-    return $filter;
27
+    return $hash;
28 28
 }
29 29
 
30 30
 1;