| ... | ... | 
                  @@ -221,91 +221,82 @@ By default, the following ones is set to database handle attributes.  | 
              
| 221 | 221 | 
                  If fatal error occuer, program terminate.  | 
              
| 222 | 222 | 
                  If SQL is executed, commit is executed automatically.  | 
              
| 223 | 223 | 
                   | 
              
| 224 | 
                  -=head2 2. �}��A�X�V�A�폜�A�I��̂��߂̃��\�b�h  | 
              |
| 224 | 
                  +=head2 2. Methods for insert, update, delete, or insert  | 
              |
| 225 | 225 | 
                   | 
              
| 226 | 
                  -L<DBIx::Custom>�́A  | 
              |
| 227 | 
                  -C<insert()>�AC<update()>�AC<delete()>�AC<select()>  | 
              |
| 228 | 
                  -�̂悤�ȑ}��A�X�V�A�폜�A�I���s�����߂̃��\�b�h���Ă��܂��B  | 
              |
| 229 | 
                  -�ȒP�Ȃ��Ƃ��s���̂ł���ASQL����ŋL�q����K�v������܂���B  | 
              |
| 226 | 
                  +There are following methods.  | 
              |
| 230 | 227 | 
                   | 
              
| 231 | 
                  -=head3 �f�[�^�̑}�� C<insert()>  | 
              |
| 228 | 
                  +=head3 C<insert()>  | 
              |
| 232 | 229 | 
                   | 
              
