| ... | ... |
@@ -380,6 +380,19 @@ You don't have to wirte last semicolon in C<execute()>. |
| 380 | 380 |
|
| 381 | 381 |
$dbi->execute('select * from book');
|
| 382 | 382 |
|
| 383 |
+=head3 insert by using primary key : C<insert_at()> |
|
| 384 |
+ |
|
| 385 |
+To insert row by using primary key, use C<insert_at()> |
|
| 386 |
+ |
|
| 387 |
+ $dbi->insert_at( |
|
| 388 |
+ table => 'book', primary_key => ['id'], |
|
| 389 |
+ where => ['123'], param => {name => 'Ken'}
|
|
| 390 |
+ ); |
|
| 391 |
+ |
|
| 392 |
+In this example, row which id column is 123 is inserted. |
|
| 393 |
+NOTE that you must pass array reference as C<where>. |
|
| 394 |
+If C<param> contains primary key, the key and value is delete from C<param>. |
|
| 395 |
+ |
|
| 383 | 396 |
=head3 Update by using primary key : C<update_at()> |
| 384 | 397 |
|
| 385 | 398 |
To update row by using primary key, use C<update_at()> |
| ... | ... |
@@ -1081,7 +1094,7 @@ You can set primary key to model. |
| 1081 | 1094 |
|
| 1082 | 1095 |
$model->primary_key(['id', 'number_id']); |
| 1083 | 1096 |
|
| 1084 |
-Primary key is used by C<update_at()>, C<delete_at()>, |
|
| 1097 |
+Primary key is used by C<insert_at>, C<update_at()>, C<delete_at()>, |
|
| 1085 | 1098 |
C<select_at()>. |
| 1086 | 1099 |
|
| 1087 | 1100 |
by C<filter> you can define filters applied by C<apply_filter()> |
| ... | ... |
@@ -386,6 +386,19 @@ SQLを実行するにはC<execute()>を使用します。 |
| 386 | 386 |
|
| 387 | 387 |
$dbi->execute('select * from book');
|
| 388 | 388 |
|
| 389 |
+=head3 プライマリーキーを利用した行の挿入 C<insert_at()> |
|
| 390 |
+ |
|
| 391 |
+プライマリーを使用して行を更新するにはC<insert_at()>を使用します。 |
|
| 392 |
+ |
|
| 393 |
+ $dbi->insert_at( |
|
| 394 |
+ table => 'book', primary_key => ['id'], |
|
| 395 |
+ where => ['123'], param => {name => 'Ken'}
|
|
| 396 |
+ ); |
|
| 397 |
+ |
|
| 398 |
+この例ではidの列が123の行に挿入されます。C<where>には、配列の |
|
| 399 |
+リファレンスを渡す必要があることに注意してください。 |
|
| 400 |
+なおC<param>にプライマリーキーが含まれていた場合は、そのキーが削除されます。 |
|
| 401 |
+ |
|
| 389 | 402 |
=head3 プライマリーキーを利用した行の更新 C<update_at()> |
| 390 | 403 |
|
| 391 | 404 |
プライマリーを使用して行を更新するにはC<update_at()>を使用します。 |
| ... | ... |
@@ -397,7 +410,7 @@ SQLを実行するにはC<execute()>を使用します。 |
| 397 | 410 |
|
| 398 | 411 |
この例ではidの列が123の行が更新されます。C<where>には、配列の |
| 399 | 412 |
リファレンスを渡す必要があることに注意してください。 |
| 400 |
-なおC<param>にプライマリーキーが含まれていた場合は、そのキーが削除さされます。 |
|
| 413 |
+なおC<param>にプライマリーキーが含まれていた場合は、そのキーが削除されます。 |
|
| 401 | 414 |
|
| 402 | 415 |
=head3 プライマリーキーを利用した行の削除 C<delete_at()> |
| 403 | 416 |
|
| ... | ... |
@@ -1084,7 +1097,7 @@ C<delete()>, C<delete_all()>, C<select()>などのメソッドを |
| 1084 | 1097 |
|
| 1085 | 1098 |
またモデルクラスでC<primary_key>の設定がなされていれば、 |
| 1086 | 1099 |
プライマリキーを指定することなしに |
| 1087 |
-C<update_at()>, C<delete_at()>, C<select_at()>のメソッドを |
|
| 1100 |
+C<insert_at>, C<update_at()>, C<delete_at()>, C<select_at()>のメソッドを |
|
| 1088 | 1101 |
利用できます。 |
| 1089 | 1102 |
|
| 1090 | 1103 |
$dbi->model('book')->delete_at(where => 123);
|
| ... | ... |
@@ -1116,7 +1129,7 @@ L<DBIx::Custom>とL<DBI>のすべてのメソッドを呼び出すこともで |
| 1116 | 1129 |
|
| 1117 | 1130 |
$model->primary_key(['id', 'number_id']); |
| 1118 | 1131 |
|
| 1119 |
-ここで設定したプライマリーキーはC<update_at()>, C<delete_at()>, |
|
| 1132 |
+ここで設定したプライマリーキーはC<insert_at>, C<update_at()>, C<delete_at()>, |
|
| 1120 | 1133 |
C<select_at()>で利用されます。 |
| 1121 | 1134 |
|
| 1122 | 1135 |
C<filter>でC<apply_filter()>で適用されるフィルタを定義しておくこともできます。 |
| ... | ... |
@@ -207,8 +207,8 @@ Table name is real table name in database. |
| 207 | 207 |
my $primary_key = $model->primary_key; |
| 208 | 208 |
$model = $model->primary_key(['id', 'number']); |
| 209 | 209 |
|
| 210 |
-Foreign key. This is used by C<update_at()>, C<delete_at()>, |
|
| 211 |
-C<select_at()>. |
|
| 210 |
+Foreign key. This is used by C<insert_at>,C<update_at()>, |
|
| 211 |
+C<delete_at()>,C<select_at()>. |
|
| 212 | 212 |
|
| 213 | 213 |
=head1 METHODS |
| 214 | 214 |
|
| ... | ... |
@@ -252,6 +252,13 @@ you don't have to specify C<table> option. |
| 252 | 252 |
Same as C<delete_all()> of L<DBIx::Custom> except that |
| 253 | 253 |
you don't have to specify C<table> option. |
| 254 | 254 |
|
| 255 |
+=head2 C<delete_at> |
|
| 256 |
+ |
|
| 257 |
+ $table->delete_at(...); |
|
| 258 |
+ |
|
| 259 |
+Same as C<delete()> of L<DBIx::Custom> except that |
|
| 260 |
+you don't have to specify C<table> and C<primary_key> option. |
|
| 261 |
+ |
|
| 255 | 262 |
=head2 C<method> |
| 256 | 263 |
|
| 257 | 264 |
$table->method( |
| ... | ... |
@@ -272,6 +279,13 @@ Add method to a L<DBIx::Custom::Table> object. |
| 272 | 279 |
Same as C<insert()> of L<DBIx::Custom> except that |
| 273 | 280 |
you don't have to specify C<table> option. |
| 274 | 281 |
|
| 282 |
+=head2 C<insert> |
|
| 283 |
+ |
|
| 284 |
+ $table->insert_at(...); |
|
| 285 |
+ |
|
| 286 |
+Same as C<insert_at()> of L<DBIx::Custom> except that |
|
| 287 |
+you don't have to specify C<table> and C<primary_key> option. |
|
| 288 |
+ |
|
| 275 | 289 |
=head2 C<new> |
| 276 | 290 |
|
| 277 | 291 |
my $table = DBIx::Custom::Table->new; |
| ... | ... |
@@ -285,6 +299,13 @@ Create a L<DBIx::Custom::Table> object. |
| 285 | 299 |
Same as C<select()> of L<DBIx::Custom> except that |
| 286 | 300 |
you don't have to specify C<table> option. |
| 287 | 301 |
|
| 302 |
+=head2 C<select_at> |
|
| 303 |
+ |
|
| 304 |
+ $table->select_at(...); |
|
| 305 |
+ |
|
| 306 |
+Same as C<select_at()> of L<DBIx::Custom> except that |
|
| 307 |
+you don't have to specify C<table> and C<primary_key> option. |
|
| 308 |
+ |
|
| 288 | 309 |
=head2 C<update> |
| 289 | 310 |
|
| 290 | 311 |
$table->update(...); |
| ... | ... |
@@ -298,3 +319,10 @@ you don't have to specify C<table> option. |
| 298 | 319 |
|
| 299 | 320 |
Same as C<update_all()> of L<DBIx::Custom> except that |
| 300 | 321 |
you don't have to specify table name. |
| 322 |
+ |
|
| 323 |
+=head2 C<update_at> |
|
| 324 |
+ |
|
| 325 |
+ $table->update_at(...); |
|
| 326 |
+ |
|
| 327 |
+Same as C<update_at()> of L<DBIx::Custom> except that |
|
| 328 |
+you don't have to specify C<table> and C<primary_key> option. |