Showing 2 changed files with 26 additions and 28 deletions
+19 -28
lib/DBIx/Custom/Table.pm
... ...
@@ -75,52 +75,43 @@ my $table = DBIx::Custom::Table->new(name => 'books');
75 75
 
76 76
 =head1 METHODS
77 77
 
78
-L<DBIx::Custom> inherits all methods from L<Object::Simple>
78
+L<DBIx::Custom> inherits all methods from L<Object::Simple>,
79
+and you can use all methods of the object set to C<dbi>.
79 80
 and implements the following new ones.
80 81
 
81 82
 =head2 C<delete>
82 83
 
83
-    $table->delete(where => \%where);
84
+    $table->delete(...);
84 85
     
85 86
 Same as C<delete()> of L<DBIx::Custom> except that
86
-you don't have to specify table name.
87
+you don't have to specify C<table> option.
87 88
 
88 89
 =head2 C<delete_all>
89 90
 
90
-    $table->delete_all(param => $param);
91
+    $table->delete_all(...);
91 92
     
92 93
 Same as C<delete_all()> of L<DBIx::Custom> except that
93
-you don't have to specify table name.
94
+you don't have to specify C<table> option.
94 95
 
95 96
 =head2 C<method>
96 97
 
97
-    $table->method(insert => sub {
98
-        my $self = shift;
98
+    $table->method(
99
+        count => sub {
100
+            my $self = shift;
99 101
         
100
-        return $self->dbi->insert(table => $self->name, @_);
101
-    });
102
+            return $self->select(column => 'count(*)', @_)
103
+                        ->fetch_first->[0];
104
+        }
105
+    );
102 106
     
103 107
 Add method to a L<DBIx::Custom::Table> object.
104 108
 
105 109
 =head2 C<insert>
106 110
 
107
-    $table->insert(param => \%param);
111
+    $table->insert(...);
108 112
     
109 113
 Same as C<insert()> of L<DBIx::Custom> except that
110
-you don't have to specify table name.
111
-
112
-=head2 C<method>
113
-
114
-    $table->method(
115
-        select_complex => sub {
116
-            my $self = shift;
117
-            
118
-            return $self->dbi->select($self->name, ...);
119
-        },
120
-        some_method => sub { ... }
121
-    );
122
-
123
-Define method.
114
+you don't have to specify C<table> option.
124 115
 
125 116
 =head2 C<new>
126 117
 
... ...
@@ -130,17 +121,17 @@ Create a L<DBIx::Custom::Table> object.
130 121
 
131 122
 =head2 C<select>
132 123
 
133
-    $table->select(param => $param);
124
+    $table->select(...);
134 125
     
135 126
 Same as C<select()> of L<DBIx::Custom> except that
136
-you don't have to specify table name.
127
+you don't have to specify C<table> option.
137 128
 
138 129
 =head2 C<update>
139 130
 
140
-    $table->update(param => \%param, where => \%where);
131
+    $table->update(...);
141 132
     
142 133
 Same as C<update()> of L<DBIx::Custom> except that
143
-you don't have to specify table name.
134
+you don't have to specify C<table> option.
144 135
 
145 136
 =head2 C<update_all>
146 137
 
+7
t/dbix-custom-core-sqlite.t
... ...
@@ -1089,3 +1089,10 @@ $result = $dbi->base_table->execute("select * from table1");
1089 1089
 is_deeply($result->fetch_hash_all, [{key1 => 1, key2 => 2}], 'dbi method from base_table');
1090 1090
 $result = $dbi->table('table1')->execute("select * from table1");
1091 1091
 is_deeply($result->fetch_hash_all, [{key1 => 1, key2 => 2}], 'dbi method from table');
1092
+
1093
+$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1094
+$dbi->method(
1095
+    one => sub { 1 }
1096
+);
1097
+is($dbi->base_table->one, 1, 'use dbi method');
1098
+is($dbi->table('table1')->one, 1, 'use dbi method');