Showing 3 changed files with 186 additions and 321 deletions
+186 -217
lib/DBIx/Custom.pm
... ...
@@ -1300,6 +1300,8 @@ our %SELECT_AT_ARGS = (%SELECT_ARGS, where => 1, primary_key => 1);
1300 1300
 sub select_at {
1301 1301
     my ($self, %args) = @_;
1302 1302
 
1303
+    warn "select_at is DEPRECATED! use update and id option instead";
1304
+
1303 1305
     # Arguments
1304 1306
     my $primary_keys = delete $args{primary_key};
1305 1307
     $primary_keys = [$primary_keys] unless ref $primary_keys;
... ...
@@ -1327,6 +1329,8 @@ sub select_at {
1327 1329
 our %DELETE_AT_ARGS = (%DELETE_ARGS, where => 1, primary_key => 1);
1328 1330
 sub delete_at {
1329 1331
     my ($self, %args) = @_;
1332
+
1333
+    warn "delete_at is DEPRECATED! use update and id option instead";
1330 1334
     
1331 1335
     # Arguments
1332 1336
     my $primary_keys = delete $args{primary_key};
... ...
@@ -2034,15 +2038,6 @@ filter name registerd by C<register_filter()>.
2034 2038
 
2035 2039
 These filters are added to the C<out> filters, set by C<apply_filter()>.
2036 2040
 
2037
-=head2 C<column>
2038
-
2039
-    my $column = $self->column(book => ['author', 'title']);
2040
-
2041
-Create column clause. The follwoing column clause is created.
2042
-
2043
-    book.author as book__author,
2044
-    book.title as book__title
2045
-
2046 2041
 =item C<query>
2047 2042
 
2048 2043
 Get L<DBIx::Custom::Query> object instead of executing SQL.
... ...
@@ -2054,61 +2049,38 @@ You can check SQL.
2054 2049
 
2055 2050
     my $sql = $query->sql;
2056 2051
 
2057
-=back
2058
-
2059
-=head2 C<delete_all>
2060
-
2061
-    $dbi->delete_all(table => $table);
2062
-
2063
-Delete statement to delete all rows.
2064
-Options is same as C<delete()>.
2065
-
2066
-=head2 C<delete_at()>
2052
+=item C<id>
2067 2053
 
2068
-Delete statement, using primary key.
2054
+Delete using primary_key.
2069 2055
 
2070
-    $dbi->delete_at(
2071
-        table => 'book',
2056
+    $dbi->delete(
2072 2057
         primary_key => 'id',
2073
-        where => '5'
2058
+        id => 4,
2074 2059
     );
2075 2060
 
2076
-This method is same as C<delete()> exept that
2077
-C<primary_key> is specified and C<where> is constant value or array refrence.
2078
-all option of C<delete()> is available.
2079
-
2080
-=over 4
2081
-
2082
-=item C<primary_key>
2083
-
2084
-Primary key. This is constant value or array reference.
2085
-    
2086
-    # Constant value
2087
-    $dbi->delete(primary_key => 'id');
2061
+    $dbi->delete(
2062
+        primary_key => ['id1', 'id2'],
2063
+        id => [4, 5],
2064
+    );
2088 2065
 
2089
-    # Array reference
2090
-    $dbi->delete(primary_key => ['id1', 'id2' ]);
2066
+The above is same as the followin ones.
2091 2067
 
2092
-This is used to create where clause.
2068
+    $dbi->delete(where => {id => 4});
2093 2069
 
2094
-=item C<where>
2070
+    $dbi->delete(where => {id1 => 4, id2 => 5});
2095 2071
 
2096
-Where clause, created from primary key information.
2097
-This is constant value or array reference.
2098
-
2099
-    # Constant value
2100
-    $dbi->delete(where => 5);
2072
+=item C<primary_key>
2101 2073
 
2102
-    # Array reference
2103
-    $dbi->delete(where => [3, 5]);
2074
+See C<id> option.
2104 2075
 
2105
-In first examle, the following SQL is created.
2076
+=back
2106 2077
 
2107
-    delete from book where id = ?;
2078
+=head2 C<delete_all>
2108 2079
 
2109
-Place holder is set to 5.
2080
+    $dbi->delete_all(table => $table);
2110 2081
 
2111
-=back
2082
+Delete statement to delete all rows.
2083
+Options is same as C<delete()>.
2112 2084
 
2113 2085
 =head2 C<insert>
2114 2086
 
... ...
@@ -2189,54 +2161,8 @@ You can check SQL.
2189 2161
 
2190 2162
 =back
2191 2163
 
2192
-=head2 C<insert_at()>
2193
-
2194
-Insert statement, using primary key.
2195
-
2196
-    $dbi->insert_at(
2197
-        table => 'book',
2198
-        primary_key => 'id',
2199
-        where => '5',
2200
-        param => {title => 'Perl'}
2201
-    );
2202
-
2203
-This method is same as C<insert()> exept that
2204
-C<primary_key> is specified and C<where> is constant value or array refrence.
2205
-all option of C<insert()> is available.
2206
-
2207 2164
 =over 4
2208 2165
 
2209
-=item C<primary_key>
2210
-
2211
-Primary key. This is constant value or array reference.
2212
-    
2213
-    # Constant value
2214
-    $dbi->insert(primary_key => 'id');
2215
-
2216
-    # Array reference
2217
-    $dbi->insert(primary_key => ['id1', 'id2' ]);
2218
-
2219
-This is used to create parts of insert data.
2220
-
2221
-=item C<where>
2222
-
2223
-Parts of Insert data, create from primary key information.
2224
-This is constant value or array reference.
2225
-
2226
-    # Constant value
2227
-    $dbi->insert(where => 5);
2228
-
2229
-    # Array reference
2230
-    $dbi->insert(where => [3, 5]);
2231
-
2232
-In first examle, the following SQL is created.
2233
-
2234
-    insert into book (id, title) values (?, ?);
2235
-
2236
-Place holders are set to 5 and 'Perl'.
2237
-
2238
-=back
2239
-
2240 2166
 =head2 C<insert_param>
2241 2167
 
2242 2168
     my $insert_param = $dbi->insert_param({title => 'a', age => 2});
... ...
@@ -2378,42 +2304,6 @@ This is used by C<clause> of L<DBIx::Custom::Where> .
2378 2304
     
2379 2305
 Register filters, used by C<filter> option of many methods.
2380 2306
 
2381
-=head2 C<register_tag> DEPRECATED!
2382
-
2383
-    $dbi->register_tag(
2384
-        update => sub {
2385
-            my @columns = @_;
2386
-            
2387
-            # Update parameters
2388
-            my $s = 'set ';
2389
-            $s .= "$_ = ?, " for @columns;
2390
-            $s =~ s/, $//;
2391
-            
2392
-            return [$s, \@columns];
2393
-        }
2394
-    );
2395
-
2396
-Register tag, used by C<execute()>.
2397
-
2398
-See also L<Tags/Tags> about tag registered by default.
2399
-
2400
-Tag parser receive arguments specified in tag.
2401
-In the following tag, 'title' and 'author' is parser arguments
2402
-
2403
-    {update_param title author} 
2404
-
2405
-Tag parser must return array refrence,
2406
-first element is the result statement, 
2407
-second element is column names corresponding to place holders.
2408
-
2409
-In this example, result statement is 
2410
-
2411
-    set title = ?, author = ?
2412
-
2413
-Column names is
2414
-
2415
-    ['title', 'author']
2416
-
2417 2307
 =head2 C<select>
2418 2308
 
2419 2309
     my $result = $dbi->select(
... ...
@@ -2537,6 +2427,30 @@ you can pass parameter by C<param> option.
2537 2427
 Append statement to last of SQL. This is string.
2538 2428
 
2539 2429
     $dbi->select(append => 'order by title');
2430
+    
2431
+=item C<id>
2432
+
2433
+Select using primary_key.
2434
+
2435
+    $dbi->select(
2436
+        primary_key => 'id',
2437
+        id => 4,
2438
+    );
2439
+
2440
+    $dbi->select(
2441
+        primary_key => ['id1', 'id2'],
2442
+        id => [4, 5]
2443
+    );
2444
+
2445
+The above is same as the followin ones.
2446
+
2447
+    $dbi->insert(where => {id => 4});
2448
+
2449
+    $dbi->insert(where => {id1 => 4, id2 => 5});
2450
+
2451
+=item C<primary_key>
2452
+
2453
+See C<id> option.
2540 2454
 
2541 2455
 =item C<wrap> EXPERIMENTAL
2542 2456
 
... ...
@@ -2601,53 +2515,6 @@ This is used to bind paramter by C<bind_param()> of statment handle.
2601 2515
 
2602 2516
 =back
2603 2517
 
2604
-=head2 C<select_at()>
2605
-
2606
-Select statement, using primary key.
2607
-
2608
-    $dbi->select_at(
2609
-        table => 'book',
2610
-        primary_key => 'id',
2611
-        where => '5'
2612
-    );
2613
-
2614
-This method is same as C<select()> exept that
2615
-C<primary_key> is specified and C<where> is constant value or array refrence.
2616
-all option of C<select()> is available.
2617
-
2618
-=over 4
2619
-
2620
-=item C<primary_key>
2621
-
2622
-Primary key. This is constant value or array reference.
2623
-    
2624
-    # Constant value
2625
-    $dbi->select(primary_key => 'id');
2626
-
2627
-    # Array reference
2628
-    $dbi->select(primary_key => ['id1', 'id2' ]);
2629
-
2630
-This is used to create where clause.
2631
-
2632
-=item C<where>
2633
-
2634
-Where clause, created from primary key information.
2635
-This is constant value or array reference.
2636
-
2637
-    # Constant value
2638
-    $dbi->select(where => 5);
2639
-
2640
-    # Array reference
2641
-    $dbi->select(where => [3, 5]);
2642
-
2643
-In first examle, the following SQL is created.
2644
-
2645
-    select * from book where id = ?
2646
-
2647
-Place holder is set to 5.
2648
-
2649
-=back
2650
-
2651 2518
 =head2 C<update>
2652 2519
 
2653 2520
     $dbi->update(
... ...
@@ -2700,7 +2567,7 @@ or array refrence.
2700 2567
     # String(with where_param option)
2701 2568
     $dbi->update(
2702 2569
         param => {title => 'Perl'},
2703
-        where => 'id = :id'',
2570
+        where => 'id = :id',
2704 2571
         where_param => {id => 2}
2705 2572
     );
2706 2573
     
... ...
@@ -2752,62 +2619,70 @@ You can check SQL.
2752 2619
 
2753 2620
     my $sql = $query->sql;
2754 2621
 
2755
-=back
2756
-
2757
-=head2 C<update_all>
2758
-
2759
-    $dbi->update_all(table => 'book', param => {title => 'Perl'});
2622
+Insert using primary_key.
2760 2623
 
2761
-Update statement to update all rows.
2762
-Options is same as C<update()>.
2624
+    $dbi->insert(
2625
+        primary_key => 'id',
2626
+        id => 4,
2627
+        param => {title => 'Perl', author => 'Ken'}
2628
+    );
2763 2629
 
2764
-=head2 C<update_at()>
2630
+    $dbi->insert(
2631
+        primary_key => ['id1', 'id2'],
2632
+        id => [4, 5],
2633
+        param => {title => 'Perl', author => 'Ken'}
2634
+    );
2765 2635
 
2766
-Update statement, using primary key.
2636
+The above is same as the followin ones.
2767 2637
 
2768
-    $dbi->update_at(
2769
-        table => 'book',
2770
-        primary_key => 'id',
2771
-        where => '5',
2772
-        param => {title => 'Perl'}
2638
+    $dbi->insert(
2639
+        param => {id => 4, title => 'Perl', author => 'Ken'}
2773 2640
     );
2774 2641
 
2775
-This method is same as C<update()> exept that
2776
-C<primary_key> is specified and C<where> is constant value or array refrence.
2777
-all option of C<update()> is available.
2642
+    $dbi->insert(
2643
+        param => {id1 => 4, id2 => 5, title => 'Perl', author => 'Ken'}
2644
+    );
2778 2645
 
2779
-=over 4
2646
+=item C<id>
2780 2647
 
2781
-=item C<primary_key>
2648
+update using primary_key.
2782 2649
 
2783
-Primary key. This is constant value or array reference.
2784
-    
2785
-    # Constant value
2786
-    $dbi->update(primary_key => 'id');
2650
+    $dbi->update(
2651
+        primary_key => 'id',
2652
+        id => 4,
2653
+        param => {title => 'Perl', author => 'Ken'}
2654
+    );
2787 2655
 
2788
-    # Array reference
2789
-    $dbi->update(primary_key => ['id1', 'id2' ]);
2656
+    $dbi->update(
2657
+        primary_key => ['id1', 'id2'],
2658
+        id => [4, 5],
2659
+        param => {title => 'Perl', author => 'Ken'}
2660
+    );
2790 2661
 
2791
-This is used to create where clause.
2662
+The above is same as the followin ones.
2792 2663
 
2793
-=item C<where>
2664
+    $dbi->update(
2665
+        where => {id => 4}
2666
+        param => {title => 'Perl', author => 'Ken'}
2667
+    );
2794 2668
 
2795
-Where clause, created from primary key information.
2796
-This is constant value or array reference.
2669
+    $dbi->update(
2670
+        where => {id1 => 4, id2 => 5},
2671
+        param => {title => 'Perl', author => 'Ken'}
2672
+    );
2797 2673
 
2798
-    # Constant value
2799
-    $dbi->update(where => 5);
2674
+=item C<primary_key>
2800 2675
 
2801
-    # Array reference
2802
-    $dbi->update(where => [3, 5]);
2676
+See C<id> option.
2803 2677
 
2804
-In first examle, the following SQL is created.
2678
+=back
2805 2679
 
2806
-    update book set title = ? where id = ?
2680
+=head2 C<update_all>
2807 2681
 
2808
-Place holders are set to 'Perl' and 5.
2682
+    $dbi->update_all(table => 'book', param => {title => 'Perl'});
2809 2683
 
2810
-=back
2684
+Update statement to update all rows.
2685
+Options is same as C<update()>.
2811 2686
 
2812 2687
 =head2 C<update_param>
2813 2688
 
... ...
@@ -2835,6 +2710,85 @@ Create a new L<DBIx::Custom::Where> object.
2835 2710
 Setup all model objects.
2836 2711
 C<columns> of model object is automatically set, parsing database information.
2837 2712
 
2713
+=head2 C<update_at()> DEPRECATED!
2714
+
2715
+Update statement, using primary key.
2716
+
2717
+    $dbi->update_at(
2718
+        table => 'book',
2719
+        primary_key => 'id',
2720
+        where => '5',
2721
+        param => {title => 'Perl'}
2722
+    );
2723
+
2724
+This method is same as C<update()> exept that
2725
+C<primary_key> is specified and C<where> is constant value or array refrence.
2726
+all option of C<update()> is available.
2727
+
2728
+=head2 C<delete_at()> DEPRECATED!
2729
+
2730
+Delete statement, using primary key.
2731
+
2732
+    $dbi->delete_at(
2733
+        table => 'book',
2734
+        primary_key => 'id',
2735
+        where => '5'
2736
+    );
2737
+
2738
+This method is same as C<delete()> exept that
2739
+C<primary_key> is specified and C<where> is constant value or array refrence.
2740
+all option of C<delete()> is available.
2741
+
2742
+=head2 C<select_at()> DEPRECATED!
2743
+
2744
+Select statement, using primary key.
2745
+
2746
+    $dbi->select_at(
2747
+        table => 'book',
2748
+        primary_key => 'id',
2749
+        where => '5'
2750
+    );
2751
+
2752
+This method is same as C<select()> exept that
2753
+C<primary_key> is specified and C<where> is constant value or array refrence.
2754
+all option of C<select()> is available.
2755
+
2756
+=head2 C<register_tag> DEPRECATED!
2757
+
2758
+    $dbi->register_tag(
2759
+        update => sub {
2760
+            my @columns = @_;
2761
+            
2762
+            # Update parameters
2763
+            my $s = 'set ';
2764
+            $s .= "$_ = ?, " for @columns;
2765
+            $s =~ s/, $//;
2766
+            
2767
+            return [$s, \@columns];
2768
+        }
2769
+    );
2770
+
2771
+Register tag, used by C<execute()>.
2772
+
2773
+See also L<Tags/Tags> about tag registered by default.
2774
+
2775
+Tag parser receive arguments specified in tag.
2776
+In the following tag, 'title' and 'author' is parser arguments
2777
+
2778
+    {update_param title author} 
2779
+
2780
+Tag parser must return array refrence,
2781
+first element is the result statement, 
2782
+second element is column names corresponding to place holders.
2783
+
2784
+In this example, result statement is 
2785
+
2786
+    set title = ?, author = ?
2787
+
2788
+Column names is
2789
+
2790
+    ['title', 'author']
2791
+
2838 2792
 =head1 Parameter
2839 2793
 
2840 2794
 Parameter start at ':'. This is replaced to place holoder
... ...
@@ -2921,6 +2875,21 @@ Updata parameter tag.
2921 2875
 
2922 2876
     {update_param NAME1 NAME2}   ->   set NAME1 = ?, NAME2 = ?
2923 2877
 
2878
+=head2 C<insert_at()> DEPRECATED!
2879
+
2880
+Insert statement, using primary key.
2881
+
2882
+    $dbi->insert_at(
2883
+        table => 'book',
2884
+        primary_key => 'id',
2885
+        where => '5',
2886
+        param => {title => 'Perl'}
2887
+    );
2888
+
2889
+This method is same as C<insert()> exept that
2890
+C<primary_key> is specified and C<where> is constant value or array refrence.
2891
+all option of C<insert()> is available.
2892
+
2924 2893
 =head1 ENVIRONMENT VARIABLE
2925 2894
 
2926 2895
 =head2 C<DBIX_CUSTOM_DEBUG>
-52
lib/DBIx/Custom/Guide.pod
... ...
@@ -404,58 +404,6 @@ You don't have to wirte last semicolon in C<execute()>.
404 404
 
405 405
     $dbi->execute('select * from book');
406 406
 
407
-=head3 insert by using primary key : C<insert_at()>
408
-
409
-To insert row by using primary key, use C<insert_at()>
410
-
411
-    $dbi->insert_at(
412
-        table => 'book', primary_key => ['id'],
413
-        where => ['123'], param => {name => 'Ken'}
414
-    );
415
-
416
-In this example, row which id column is 123 is inserted.
417
-NOTE that you must pass array reference as C<where>.
418
-If C<param> contains primary key, the key and value is delete from C<param>.
419
-
420
-=head3 Update by using primary key : C<update_at()>
421
-
422
-To update row by using primary key, use C<update_at()>
423
-
424
-    $dbi->update_at(
425
-        table => 'book', primary_key => ['id'],
426
-        where => ['123'], param => {name => 'Ken'}
427
-    );
428
-
429
-In this example, row which id column is 123 is updated.
430
-NOTE that you must pass array reference as C<where>.
431
-If C<param> contains primary key, the key and value is delete from C<param>.
432
-
433
-=head3 Delete by using primary key : C<delete_at()>
434
-
435
-To delete row by using primary key, use C<delete_at()>
436
-
437
-    $dbi->delete_at(table => 'book', primary_key => ['id'], where => ['123']);
438
-
439
-In this example, row which id column is 123 is deleted.
440
-NOTE that you must pass array reference as C<where>.
441
-
442
-You can also write arguments like this.
443
-
444
-    $dbi->delete_at(table => 'book', primary_key => ['id'], param => {id => '123'});
445
-
446
-=head3 Select by using primary key : C<select_at()>
447
-
448
-To select row by using primary key, use C<select_at()>.
449
-
450
-    $dbi->select_at(table => 'book', primary_key => ['id'], where => ['123']);
451
-
452
-In this example, row which id colunm is 123 is selected.
453
-NOTE that you must pass array reference as C<where>.
454
-
455
-You can also write arguments like this.
456
-
457
-    $dbi->select_at(table => 'book', primary_key => ['id'], param => {id => '123'});
458
-
459 407
 =head2 3. Fetch row
460 408
 
461 409
 Return value of C<select()> is L<DBIx::Custom::Result> object.
-52
lib/DBIx/Custom/Guide/Ja.pod
... ...
@@ -410,58 +410,6 @@ SQLを実行するにはC<execute()>を使用します。
410 410
 
411 411
     $dbi->execute('select * from book');
412 412
 
413
-=head3 プライマリーキーを利用した行の挿入 C<insert_at()>
414
-
415
-プライマリーを使用して行を更新するにはC<insert_at()>を使用します。
416
-
417
-    $dbi->insert_at(
418
-        table => 'book', primary_key => ['id'],
419
-        where => ['123'], param => {name => 'Ken'}
420
-    );
421
-
422
-この例ではidの列が123の行に挿入されます。C<where>には、配列の
423
-リファレンスを渡す必要があることに注意してください。
424
-なおC<param>にプライマリーキーが含まれていた場合は、そのキーが削除されます。
425
-
426
-=head3 プライマリーキーを利用した行の更新 C<update_at()>
427
-
428
-プライマリーを使用して行を更新するにはC<update_at()>を使用します。
429
-
430
-    $dbi->update_at(
431
-        table => 'book', primary_key => ['id'],
432
-        where => ['123'], param => {name => 'Ken'}
433
-    );
434
-
435
-この例ではidの列が123の行が更新されます。C<where>には、配列の
436
-リファレンスを渡す必要があることに注意してください。
437
-なおC<param>にプライマリーキーが含まれていた場合は、そのキーが削除されます。
438
-
439
-=head3 プライマリーキーを利用した行の削除 C<delete_at()>
440
-
441
-プライマリーを使用して行を削除するにはC<delete_at()>を使用します。
442
-
443
-    $dbi->delete_at(table => 'book', primary_key => ['id'], where => ['123']);
444
-
445
-この例ではidの列が123の行が削除されます。C<where>には、配列の
446
-リファレンスを渡す必要があることに注意してください。
447
-
448
-また下のような記述方法も許されています。
449
-
450
-    $dbi->delete_at(table => 'book', primary_key => ['id'], param => {id => '123'});
451
-
452
-=head3 プライマリーキーを利用した行の選択 C<select_at()>
453
-
454
-プライマリーを使用して行を選択するにはC<select_at()>を使用します。
455
-
456
-    $dbi->select_at(table => 'book', primary_key => ['id'], where => ['123']);
457
-
458
-この例ではidの列が123の行が選択されます。C<where>には、配列の
459
-リファレンスを渡す必要があることに注意してください。
460
-
461
-また下のような記述方法も許されています。
462
-
463
-    $dbi->select_at(table => 'book', primary_key => ['id'], param => {id => '123'});
464
-
465 413
 =head2 3. 行のフェッチ
466 414
 
467 415
 C<select()>メソッドの戻り値はL<DBIx::Custom::Result>オブジェクトです。