Showing 1 changed files with 28 additions and 49 deletions
+28 -49
lib/DBIx/Custom.pm
... ...
@@ -324,7 +324,6 @@ sub delete {
324 324
     my $where            = delete $args{where} || {};
325 325
     my $append           = delete $args{append};
326 326
     my $allow_delete_all = delete $args{allow_delete_all};
327
-    my $query_return     = delete $args{query};
328 327
     my $where_param      = delete $args{where_param} || {};
329 328
     my $id = delete $args{id};
330 329
     my $primary_key = delete $args{primary_key};
... ...
@@ -356,13 +355,9 @@ sub delete {
356 355
     push @sql, $append if $append;
357 356
     my $sql = join(' ', @sql);
358 357
     
359
-    # Create query
360
-    my $query = $self->create_query($sql);
361
-    return $query if $query_return;
362
-    
363 358
     # Execute query
364 359
     return $self->execute(
365
-        $query,
360
+        $sql,
366 361
         param => $where_param,
367 362
         table => $table,
368 363
         %args
... ...
@@ -443,6 +438,7 @@ sub execute {
443 438
     my $type = delete $args{type};
444 439
     $type = _array_to_hash($type);
445 440
     my $type_rule_off = delete $args{type_rule_off};
441
+    my $query_return = delete $args{query};
446 442
     
447 443
     # Check argument names
448 444
     foreach my $name (keys %args) {
... ...
@@ -452,6 +448,7 @@ sub execute {
452 448
     
453 449
     # Create query
454 450
     $query = $self->create_query($query) unless ref $query;
451
+    return $query if $query_return;
455 452
     $filter ||= $query->filter;
456 453
     
457 454
     # Tables
... ...
@@ -619,7 +616,6 @@ sub insert {
619 616
     my $p = delete $args{param} || {};
620 617
     $param  ||= $p;
621 618
     my $append = delete $args{append} || '';
622
-    my $query_return  = delete $args{query};
623 619
     my $id = delete $args{id};
624 620
     my $primary_key = delete $args{primary_key};
625 621
     croak "insert method primary_key option " .
... ...
@@ -648,13 +644,9 @@ sub insert {
648 644
     push @sql, $append if $append;
649 645
     my $sql = join (' ', @sql);
650 646
     
651
-    # Create query
652
-    my $query = $self->create_query($sql);
653
-    return $query if $query_return;
654
-    
655 647
     # Execute query
656 648
     return $self->execute(
657
-        $query,
649
+        $sql,
658 650
         param => $param,
659 651
         table => $table,
660 652
         %args
... ...
@@ -875,7 +867,6 @@ sub select {
875 867
     warn "select() param option is DEPRECATED! use where_param option instead"
876 868
       if keys %$param;
877 869
     my $where_param = delete $args{where_param} || $param || {};
878
-    my $query_return = $args{query};
879 870
     my $wrap = delete $args{wrap};
880 871
     my $id = delete $args{id};
881 872
     my $primary_key = delete $args{primary_key};
... ...
@@ -980,13 +971,9 @@ sub select {
980 971
     # SQL
981 972
     my $sql = join (' ', @sql);
982 973
     
983
-    # Create query
984
-    my $query = $self->create_query($sql);
985
-    return $query if $query_return;
986
-    
987 974
     # Execute query
988 975
     my $result = $self->execute(
989
-        $query,
976
+        $sql,
990 977
         param => $where_param, 
991 978
         table => $tables,
992 979
         %args
... ...
@@ -1097,13 +1084,9 @@ sub update {
1097 1084
     # SQL
1098 1085
     my $sql = join(' ', @sql);
1099 1086
     
1100
-    # Create query
1101
-    my $query = $self->create_query($sql);
1102
-    return $query if $args{query};
1103
-    
1104 1087
     # Execute query
1105 1088
     my $ret_val = $self->execute(
1106
-        $query,
1089
+        $sql,
1107 1090
         param  => $param, 
1108 1091
         table => $table,
1109 1092
         %args
... ...
@@ -2180,38 +2163,17 @@ Options is same as C<delete()>.
2180 2163
 
2181 2164
 =head2 C<insert>
2182 2165
 
2183
-    $dbi->insert(
2184
-        param  => {title => 'Perl', author => 'Ken'},
2185
-        table  => 'book'
2186
-    );
2187
-    
2188
-Insert statement.
2189
-
2190
-The following opitons are currently available.
2191
-
2192
-=over 4
2193
-
2194
-=item C<param>
2195
-
2196
-Insert data. This is hash reference.
2197
-
2198
-    $dbi->insert(param => {title => 'Perl'});
2166
+    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
2199 2167
 
2200
-If arguments is odd numbers, first argument is received as C<param>.
2168
+Execute insert statement.
2201 2169
 
2202
-    $dbi->insert({title => 'Perl', author => 'Ken'}, table => 'book');
2170
+The following opitons are available.
2203 2171
 
2204
-=item C<table>
2205
-
2206
-Table name.
2207
-
2208
-    $dbi->insert(table => 'book');
2172
+=over 4
2209 2173
 
2210 2174
 =item C<append>
2211 2175
 
2212
-Append statement to last of SQL. This is string.
2213
-
2214
-    $dbi->insert(append => 'order by title');
2176
+Same as C<select> method's C<append> option.
2215 2177
 
2216 2178
 =item C<filter>
2217 2179
 
... ...
@@ -2258,6 +2220,23 @@ The above is same as the followin ones.
2258 2220
 
2259 2221
 See C<id> description.
2260 2222
 
2223
+=item C<table>
2224
+
2225
+Table name.
2226
+
2227
+    $dbi->insert(table => 'book');
2228
+
2229
+=item C<param>
2230
+
2231
+    param => {title => 'Perl', author => 'Ken'}
2232
+
2233
+Insert data.
2234
+
2235
+If C<insert> method's arguments is odd numbers,
2236
+first argument is received as C<param>.
2237
+
2238
+    $dbi->insert({title => 'Perl', author => 'Ken'}, table => 'book');
2239
+
2261 2240
 =item C<type>
2262 2241
 
2263 2242
 Same as C<execute> method's C<type> option.