| 233 | 
                  -�f�[�^�x�[�X�Ƀf�[�^��}���ɂ�C<insert()>��g�p���܂��B  | 
              |
| 230 | 
                  +use C<insert()> to insert row into database  | 
              |
| 234 | 231 | 
                   | 
              
| 235 | 232 | 
                  $dbi->insert(table => 'book',  | 
              
| 236 | 233 | 
                                    param  => {title => 'Perl', author => 'Ken'});
                 | 
              
| 237 | 234 | 
                   | 
              
| 238 | 
                  -C<table>�ɂ̓e�[�u�����AC<param>�ɂ͑}����f�[�^��w�肵�܂��B  | 
              |
| 235 | 
                  +C<table> is table name, C<param> is insert data.  | 
              |
| 239 | 236 | 
                   | 
              
| 240 | 
                  -����SQL�����s����܂��B  | 
              |
| 237 | 
                  +Following SQL is executed.  | 
              |
| 241 | 238 | 
                   | 
              
| 242 | 239 | 
                  insert into (title, author) values (?, ?);  | 
              
| 243 | 240 | 
                   | 
              
| 244 | 
                  -=head3 �f�[�^�̍X�V C<update()>  | 
              |
| 241 | 
                  +=head3 C<update()>  | 
              |
| 245 | 242 | 
                   | 
              
| 246 | 
                  -�f�[�^�x�[�X�̃f�[�^��X�V����ɂ́AC<update()>��g�p���܂��B  | 
              |
| 243 | 
                  +use C<update()> to update row in database.  | 
              |
| 247 | 244 | 
                   | 
              
| 248 | 245 | 
                  $dbi->update(table => 'book',  | 
              
| 249 | 246 | 
                                    param  => {title => 'Perl', author => 'Ken'}, 
                 | 
              
| 250 | 247 | 
                                    where  => {id => 5});
                 | 
              
| 251 | 248 | 
                   | 
              
| 252 | 
                  -C<table>�ɂ̓e�[�u�����AC<param>�ɂ͑}����f�[�^�AC<where>�ɂ�  | 
              |
| 253 | 
                  -���w�肵�܂��B  | 
              |
| 249 | 
                  +C<table> is table name, C<param> is update data, C<where> is condition.  | 
              |
| 254 | 250 | 
                   | 
              
| 255 | 
                  -����SQL�����s����܂��B  | 
              |
| 251 | 
                  +Following SQL is executed.  | 
              |
| 256 | 252 | 
                   | 
              
| 257 | 253 | 
                  update book set title = ?, author = ?;  | 
              
| 258 | 254 | 
                   | 
              
| 259 | 
                  -C<update>���\�b�h�͈�S�̂���  | 
              |
| 260 | 
                  -where��̂Ȃ�SQL�s���邱�Ƃ���Ă��܂���B  | 
              |
| 261 | 
                  -�����ׂĂ̍s��X�V�������ꍇ��  | 
              |
| 262 | 
                  -C<update_all()>��g�p�����������B  | 
              |
| 255 | 
                  +You can't execute C<update()> without C<where> for safety.  | 
              |
| 256 | 
                  +use C<update_all()> if you want to update all rows.  | 
              |
| 263 | 257 | 
                   | 
              
| 264 | 258 | 
                  $dbi->update_all(table => 'book',  | 
              
| 265 | 259 | 
                                        param  => {title => 'Perl', author => 'Ken'});
                 | 
              
| 266 | 260 | 
                   | 
              
| 267 | 
                  -=head3 �f�[�^�̍폜 C<delete()>  | 
              |
| 261 | 
                  +=head3 C<delete()>  | 
              |
| 268 | 262 | 
                   | 
              
| 269 | 
                  -�f�[�^�x�[�X�̃f�[�^��1���폜����ɂ́AC<delete()>��g�p���܂��B  | 
              |
| 263 | 
                  +use C<delete()> to delete rows from database.  | 
              |
| 270 | 264 | 
                   | 
              
| 271 | 265 | 
                  $dbi->delete(table => 'book',  | 
              
| 272 | 266 | 
                                    where  => {author => 'Ken'});
                 | 
              
| 273 | 267 | 
                   | 
              
| 274 | 
                  -C<table>�ɂ̓e�[�u�����AC<where>�ɂ͏��w�肵�܂��B  | 
              |
| 268 | 
                  +C<table> is table name, C<where> is condition.  | 
              |
| 275 | 269 | 
                   | 
              
| 276 | 
                  -����SQL�����s����܂��B  | 
              |
| 270 | 
                  +Following SQL is executed.  | 
              |
| 277 | 271 | 
                   | 
              
| 278 | 272 | 
                  delete from book where id = ?;  | 
              
| 279 | 273 | 
                   | 
              
| 280 | 
                  -C<delete>���\�b�h�͈�S�̂���  | 
              |
| 281 | 
                  -where��̂Ȃ�SQL�s���邱�Ƃ���Ă��܂���B  | 
              |
| 282 | 
                  -�����ׂĂ̍s��폜�������ꍇ��  | 
              |
| 283 | 
                  -C<delete_all()>��g�p�����������B  | 
              |
| 274 | 
                  +You can't execute C<delete()> without C<where> for safety.  | 
              |
| 275 | 
                  +use C<delete_all()> if you want to delete all rows.  | 
              |
| 284 | 276 | 
                   | 
              
| 285 | 277 | 
                  $dbi->delete_all(table => 'book');  | 
              
| 286 | 278 | 
                   | 
              
| 287 | 
                  -=head3 �f�[�^�̑I�� C<select()>  | 
              |
| 279 | 
                  +=head3 C<select()>  | 
              |
| 288 | 280 | 
                   | 
              
| 289 | 
                  -�s��I���ɂ�C<select()>��g�p���܂��B  | 
              |
| 281 | 
                  +use C<select()> to select rows from database  | 
              |
| 290 | 282 | 
                   | 
              
| 291 | 283 | 
                  my $result = $dbi->select(table => 'book');  | 
              
| 292 | 284 | 
                   | 
              
| 293 | 
                  -C<table>������w�肵�āA���̏��w�肵�Ȃ��ꍇ�͎���SQL�����s����܂��B  | 
              |
| 285 | 
                  +Following SQL is executed.  | 
              |
| 294 | 286 | 
                   | 
              
| 295 | 287 | 
                  select * from book;  | 
              
| 296 | 288 | 
                   | 
              
| 297 | 
                  -C<select()>���\�b�h�̖߂�l��L<DBIx::Custom::Result>  | 
              |
| 298 | 
                  -�I�u�W�F�N�g�ł��B�s��t�F�b�`����ɂ�C<fetch()>��g�p���܂��B  | 
              |
| 289 | 
                  +Return value is L<DBIx::Custom::Result> object.  | 
              |
| 290 | 
                  +use C<fetch()> to fetch row.  | 
              |
| 299 | 291 | 
                   | 
              
| 300 | 292 | 
                       while (my $row = $result->fetch) {
                 | 
              
| 301 | 293 | 
                  my $title = $row->[0];  | 
              
| 302 | 294 | 
                  my $author = $row->[1];  | 
              
| 303 | 295 | 
                  }  | 
              
| 304 | 296 | 
                   | 
              
| 305 | 
                  -L<DBIx::Custom::Result>�ɂ��Ă͂��̌�L<3. �s�̃t�F�b�`/"3. �s�̃t�F�b�`">�ŏڂ��������܂��B  | 
              |
| 297 | 
                  +See L<3. Fetch row/"3. Fetch row"> about L<DBIx::Custom::Result>.  | 
              |
| 306 | 298 | 
                   | 
              
| 307 | 
                  -���܂��܂�C<select()>�̎g�����Ă����܂��傤�B  | 
              |
| 308 | 
                  -����C<select>�͍s�̖��O��where���w�肵����̂ł��B  | 
              |
| 299 | 
                  +Continue more examples.  | 
              |
| 309 | 300 | 
                   | 
              
| 310 | 301 | 
                  my $result = $dbi->select(  | 
              
| 311 | 302 | 
                  table => 'book',  | 
              
| ... | ... | 
                  @@ -313,26 +304,27 @@ L<DBIx::Custom::Result>  | 
              
| 313 | 304 | 
                           where  => {author => 'Ken'}
                 | 
              
| 314 | 305 | 
                  );  | 
              
| 315 | 306 | 
                   | 
              
| 316 | 
                  -C<column>�ɂ͗�AC<where>�ɂ͏��w�肷�邱�Ƃ��ł��܂��B  | 
              |
| 317 | 
                  -����SQL�����s����܂��B  | 
              |
| 307 | 
                  +C<column> is column names, C<where> is condition.  | 
              |
| 308 | 
                  +  | 
              |
| 309 | 
                  +Following SQL is executed.  | 
              |
| 318 | 310 | 
                   | 
              
| 319 | 311 | 
                  select author, title from book where author = ?;  | 
              
| 320 | 312 | 
                   | 
              
| 321 | 
                  -�e�[�u������������ꍇ�͂�C<relation>�Ƀe�[�u����  | 
              |
| 322 | 
                  -�W��L�q���܂��B  | 
              |
| 313 | 
                  +Next example.  | 
              |
| 323 | 314 | 
                   | 
              
| 324 | 315 | 
                  my $result = $dbi->select(  | 
              
| 325 | 316 | 
                  table => ['book', 'rental'],  | 
              
| 326 | 
                  -        where    => {book.name => 'Perl'},
                 | 
              |
| 317 | 
                  +        where    => {'book.name' => 'Perl'},
                 | 
              |
| 327 | 318 | 
                           relation => {'book.id' => 'rental.book_id'}
                 | 
              
| 328 | 319 | 
                  );  | 
              
| 329 | 320 | 
                   | 
              
| 330 | 
                  -book�e�[�u����id���rental�e�[�u����book_id���֘A�t�����܂��B  | 
              |
| 331 | 
                  -����SQL�����s����܂��B  | 
              |
| 321 | 
                  +C<relation> is relation of tables. This is inner join.  | 
              |
| 322 | 
                  +  | 
              |
| 323 | 
                  +Following SQL is executed.  | 
              |
| 332 | 324 | 
                   | 
              
| 333 | 325 | 
                  select * from book, rental where book.name = ? and book.id = rental.book_id;  | 
              
| 334 | 326 | 
                   | 
              
| 335 | 
                  -SQL���̖���ɕ������lj�������ꍇ��<append>��g�p���܂��B  | 
              |
| 327 | 
                  +Next example.  | 
              |
| 336 | 328 | 
                   | 
              
| 337 | 329 | 
                  my $result = $dbi->select(  | 
              
| 338 | 330 | 
                  table => 'book',  | 
              
| ... | ... | 
                  @@ -340,44 +332,37 @@ SQL  | 
              
| 340 | 332 | 
                  append => 'for update',  | 
              
| 341 | 333 | 
                  );  | 
              
| 342 | 334 | 
                   | 
              
| 343 | 
                  -����SQL�����s����܂��B  | 
              |
| 335 | 
                  +C<append> is string appending to end of SQL.  | 
              |
| 336 | 
                  +  | 
              |
| 337 | 
                  +Following SQL is executed.  | 
              |
| 344 | 338 | 
                   | 
              
| 345 | 339 | 
                  select * book where author = ? for update;  | 
              
| 346 | 340 | 
                   | 
              
| 347 | 
                  -�܂�C<append>�́AC<select>�����łȂ�C<insert()>�AC<update()>�AC<update_all()>  | 
              |
| 348 | 
                  -C<delete()>�AC<delete_all()>�AC<select()>�Ŏg�p���邱�Ƃ�ł��܂��B  | 
              |
| 341 | 
                  +C<appned> is also used at C<insert()>, C<update()>, C<update_all()>  | 
              |
| 342 | 
                  +C<delete()>, C<delete_all()>, and C<select()>.  | 
              |
| 349 | 343 | 
                   | 
              
| 350 | 
                  -=head3 SQL�̎�s C<execute()>  | 
              |
| 344 | 
                  +=head3 C<execute()> SQL  | 
              |
| 351 | 345 | 
                   | 
              
| 352 | 
                  -�C�ӂ�SQL���s����ɂ�execute���\�b�h��g�p���܂��B  | 
              |
| 346 | 
                  +use C<execute()> to execute SQL  | 
              |
| 353 | 347 | 
                   | 
              
| 354 | 348 | 
                       $dbi->execute("select * from book;");
                 | 
              
| 355 | 349 | 
                   | 
              
| 356 | 
                  -C<execute()>��L<DBIx::Custom>�̍����̃��\�b�h�ł���^�O��W�J���܂��B  | 
              |
| 350 | 
                  +Process tag and execute SQL.  | 
              |
| 357 | 351 | 
                   | 
              
| 358 | 352 | 
                  $dbi->execute(  | 
              
| 359 | 353 | 
                           "select * from book {= title} and {= author};"
                 | 
              
| 360 | 354 | 
                           param => {title => 'Perl', author => 'Ken'}
                 | 
              
| 361 | 355 | 
                  );  | 
              
| 362 | 356 | 
                   | 
              
| 363 | 
                  -��L�̃^�O��܂�SQL�͎��̂悤�ɓW�J����܂��B  | 
              |
| 357 | 
                  +Following SQL is executed.  | 
              |
| 364 | 358 | 
                   | 
              
| 365 | 359 | 
                  select * from book title = ? and author = ?;  | 
              
| 366 | 360 | 
                   | 
              
| 367 | 
                  -SQL����s�����Ƃ��Ƀv���[�X�z���_(?)�ɑΉ�����ʒu��title��author  | 
              |
| 368 | 
                  -�̒l���������I�ɖ��ߍ��܂�܂��B  | 
              |
| 369 | 
                  -  | 
              |
| 370 | 
                  -�^�O�ɂ��Ă�L<5. �^�O/"5. �^�O">�ŏڂ�������܂����A  | 
              |
| 371 | 
                  -�ЂƂ̒��ӓ_������܂��B  | 
              |
| 372 | 
                  -�^�O��W�J���邽�߂�C<{>��C<}>�͗\���ɂȂ�Ă��܂��B
                 | 
              |
| 373 | 
                  -�����p�������ꍇ�͒��O��\����ăG�X�P�[�v��s���K�v������܂��B  | 
              |
| 374 | 
                  -  | 
              |
| 375 | 
                  -    $dbi->execute("... \\{ ... \\} ...");
                 | 
              |
| 361 | 
                  +Values of title and author is embbdeded into placeholder.  | 
              |
| 376 | 362 | 
                   | 
              
| 377 | 
                  -\���̂�Perl�̃G�X�P�[�v�����ł��̂ŁA��K�v�ɂȂ�Ƃ����_�ɒ��ӂ��Ă��������B  | 
              |
| 363 | 
                  +See L<5. Tag/"5. Tag"> about tag.  | 
              |
| 378 | 364 | 
                   | 
              
| 379 | 
                  -�܂�execute�̃L���[�g�ȋ@�\�Ƃ��āASQL�̍Ō�ɃZ�~�R��������Ȃ��Ă�  | 
              |
| 380 | 
                  -���܂��܂���B  | 
              |
| 365 | 
                  +You don't have to wirte last semicolon in C<execute()>.  | 
              |
| 381 | 366 | 
                   | 
              
| 382 | 367 | 
                       $dbi->execute('select * from book');
                 | 
              
| 383 | 368 | 
                   | 
              
| ... | ... | 
                  @@ -746,81 +731,81 @@ C<table>  | 
              
| 746 | 731 | 
                       $dbi->execute($sql, param => {title => 'Perl', author => '%Ken%'}
                 | 
              
| 747 | 732 | 
                  table => ['book']);  | 
              
| 748 | 733 | 
                   | 
              
| 749 | 
                  -=head2 �^�O�ꗗ  | 
              |
| 734 | 
                  +=head3 �^�O�ꗗ  | 
              |
| 750 | 735 | 
                   | 
              
| 751 | 736 | 
                  L<DBIx::Custom>�ł͎��̃^�O���g�p�\�ł��B  | 
              
| 752 | 737 | 
                   | 
              
| 753 | 738 | 
                  ���̂悤�Ƀ^�O��g���SQL����\������̂�L<DBIx::Custom>��  | 
              
| 754 | 739 | 
                  ����ł��B�ȉ��̃^�O�����p�\�ł��B  | 
              
| 755 | 740 | 
                   | 
              
| 756 | 
                  -=head3 C<?>  | 
              |
| 741 | 
                  +=head4 C<?>  | 
              |
| 757 | 742 | 
                   | 
              
| 758 | 743 | 
                  C<?>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 759 | 744 | 
                   | 
              
| 760 | 745 | 
                       {? NAME}    ->   ?
                 | 
              
| 761 | 746 | 
                   | 
              
| 762 | 
                  -=head3 C<=>  | 
              |
| 747 | 
                  +=head4 C<=>  | 
              |
| 763 | 748 | 
                   | 
              
| 764 | 749 | 
                  C<=>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 765 | 750 | 
                   | 
              
| 766 | 751 | 
                       {= NAME}    ->   NAME = ?
                 | 
              
| 767 | 752 | 
                   | 
              
| 768 | 
                  -=head3 C<E<lt>E<gt>>  | 
              |
| 753 | 
                  +=head4 C<E<lt>E<gt>>  | 
              |
| 769 | 754 | 
                   | 
              
| 770 | 755 | 
                  C<E<lt>E<gt>>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 771 | 756 | 
                   | 
              
| 772 | 757 | 
                       {<> NAME}   ->   NAME <> ?
                 | 
              
| 773 | 758 | 
                   | 
              
| 774 | 
                  -=head3 C<E<lt>>  | 
              |
| 759 | 
                  +=head4 C<E<lt>>  | 
              |
| 775 | 760 | 
                   | 
              
| 776 | 761 | 
                  C<E<lt>>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 777 | 762 | 
                   | 
              
| 778 | 763 | 
                       {< NAME}    ->   NAME < ?
                 | 
              
| 779 | 764 | 
                   | 
              
| 780 | 
                  -=head3 C<E<gt>>  | 
              |
| 765 | 
                  +=head4 C<E<gt>>  | 
              |
| 781 | 766 | 
                   | 
              
| 782 | 767 | 
                  C<E<gt>>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 783 | 768 | 
                   | 
              
| 784 | 769 | 
                       {> NAME}    ->   NAME > ?
                 | 
              
| 785 | 770 | 
                   | 
              
| 786 | 
                  -=head3 C<E<gt>=>  | 
              |
| 771 | 
                  +=head4 C<E<gt>=>  | 
              |
| 787 | 772 | 
                   | 
              
| 788 | 773 | 
                  C<E<gt>=>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 789 | 774 | 
                   | 
              
| 790 | 775 | 
                       {>= NAME}   ->   NAME >= ?
                 | 
              
| 791 | 776 | 
                   | 
              
| 792 | 
                  -=head3 C<E<lt>=>  | 
              |
| 777 | 
                  +=head4 C<E<lt>=>  | 
              |
| 793 | 778 | 
                   | 
              
| 794 | 779 | 
                  C<E<lt>=>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 795 | 780 | 
                   | 
              
| 796 | 781 | 
                       {<= NAME}   ->   NAME <= ?
                 | 
              
| 797 | 782 | 
                   | 
              
| 798 | 
                  -=head3 C<like>  | 
              |
| 783 | 
                  +=head4 C<like>  | 
              |
| 799 | 784 | 
                   | 
              
| 800 | 785 | 
                  C<like>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 801 | 786 | 
                   | 
              
| 802 | 787 | 
                       {like NAME}   ->   NAME like ?
                 | 
              
| 803 | 788 | 
                   | 
              
| 804 | 
                  -=head3 C<in>  | 
              |
| 789 | 
                  +=head4 C<in>  | 
              |
| 805 | 790 | 
                   | 
              
| 806 | 791 | 
                  C<in>�^�O�͈ȉ��̂悤�ɓW�J����܂��B�v���[�X�z���_��  | 
              
| 807 | 792 | 
                  �����Ŏw�肷��K�v�����邱�Ƃɒ��ӂ��Ă��������B  | 
              
| 808 | 793 | 
                   | 
              
| 809 | 794 | 
                       {in NAME COUNT}   ->   NAME in [?, ?, ..]
                 | 
              
| 810 | 795 | 
                   | 
              
| 811 | 
                  -=head3 C<insert_param>  | 
              |
| 796 | 
                  +=head4 C<insert_param>  | 
              |
| 812 | 797 | 
                   | 
              
| 813 | 798 | 
                  C<insert_param>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 814 | 799 | 
                   | 
              
| 815 | 800 | 
                       {insert_param NAME1 NAME2}   ->   (NAME1, NAME2) values (?, ?)
                 | 
              
| 816 | 801 | 
                   | 
              
| 817 | 
                  -=head3 C<update_param>  | 
              |
| 802 | 
                  +=head4 C<update_param>  | 
              |
| 818 | 803 | 
                   | 
              
| 819 | 804 | 
                  C<update_param>�^�O�͈ȉ��̂悤�ɓW�J����܂��B  | 
              
| 820 | 805 | 
                   | 
              
| 821 | 806 | 
                       {update_param NAME1 NAME2}   ->   set NAME1 = ?, NAME2 = ?
                 | 
              
| 822 | 807 | 
                   | 
              
| 823 | 
                  -=head2 �����̗�̈���  | 
              |
| 808 | 
                  +=head3 �����̗�̈���  | 
              |
| 824 | 809 | 
                   | 
              
| 825 | 810 | 
                  �����̗��܂ރ^�O������ꍇ�ɂ�ASQL���s���邱�Ƃ��ł��܂��B  | 
              
| 826 | 811 | 
                  ���Ƃ��A��̓�t�Ŕ�r���Ȃ���Ȃ�Ȃ��ꍇ��  | 
              
| ... | ... | 
                  @@ -832,7 +817,7 @@ C<update_param>  | 
              
| 832 | 817 | 
                   | 
              
| 833 | 818 | 
                       my $dbi->execute($sql, param => {date => ['2010-10-01', '2012-02-10']});
                 | 
              
| 834 | 819 | 
                   | 
              
| 835 | 
                  -=head2 �^�O�̒lj� C<register_tag()>  | 
              |
| 820 | 
                  +=head3 �^�O�̒lj� C<register_tag()>  | 
              |
| 836 | 821 | 
                   | 
              
| 837 | 822 | 
                  L<DBIx::Custom>�ł̓^�O��Ǝ��ɒlj���邱�Ƃ��ł��܂��B  | 
              
| 838 | 823 | 
                  �^�O��lj����ɂ�C<register_tag()>��g�p���܂��B  | 
              
| ... | ... | 
                  @@ -15,7 +15,7 @@ L<DBIx::Custom>はO/Rマッパーではありません。O/Rマッパーは  | 
              
| 15 | 15 | 
                  便利ですが、O/Rマッパのたくさんの文法を覚える必要があります。  | 
              
| 16 | 16 | 
                  また、O/Rマッパによって生成されたSQLは非効率なことがありますし、  | 
              
| 17 | 17 | 
                  複雑なSQLを生成することができないので、  | 
              
| 18 | 
                  -生のSQLを発行しなければならない場合がたくさんあります。  | 
              |
| 18 | 
                  +生のSQLを実行しなければならない場合がたくさんあります。  | 
              |
| 19 | 19 | 
                   | 
              
| 20 | 20 | 
                  L<DBIx::Custom>はO/Rマッパとは対照的な設計が行われています。  | 
              
| 21 | 21 | 
                  L<DBIx::Custom>の主な目的は、SQLを尊重しつつ、L<DBI>だけでは  | 
              
| ... | ... | 
                  @@ -99,7 +99,7 @@ titleだけの場合は次のSQLを  | 
              
| 99 | 99 | 
                   | 
              
| 100 | 100 | 
                  select * from book where title = ?;  | 
              
| 101 | 101 | 
                   | 
              
| 102 | 
                  -authorだけの場合は次のSQLを発行した場合を考えましょう。  | 
              |
| 102 | 
                  +authorだけの場合は次のSQLを実行した場合を考えましょう。  | 
              |
| 103 | 103 | 
                   | 
              
| 104 | 104 | 
                  select * from book where author = ?;  | 
              
| 105 | 105 | 
                   | 
              
| ... | ... | 
                  @@ -224,41 +224,37 @@ SQLが実行されると自動的にコミットされます。  | 
              
| 224 | 224 | 
                   | 
              
| 225 | 225 | 
                  =head2 2. 挿入、更新、削除、選択のためのメソッド  | 
              
| 226 | 226 | 
                   | 
              
| 227 | 
                  -L<DBIx::Custom>は、  | 
              |
| 228 | 
                  -C<insert()>、C<update()>、C<delete()>、C<select()>  | 
              |
| 229 | 
                  -のような挿入、更新、削除、選択を行うためのメソッドを持っています。  | 
              |
| 230 | 
                  -簡単なことをを行うのであれば、SQLを自分で記述する必要がありません。  | 
              |
| 227 | 
                  +下記のメソッドがあります。  | 
              |
| 231 | 228 | 
                   | 
              
| 232 | 
                  -=head3 データの挿入 C<insert()>  | 
              |
| 229 | 
                  +=head3 行の挿入 C<insert()>  | 
              |
| 233 | 230 | 
                   | 
              
| 234 | 
                  -データベースにデータを挿入するにはC<insert()>を使用します。  | 
              |
| 231 | 
                  +データベースに行を挿入するにはC<insert()>を使用します。  | 
              |
| 235 | 232 | 
                   | 
              
| 236 | 233 | 
                  $dbi->insert(table => 'book',  | 
              
| 237 | 234 | 
                                    param  => {title => 'Perl', author => 'Ken'});
                 | 
              
| 238 | 235 | 
                   | 
              
| 239 | 
                  -C<table>にはテーブル名、C<param>には挿入したいデータを指定します。  | 
              |
| 236 | 
                  +C<table>はテーブル名、C<param>は挿入する行のデータです。  | 
              |
| 240 | 237 | 
                   | 
              
| 241 | 
                  -次のSQLが発行されます。  | 
              |
| 238 | 
                  +次のSQLが実行されます。  | 
              |
| 242 | 239 | 
                   | 
              
| 243 | 240 | 
                  insert into (title, author) values (?, ?);  | 
              
| 244 | 241 | 
                   | 
              
| 245 | 242 | 
                  =head3 データの更新 C<update()>  | 
              
| 246 | 243 | 
                   | 
              
| 247 | 
                  -データベースのデータを更新するには、C<update()>を使用します。  | 
              |
| 244 | 
                  +データベースの行を更新するには、C<update()>を使用します。  | 
              |
| 248 | 245 | 
                   | 
              
| 249 | 246 | 
                  $dbi->update(table => 'book',  | 
              
| 250 | 247 | 
                                    param  => {title => 'Perl', author => 'Ken'}, 
                 | 
              
| 251 | 248 | 
                                    where  => {id => 5});
                 | 
              
| 252 | 249 | 
                   | 
              
| 253 | 
                  -C<table>にはテーブル名、C<param>には挿入したいデータ、C<where>には  | 
              |
| 254 | 
                  -条件を指定します。  | 
              |
| 250 | 
                  +C<table>はテーブル名、C<param>は更新データ、C<where>は  | 
              |
| 251 | 
                  +条件です。  | 
              |
| 255 | 252 | 
                   | 
              
| 256 | 
                  -次のSQLが発行されます。  | 
              |
| 253 | 
                  +次のSQLが実行されます。  | 
              |
| 257 | 254 | 
                   | 
              
| 258 | 255 | 
                  update book set title = ?, author = ?;  | 
              
| 259 | 256 | 
                   | 
              
| 260 | 
                  -C<update>メソッドは安全のため  | 
              |
| 261 | 
                  -where句のないSQLを発行することを許可していません。  | 
              |
| 257 | 
                  +安全のためC<where>のないupdate()を実効することはできません。  | 
              |
| 262 | 258 | 
                  もしすべての行を更新したい場合は  | 
              
| 263 | 259 | 
                  C<update_all()>を使用してください。  | 
              
| 264 | 260 | 
                   | 
              
| ... | ... | 
                  @@ -267,19 +263,18 @@ C<update_all()>を使用してください。  | 
              
| 267 | 263 | 
                   | 
              
| 268 | 264 | 
                  =head3 データの削除 C<delete()>  | 
              
| 269 | 265 | 
                   | 
              
| 270 | 
                  -データベースのデータを1件削除するには、C<delete()>を使用します。  | 
              |
| 266 | 
                  +データベースの行を1件削除するには、C<delete()>を使用します。  | 
              |
| 271 | 267 | 
                   | 
              
| 272 | 268 | 
                  $dbi->delete(table => 'book',  | 
              
| 273 | 269 | 
                                    where  => {author => 'Ken'});
                 | 
              
| 274 | 270 | 
                   | 
              
| 275 | 
                  -C<table>にはテーブル名、C<where>には条件を指定します。  | 
              |
| 271 | 
                  +C<table>はテーブル名、C<where>は条件です。  | 
              |
| 276 | 272 | 
                   | 
              
| 277 | 
                  -次のSQLが発行されます。  | 
              |
| 273 | 
                  +次のSQLが実行されます。  | 
              |
| 278 | 274 | 
                   | 
              
| 279 | 275 | 
                  delete from book where id = ?;  | 
              
| 280 | 276 | 
                   | 
              
| 281 | 
                  -C<delete>メソッドは安全のため  | 
              |
| 282 | 
                  -where句のないSQLを発行することを許可していません。  | 
              |
| 277 | 
                  +安全のためC<where>のないC<delete()>を実効することはできません。  | 
              |
| 283 | 278 | 
                  もしすべての行を削除したい場合は  | 
              
| 284 | 279 | 
                  C<delete_all()>を使用してください。  | 
              
| 285 | 280 | 
                   | 
              
| ... | ... | 
                  @@ -291,11 +286,11 @@ C<delete_all()>を使用してください。  | 
              
| 291 | 286 | 
                   | 
              
| 292 | 287 | 
                  my $result = $dbi->select(table => 'book');  | 
              
| 293 | 288 | 
                   | 
              
| 294 | 
                  -C<table>だけを指定して、他の条件を指定しない場合は次のSQLが発行されます。  | 
              |
| 289 | 
                  +次のSQLが実行されます。  | 
              |
| 295 | 290 | 
                   | 
              
| 296 | 291 | 
                  select * from book;  | 
              
| 297 | 292 | 
                   | 
              
| 298 | 
                  -C<select()>メソッドの戻り値はL<DBIx::Custom::Result>  | 
              |
| 293 | 
                  +戻り値はL<DBIx::Custom::Result>  | 
              |
| 299 | 294 | 
                  オブジェクトです。行をフェッチするにはC<fetch()>を使用します。  | 
              
| 300 | 295 | 
                   | 
              
| 301 | 296 | 
                       while (my $row = $result->fetch) {
                 | 
              
| ... | ... | 
                  @@ -303,10 +298,9 @@ C<select()>メソッドの戻り値はL<DBIx::Custom::Result>  | 
              
| 303 | 298 | 
                  my $author = $row->[1];  | 
              
| 304 | 299 | 
                  }  | 
              
| 305 | 300 | 
                   | 
              
| 306 | 
                  -L<DBIx::Custom::Result>についてはこの後L<3. 行のフェッチ/"3. 行のフェッチ">で詳しく扱います。  | 
              |
| 301 | 
                  +L<DBIx::Custom::Result>についてはL<3. 行のフェッチ/"3. 行のフェッチ">を見てください。  | 
              |
| 307 | 302 | 
                   | 
              
| 308 | 
                  -さまざまなC<select()>の使い方を見ていきましょう。  | 
              |
| 309 | 
                  -次のC<select>は行の名前とwhere句を指定したものです。  | 
              |
| 303 | 
                  +サンプルを続けます。  | 
              |
| 310 | 304 | 
                   | 
              
| 311 | 305 | 
                  my $result = $dbi->select(  | 
              
| 312 | 306 | 
                  table => 'book',  | 
              
| ... | ... | 
                  @@ -314,13 +308,13 @@ L<DBIx::Custom::Result>についてはこの後L<3. 行のフェッチ/"3. 行  | 
              
| 314 | 308 | 
                           where  => {author => 'Ken'}
                 | 
              
| 315 | 309 | 
                  );  | 
              
| 316 | 310 | 
                   | 
              
| 317 | 
                  -C<column>には列名を、C<where>には条件を指定することができます。  | 
              |
| 318 | 
                  -次のSQLが発行されます。  | 
              |
| 311 | 
                  +C<column>は列名、C<where>は条件です。  | 
              |
| 312 | 
                  +  | 
              |
| 313 | 
                  +次のSQLが実行されます。  | 
              |
| 319 | 314 | 
                   | 
              
| 320 | 315 | 
                  select author, title from book where author = ?;  | 
              
| 321 | 316 | 
                   | 
              
| 322 | 
                  -テーブルを結合したい場合ははC<relation>にテーブルの  | 
              |
| 323 | 
                  -関係を記述します。  | 
              |
| 317 | 
                  +次のサンプルです。  | 
              |
| 324 | 318 | 
                   | 
              
| 325 | 319 | 
                  my $result = $dbi->select(  | 
              
| 326 | 320 | 
                  table => ['book', 'rental'],  | 
              
| ... | ... | 
                  @@ -328,12 +322,16 @@ C<column>には列名を、C<where>には条件を指定することができま  | 
              
| 328 | 322 | 
                           relation => {'book.id' => 'rental.book_id'}
                 | 
              
| 329 | 323 | 
                  );  | 
              
| 330 | 324 | 
                   | 
              
| 325 | 
                  +C<relation>テーブル間の関係です。これは内部結合です。  | 
              |
| 326 | 
                  +  | 
              |
| 327 | 
                  +次のSQLが実行されます。  | 
              |
| 328 | 
                  +  | 
              |
| 331 | 329 | 
                  bookテーブルのid列とrentalテーブルのbook_idが関連付けられます。  | 
              
| 332 | 
                  -次のSQLが発行されます。  | 
              |
| 330 | 
                  +次のSQLが実行されます。  | 
              |
| 333 | 331 | 
                   | 
              
| 334 | 332 | 
                  select * from book, rental where book.name = ? and book.id = rental.book_id;  | 
              
| 335 | 333 | 
                   | 
              
| 336 | 
                  -SQL文の末尾に文字列を追加したい場合は<append>を使用します。  | 
              |
| 334 | 
                  +次のサンプルです。  | 
              |
| 337 | 335 | 
                   | 
              
| 338 | 336 | 
                  my $result = $dbi->select(  | 
              
| 339 | 337 | 
                  table => 'book',  | 
              
| ... | ... | 
                  @@ -341,7 +339,9 @@ SQL文の末尾に文字列を追加したい場合は<append>を使用します  | 
              
| 341 | 339 | 
                  append => 'for update',  | 
              
| 342 | 340 | 
                  );  | 
              
| 343 | 341 | 
                   | 
              
| 344 | 
                  -次のSQLが発行されます。  | 
              |
| 342 | 
                  +C<append>はSQLの末尾に追加される文字列です。  | 
              |
| 343 | 
                  +  | 
              |
| 344 | 
                  +次のSQLが実行されます。  | 
              |
| 345 | 345 | 
                   | 
              
| 346 | 346 | 
                  select * book where author = ? for update;  | 
              
| 347 | 347 | 
                   | 
              
| ... | ... | 
                  @@ -350,35 +350,26 @@ C<delete()>、C<delete_all()>、C<select()>で使用することもできます  | 
              
| 350 | 350 | 
                   | 
              
| 351 | 351 | 
                  =head3 SQLの実行 C<execute()>  | 
              
| 352 | 352 | 
                   | 
              
| 353 | 
                  -任意のSQLを実行するにはexecuteメソッドを使用します。  | 
              |
| 353 | 
                  +SQLを実行するにはC<execute()>を使用します。  | 
              |
| 354 | 354 | 
                   | 
              
| 355 | 355 | 
                       $dbi->execute("select * from book;");
                 | 
              
| 356 | 356 | 
                   | 
              
| 357 | 
                  -C<execute()>はL<DBIx::Custom>の根幹のメソッドでありタグを展開します。  | 
              |
| 357 | 
                  +タグを処理してSQLを実行します。  | 
              |
| 358 | 358 | 
                   | 
              
| 359 | 359 | 
                  $dbi->execute(  | 
              
| 360 | 360 | 
                           "select * from book {= title} and {= author};"
                 | 
              
| 361 | 361 | 
                           param => {title => 'Perl', author => 'Ken'}
                 | 
              
| 362 | 362 | 
                  );  | 
              
| 363 | 363 | 
                   | 
              
| 364 | 
                  -上記のタグを含んだSQLは次のように展開されます。  | 
              |
| 364 | 
                  +次のSQLが実行されます。  | 
              |
| 365 | 365 | 
                   | 
              
| 366 | 366 | 
                  select * from book title = ? and author = ?;  | 
              
| 367 | 367 | 
                   | 
              
| 368 | 
                  -SQLが実行されるときにプレースホルダ(?)に対応する位置にtitleとauthor  | 
              |
| 369 | 
                  -の値がが自動的に埋め込まれます。  | 
              |
| 370 | 
                  -  | 
              |
| 371 | 
                  -タグについてはL<5. タグ/"5. タグ">で詳しく解説しますが、  | 
              |
| 372 | 
                  -ひとつの注意点があります。  | 
              |
| 373 | 
                  -タグを展開するためにC<{>とC<}>は予約語になっています。
                 | 
              |
| 374 | 
                  -もし利用したい場合は直前に\をおいてエスケープを行う必要があります。  | 
              |
| 375 | 
                  -  | 
              |
| 376 | 
                  -    $dbi->execute("... \\{ ... \\} ...");
                 | 
              |
| 368 | 
                  +プレースホルダにtitleとauthorの値が埋め込まれます。  | 
              |
| 377 | 369 | 
                   | 
              
| 378 | 
                  -\自体がPerlのエスケープ文字ですので、二つ必要になるという点に注意してください。  | 
              |
| 370 | 
                  +タグについてはL<5. タグ/"5. タグ">を見てください。  | 
              |
| 379 | 371 | 
                   | 
              
| 380 | 
                  -またexecuteのキュートな機能として、SQLの最後にセミコロンをおかなくても  | 
              |
| 381 | 
                  -かまいません。  | 
              |
| 372 | 
                  +またC<execute()>のSQLの末尾にはセミコロンを置く必要はありません。  | 
              |
| 382 | 373 | 
                   | 
              
| 383 | 374 | 
                       $dbi->execute('select * from book');
                 | 
              
| 384 | 375 | 
                   | 
              
| ... | ... | 
                  @@ -747,81 +738,81 @@ C<table>を指定する必要があります。  | 
              
| 747 | 738 | 
                       $dbi->execute($sql, param => {title => 'Perl', author => '%Ken%'}
                 | 
              
| 748 | 739 | 
                  table => ['book']);  | 
              
| 749 | 740 | 
                   | 
              
| 750 | 
                  -=head2 タグ一覧  | 
              |
| 741 | 
                  +=head3 タグ一覧  | 
              |
| 751 | 742 | 
                   | 
              
| 752 | 743 | 
                  L<DBIx::Custom>では次のタグが使用可能です。  | 
              
| 753 | 744 | 
                   | 
              
| 754 | 745 | 
                  このようにタグを使ってSQL文を表現するのがL<DBIx::Custom>の  | 
              
| 755 | 746 | 
                  特徴です。以下のタグが利用可能です。  | 
              
| 756 | 747 | 
                   | 
              
| 757 | 
                  -=head3 C<?>  | 
              |
| 748 | 
                  +=head4 C<?>  | 
              |
| 758 | 749 | 
                   | 
              
| 759 | 750 | 
                  C<?>タグは以下のように展開されます。  | 
              
| 760 | 751 | 
                   | 
              
| 761 | 752 | 
                       {? NAME}    ->   ?
                 | 
              
| 762 | 753 | 
                   | 
              
| 763 | 
                  -=head3 C<=>  | 
              |
| 754 | 
                  +=head4 C<=>  | 
              |
| 764 | 755 | 
                   | 
              
| 765 | 756 | 
                  C<=>タグは以下のように展開されます。  | 
              
| 766 | 757 | 
                   | 
              
| 767 | 758 | 
                       {= NAME}    ->   NAME = ?
                 | 
              
| 768 | 759 | 
                   | 
              
| 769 | 
                  -=head3 C<E<lt>E<gt>>  | 
              |
| 760 | 
                  +=head4 C<E<lt>E<gt>>  | 
              |
| 770 | 761 | 
                   | 
              
| 771 | 762 | 
                  C<E<lt>E<gt>>タグは以下のように展開されます。  | 
              
| 772 | 763 | 
                   | 
              
| 773 | 764 | 
                       {<> NAME}   ->   NAME <> ?
                 | 
              
| 774 | 765 | 
                   | 
              
| 775 | 
                  -=head3 C<E<lt>>  | 
              |
| 766 | 
                  +=head4 C<E<lt>>  | 
              |
| 776 | 767 | 
                   | 
              
| 777 | 768 | 
                  C<E<lt>>タグは以下のように展開されます。  | 
              
| 778 | 769 | 
                   | 
              
| 779 | 770 | 
                       {< NAME}    ->   NAME < ?
                 | 
              
| 780 | 771 | 
                   | 
              
| 781 | 
                  -=head3 C<E<gt>>  | 
              |
| 772 | 
                  +=head4 C<E<gt>>  | 
              |
| 782 | 773 | 
                   | 
              
| 783 | 774 | 
                  C<E<gt>>タグは以下のように展開されます。  | 
              
| 784 | 775 | 
                   | 
              
| 785 | 776 | 
                       {> NAME}    ->   NAME > ?
                 | 
              
| 786 | 777 | 
                   | 
              
| 787 | 
                  -=head3 C<E<gt>=>  | 
              |
| 778 | 
                  +=head4 C<E<gt>=>  | 
              |
| 788 | 779 | 
                   | 
              
| 789 | 780 | 
                  C<E<gt>=>タグは以下のように展開されます。  | 
              
| 790 | 781 | 
                   | 
              
| 791 | 782 | 
                       {>= NAME}   ->   NAME >= ?
                 | 
              
| 792 | 783 | 
                   | 
              
| 793 | 
                  -=head3 C<E<lt>=>  | 
              |
| 784 | 
                  +=head4 C<E<lt>=>  | 
              |
| 794 | 785 | 
                   | 
              
| 795 | 786 | 
                  C<E<lt>=>タグは以下のように展開されます。  | 
              
| 796 | 787 | 
                   | 
              
| 797 | 788 | 
                       {<= NAME}   ->   NAME <= ?
                 | 
              
| 798 | 789 | 
                   | 
              
| 799 | 
                  -=head3 C<like>  | 
              |
| 790 | 
                  +=head4 C<like>  | 
              |
| 800 | 791 | 
                   | 
              
| 801 | 792 | 
                  C<like>タグは以下のように展開されます。  | 
              
| 802 | 793 | 
                   | 
              
| 803 | 794 | 
                       {like NAME}   ->   NAME like ?
                 | 
              
| 804 | 795 | 
                   | 
              
| 805 | 
                  -=head3 C<in>  | 
              |
| 796 | 
                  +=head4 C<in>  | 
              |
| 806 | 797 | 
                   | 
              
| 807 | 798 | 
                  C<in>タグは以下のように展開されます。プレースホルダの  | 
              
| 808 | 799 | 
                  数を引数で指定する必要があることに注意してください。  | 
              
| 809 | 800 | 
                   | 
              
| 810 | 801 | 
                       {in NAME COUNT}   ->   NAME in [?, ?, ..]
                 | 
              
| 811 | 802 | 
                   | 
              
| 812 | 
                  -=head3 C<insert_param>  | 
              |
| 803 | 
                  +=head4 C<insert_param>  | 
              |
| 813 | 804 | 
                   | 
              
| 814 | 805 | 
                  C<insert_param>タグは以下のように展開されます。  | 
              
| 815 | 806 | 
                   | 
              
| 816 | 807 | 
                       {insert_param NAME1 NAME2}   ->   (NAME1, NAME2) values (?, ?)
                 | 
              
| 817 | 808 | 
                   | 
              
| 818 | 
                  -=head3 C<update_param>  | 
              |
| 809 | 
                  +=head4 C<update_param>  | 
              |
| 819 | 810 | 
                   | 
              
| 820 | 811 | 
                  C<update_param>タグは以下のように展開されます。  | 
              
| 821 | 812 | 
                   | 
              
| 822 | 813 | 
                       {update_param NAME1 NAME2}   ->   set NAME1 = ?, NAME2 = ?
                 | 
              
| 823 | 814 | 
                   | 
              
| 824 | 
                  -=head2 同名の列の扱い  | 
              |
| 815 | 
                  +=head3 同名の列の扱い  | 
              |
| 825 | 816 | 
                   | 
              
| 826 | 817 | 
                  同名の列を含むタグがある場合にも、SQLを実行することができます。  | 
              
| 827 | 818 | 
                  たとえば、二つの日付で比較しなければならない場合を  | 
              
| ... | ... | 
                  @@ -833,7 +824,7 @@ C<update_param>タグは以下のように展開されます。  | 
              
| 833 | 824 | 
                   | 
              
| 834 | 825 | 
                       my $dbi->execute($sql, param => {date => ['2010-10-01', '2012-02-10']});
                 | 
              
| 835 | 826 | 
                   | 
              
| 836 | 
                  -=head2 タグの追加 C<register_tag()>  | 
              |
| 827 | 
                  +=head3 タグの追加 C<register_tag()>  | 
              |
| 837 | 828 | 
                   | 
              
| 838 | 829 | 
                  L<DBIx::Custom>ではタグを独自に追加することができます。  | 
              
| 839 | 830 | 
                  タグを追加するにはC<register_tag()>を使用します。  |