| ... | ... | 
                  @@ -3,10 +3,11 @@  | 
              
| 3 | 3 | 
                  Build  | 
              
| 4 | 4 | 
                  MANIFEST  | 
              
| 5 | 5 | 
                  META.yml  | 
              
| 6 | 
                  -Makefile.PL  | 
              |
| 7 | 6 | 
                  _build/*  | 
              
| 8 | 7 | 
                  blib/*  | 
              
| 9 | 8 | 
                  *.tar.gz  | 
              
| 10 | 9 | 
                  cover_db/*  | 
              
| 11 | 10 | 
                  *.tmp  | 
              
| 12 | 11 | 
                  t/*.db  | 
              
| 12 | 
                  +Makefile  | 
              |
| 13 | 
                  +pm_to_blib  | 
              
| ... | ... | 
                  @@ -1,3 +1,5 @@  | 
              
| 1 | 
                  +0.1620  | 
              |
| 2 | 
                  + updated document  | 
              |
| 1 | 3 | 
                  0.1619  | 
              
| 2 | 4 | 
                  updated document  | 
              
| 3 | 5 | 
                  added experimental expand method  | 
              
| ... | ... | 
                  @@ -0,0 +1,15 @@  | 
              
| 1 | 
                  +use ExtUtils::MakeMaker;  | 
              |
| 2 | 
                  +WriteMakefile  | 
              |
| 3 | 
                  +(  | 
              |
| 4 | 
                  + 'INSTALLDIRS' => 'site',  | 
              |
| 5 | 
                  + 'NAME' => 'DBIx::Custom',  | 
              |
| 6 | 
                  + 'EXE_FILES' => [],  | 
              |
| 7 | 
                  + 'VERSION_FROM' => 'lib/DBIx/Custom.pm',  | 
              |
| 8 | 
                  +          'PREREQ_PM' => {
                 | 
              |
| 9 | 
                  + 'Test::More' => 0,  | 
              |
| 10 | 
                  + 'Object::Simple' => '3.0201',  | 
              |
| 11 | 
                  + 'DBD::SQLite' => '1.25',  | 
              |
| 12 | 
                  + 'DBI' => '1.605'  | 
              |
| 13 | 
                  + }  | 
              |
| 14 | 
                  + )  | 
              |
| 15 | 
                  +;  | 
              
| ... | ... | 
                  @@ -1,6 +1,6 @@  | 
              
| 1 | 1 | 
                  package DBIx::Custom;  | 
              
| 2 | 2 | 
                   | 
              
| 3 | 
                  -our $VERSION = '0.1619';  | 
              |
| 3 | 
                  +our $VERSION = '0.1620';  | 
              |
| 4 | 4 | 
                   | 
              
| 5 | 5 | 
                  use 5.008001;  | 
              
| 6 | 6 | 
                  use strict;  | 
              
| ... | ... | 
                  @@ -179,8 +179,6 @@ C<select()>メソッドの戻り値はL<DBIx::Custom::Result>  | 
              
| 179 | 179 | 
                  'where books.id = rental.book_id;');  | 
              
| 180 | 180 | 
                  $sth->execute;  | 
              
| 181 | 181 | 
                   | 
              
| 182 | 
                  -=head3 C<append>オプション  | 
              |
| 183 | 
                  -  | 
              |
| 184 | 182 | 
                  SQL文の末尾に文字列を追加したい場合は<append>オプションを使用します。  | 
              
| 185 | 183 | 
                   | 
              
| 186 | 184 | 
                  my $result = $dbi->select(  | 
              
| ... | ... | 
                  @@ -199,8 +197,6 @@ C<append>オプションは、C<insert()>、C<update()>、C<update_all()>  | 
              
| 199 | 197 | 
                  C<delete()>、C<select>メソッドで使用することが  | 
              
| 200 | 198 | 
                  できます。  | 
              
| 201 | 199 | 
                   | 
              
| 202 | 
                  -=head3 C<filter>オプション  | 
              |
| 203 | 
                  -  | 
              |
| 204 | 200 | 
                  この後のフィルタリングの解説で詳しく扱いますが、値をフィルタリングしたい  | 
              
| 205 | 201 | 
                  場合はC<filter>オプションを使用することができます。  | 
              
| 206 | 202 | 
                   | 
              
| ... | ... | 
                  @@ -213,6 +209,19 @@ C<filter>オプションは、C<insert()>、C<update()>、C<update_all()>  | 
              
| 213 | 209 | 
                  C<delete()>、C<select>メソッドで使用することが  | 
              
| 214 | 210 | 
                  できます。  | 
              
| 215 | 211 | 
                   | 
              
| 212 | 
                  +C<select()>メソッドのC<where>オプションではハッシュの代わりに  | 
              |
| 213 | 
                  +タグを利用することもできます。これによって柔軟な  | 
              |
| 214 | 
                  +条件を指定することができます。  | 
              |
| 215 | 
                  +  | 
              |
| 216 | 
                  + # Select, more flexible where  | 
              |
| 217 | 
                  + my $result = $dbi->select(  | 
              |
| 218 | 
                  + table => 'books',  | 
              |
| 219 | 
                  +        where  => ['{= author} and {like title}', 
                 | 
              |
| 220 | 
                  +                   {author => 'Ken', title => '%Perl%'}]
                 | 
              |
| 221 | 
                  + );  | 
              |
| 222 | 
                  +  | 
              |
| 223 | 
                  +タグについては以降で解説します。  | 
              |
| 224 | 
                  +  | 
              |
| 216 | 225 | 
                  =head2 3. 行のフェッチ  | 
              
| 217 | 226 | 
                   | 
              
| 218 | 227 | 
                  C<select()>メソッドの戻り値であるL<DBIx::Custom::Result>  | 
              
| ... | ... | 
                  @@ -292,18 +301,16 @@ C<select()>メソッドの戻り値であるL<DBIx::Custom::Result>  | 
              
| 292 | 301 | 
                   | 
              
| 293 | 302 | 
                  my $rows = $result->fetch_hash_all;  | 
              
| 294 | 303 | 
                   | 
              
| 295 | 
                  -=head3 C<sth>  | 
              |
| 296 | 
                  -  | 
              |
| 297 | 
                  -L<DBI>のステートメントハンドルにアクセスしたい場合は  | 
              |
| 304 | 
                  +L<DBI>のステートメントハンドルに直接アクセスしたい場合は  | 
              |
| 298 | 305 | 
                  <sth>を使用します。  | 
              
| 299 | 306 | 
                   | 
              
| 300 | 307 | 
                  my $sth = $result->sth;  | 
              
| 301 | 308 | 
                   | 
              
| 302 | 
                  -=head2 4. Hash parameter binding  | 
              |
| 309 | 
                  +=head2 4. ハッシュパラメタバインド  | 
              |
| 303 | 310 | 
                   | 
              
| 304 | 
                  -L<DBIx::Custom> provides hash parameter binding.  | 
              |
| 311 | 
                  +L<DBIx::Custom>はハッシュパラメタバインドを提供します。  | 
              |
| 305 | 312 | 
                   | 
              
| 306 | 
                  -At frist, I show normal parameter binding.  | 
              |
| 313 | 
                  +まず最初にL<DBI>による通常のパラメタバインドをご覧ください。  | 
              |
| 307 | 314 | 
                   | 
              
| 308 | 315 | 
                  use DBI;  | 
              
| 309 | 316 | 
                  my $dbh = DBI->connect(...);  | 
              
| ... | ... | 
                  @@ -312,25 +319,31 @@ At frist, I show normal parameter binding.  | 
              
| 312 | 319 | 
                  );  | 
              
| 313 | 320 | 
                       $sth->execute('Ken', '%Perl%');
                 | 
              
| 314 | 321 | 
                   | 
              
| 315 | 
                  -This is very good way because database system can enable SQL caching,  | 
              |
| 316 | 
                  -and parameter is quoted automatically. this is secure.  | 
              |
| 322 | 
                  +これはデータベースシステムがSQLをキャッシュすることができ、  | 
              |
| 323 | 
                  +パラメータは自動的にクォートされるので、  | 
              |
| 324 | 
                  +パフォーマンス面でも、セキュリティ面でも  | 
              |
| 325 | 
                  +とても良い方法です。  | 
              |
| 317 | 326 | 
                   | 
              
| 318 | 
                  -L<DBIx::Custom> hash parameter binding system improve  | 
              |
| 319 | 
                  -normal parameter binding to use hash parameter.  | 
              |
| 327 | 
                  +  | 
              |
| 328 | 
                  +L<DBIx::Custom>はこれを改善して、ハッシュで  | 
              |
| 329 | 
                  +パラメタを指定できるようにしました。  | 
              |
| 320 | 330 | 
                   | 
              
| 321 | 331 | 
                  my $result = $dbi->execute(  | 
              
| 322 | 332 | 
                           "select * from books where {= author} and {like title};"
                 | 
              
| 323 | 333 | 
                           param => {author => 'Ken', title => '%Perl%'}
                 | 
              
| 324 | 334 | 
                  );  | 
              
| 325 | 335 | 
                   | 
              
| 326 | 
                  -This is same as the normal way, execpt that the parameter is hash.  | 
              |
| 327 | 
                  -{= author} and {like title} is called C<tag>.
                 | 
              |
| 328 | 
                  -tag is expand to placeholder string internally.  | 
              |
| 336 | 
                  +C<{= author}>とC<{like title}>はタグと呼ばれます。
                 | 
              |
| 337 | 
                  +タグは内部ではプレースホルダを含む文字列に置き換えられます。  | 
              |
| 329 | 338 | 
                   | 
              
| 330 | 339 | 
                       select * from books where {= author} and {like title}
                 | 
              
| 331 | 
                  - -> select * from books where author = ? and title like ?;  | 
              |
| 332 | 340 | 
                   | 
              
| 333 | 
                  -The following tags is available.  | 
              |
| 341 | 
                  +という文は以下のSQLに置き換えられます。  | 
              |
| 342 | 
                  +  | 
              |
| 343 | 
                  + select * from books where author = ? and title like ?;  | 
              |
| 344 | 
                  +  | 
              |
| 345 | 
                  +このようにタグを使ってSQL文を表現するのがL<DBIx::Custom>の  | 
              |
| 346 | 
                  +特徴です。以下のタグが利用可能です。  | 
              |
| 334 | 347 | 
                   | 
              
| 335 | 348 | 
                  [TAG] [REPLACED]  | 
              
| 336 | 349 | 
                       {? NAME}               ->   ?
                 | 
              
| ... | ... | 
                  @@ -348,22 +361,29 @@ The following tags is available.  | 
              
| 348 | 361 | 
                       {insert_param NAME1 NAME2}   ->   (NAME1, NAME2) values (?, ?)
                 | 
              
| 349 | 362 | 
                       {update_param NAME1 NAME2}   ->   set NAME1 = ?, NAME2 = ?
                 | 
              
| 350 | 363 | 
                   | 
              
| 351 | 
                  -See also L<DBIx::Custom::QueryBuilder>.  | 
              |
| 364 | 
                  +これらの変換はL<DBIx::Custom::QueryBuilder>によって行われます。  | 
              |
| 352 | 365 | 
                   | 
              
| 353 | 
                  -C<{> and C<}> is reserved. If you use these charactors,
                 | 
              |
| 354 | 
                  -you must escape them using '\'. Note that '\' is  | 
              |
| 355 | 
                  -already perl escaped charactor, so you must write '\\'.  | 
              |
| 366 | 
                  +C<{>とC<}>は予約語です。これらの文字を使いたい場合は
                 | 
              |
| 367 | 
                  +「\」を使ってエスケープする必要があります。  | 
              |
| 368 | 
                  +'\'はPerlのエスケープ文字なので、  | 
              |
| 369 | 
                  +エスケープするためには'\\'と書く必要があることに注意  | 
              |
| 370 | 
                  +してください。  | 
              |
| 356 | 371 | 
                   | 
              
| 357 | 372 | 
                       'select * from books \\{ something statement \\}'
                 | 
              
| 358 | 373 | 
                   | 
              
| 359 | 
                  -=head2 5. Filtering  | 
              |
| 374 | 
                  +=head2 5. フィルタリング  | 
              |
| 375 | 
                  +  | 
              |
| 376 | 
                  +=head3 パラメタバインド時のフィルタリング  | 
              |
| 360 | 377 | 
                   | 
              
| 361 | 
                  -Usually, Perl string is kept as internal string.  | 
              |
| 362 | 
                  -If you want to save the string to database, You must encode the string.  | 
              |
| 363 | 
                  -Filtering system help you to convert a data to another data  | 
              |
| 364 | 
                  -when you save to the data and get the data form database.  | 
              |
| 378 | 
                  +データベースに登録するデータをフィルタリングしたい場合  | 
              |
| 379 | 
                  +があります。たとえば、内部文字列で文字列を保持している場合は  | 
              |
| 380 | 
                  +データベースにデータを登録する前に、バイト文字列に変換する  | 
              |
| 381 | 
                  +必要があります。L<DBIx::Custom>のフィルタリングシステムは  | 
              |
| 382 | 
                  +あるデータを他のデータに変換するのを手助けしてくれます。  | 
              |
| 365 | 383 | 
                   | 
              
| 366 | 
                  -If you want to register filter, use C<register_filter()> method.  | 
              |
| 384 | 
                  +フィルタリングを利用するにはまず、  | 
              |
| 385 | 
                  +C<register_filter()>メソッドを使用して  | 
              |
| 386 | 
                  +フィルタを登録しておく必要があります。  | 
              |
| 367 | 387 | 
                   | 
              
| 368 | 388 | 
                  $dbi->register_filter(  | 
              
| 369 | 389 | 
                           to_upper_case => sub {
                 | 
              
| ... | ... | 
                  @@ -372,9 +392,11 @@ If you want to register filter, use C<register_filter()> method.  | 
              
| 372 | 392 | 
                  }  | 
              
| 373 | 393 | 
                  );  | 
              
| 374 | 394 | 
                   | 
              
| 375 | 
                  -C<encode_utf8> and C<decode_utf8> filter is registerd by default.  | 
              |
| 395 | 
                  +デフォルトのフィルタとしてC<encode_utf8>とC<decode_utf8>  | 
              |
| 396 | 
                  +が登録されています。  | 
              |
| 376 | 397 | 
                   | 
              
| 377 | 
                  -You can specify these filters to C<filter> argument of C<execute()> method.  | 
              |
| 398 | 
                  +登録されているフィルタはC<execute()>メソッドのC<filter>オプション  | 
              |
| 399 | 
                  +で指定することができます。  | 
              |
| 378 | 400 | 
                   | 
              
| 379 | 401 | 
                  my $result = $dbi->execute(  | 
              
| 380 | 402 | 
                           "select * from books where {= author} and {like title};"
                 | 
              
| ... | ... | 
                  @@ -382,16 +404,20 @@ You can specify these filters to C<filter> argument of C<execute()> method.  | 
              
| 382 | 404 | 
                           filter => {author => 'to_upper_case, title => 'encode_utf8'}
                 | 
              
| 383 | 405 | 
                  );  | 
              
| 384 | 406 | 
                   | 
              
| 385 | 
                  -C<filter> argument can be specified to suger methods, such as  | 
              |
| 386 | 
                  -C<insert()>, C<update()>, C<update_all()>,  | 
              |
| 387 | 
                  -C<delete()>, C<delete_all()>, C<select()>.  | 
              |
| 407 | 
                  +この例ではC<author>の値はバインドされるときに大文字に変換され、  | 
              |
| 408 | 
                  +C<title>の値はバイト文字列に変換されます。  | 
              |
| 409 | 
                  +  | 
              |
| 410 | 
                  +C<filter>オプションは  | 
              |
| 411 | 
                  +C<insert()>、C<update()>、 C<update_all()>,  | 
              |
| 412 | 
                  +C<delete()>、C<select()>  | 
              |
| 413 | 
                  +メソッドにおいても使用することができます。  | 
              |
| 388 | 414 | 
                   | 
              
| 389 | 
                  - # insert(), having filter argument  | 
              |
| 415 | 
                  + # insert() with filter option  | 
              |
| 390 | 416 | 
                  $dbi->insert(table => 'books',  | 
              
| 391 | 417 | 
                                    param  => {title => 'Perl', author => 'Ken'},
                 | 
              
| 392 | 418 | 
                                    filter => {title => 'encode_utf8'});
                 | 
              
| 393 | 419 | 
                   | 
              
| 394 | 
                  - # select(), having filter argument  | 
              |
| 420 | 
                  + # select() with filter option  | 
              |
| 395 | 421 | 
                  my $result = $dbi->select(  | 
              
| 396 | 422 | 
                  table => 'books',  | 
              
| 397 | 423 | 
                  column => [qw/author title/],  | 
              
| ... | ... | 
                  @@ -400,11 +426,13 @@ C<delete()>, C<delete_all()>, C<select()>.  | 
              
| 400 | 426 | 
                           filter => {title => 'encode_utf8'}
                 | 
              
| 401 | 427 | 
                  );  | 
              
| 402 | 428 | 
                   | 
              
| 403 | 
                  -Filter works each parmeter, but you prepare default filter for all parameters.  | 
              |
| 429 | 
                  +C<filter>で指定されたフィルタはそれぞれのパラメータの値に働きますが、  | 
              |
| 430 | 
                  +すべてのパラメータのためのデフォルトのフィルタを設定することもできます。  | 
              |
| 404 | 431 | 
                   | 
              
| 405 | 432 | 
                       $dbi->default_bind_filter('encode_utf8');
                 | 
              
| 406 | 433 | 
                   | 
              
| 407 | 
                  -C<filter()> argument overwrites this default filter.  | 
              |
| 434 | 
                  +C<filter()>オプションで指定されたフィルタは、  | 
              |
| 435 | 
                  +デフォルトのフィルタを上書きます。  | 
              |
| 408 | 436 | 
                   | 
              
| 409 | 437 | 
                       $dbi->default_bind_filter('encode_utf8');
                 | 
              
| 410 | 438 | 
                  $dbi->insert(  | 
              
| ... | ... | 
                  @@ -413,26 +441,25 @@ C<filter()> argument overwrites this default filter.  | 
              
| 413 | 441 | 
                           filter => {author => 'to_upper_case', price => undef}
                 | 
              
| 414 | 442 | 
                  );  | 
              
| 415 | 443 | 
                   | 
              
| 416 | 
                  -This is same as the following example.  | 
              |
| 444 | 
                  +C<title>の値にはデフォルトのフィルタであるC<encode_utf8>が適用され  | 
              |
| 445 | 
                  +C<author>の値にはC<to_upper_case>が適用されます。  | 
              |
| 446 | 
                  +C<price>にはundefを設定しているのでフィルタが解除されます。  | 
              |
| 417 | 447 | 
                   | 
              
| 418 | 
                  - $dbi->insert(  | 
              |
| 419 | 
                  - table => 'books',  | 
              |
| 420 | 
                  -        param  => {title => 'Perl', author => 'Ken', price => 1000},
                 | 
              |
| 421 | 
                  -        filter => {title => 'encode_uft8' author => 'to_upper_case'}
                 | 
              |
| 422 | 
                  - );  | 
              |
| 448 | 
                  +=head3 行のフェッチ時のフィルタリング  | 
              |
| 423 | 449 | 
                   | 
              
| 424 | 
                  -You can also specify filter when the row is fetched. This is reverse of bind filter.  | 
              |
| 450 | 
                  +行をフェッチするときのフィルタも設定することができます。  | 
              |
| 451 | 
                  +これはL<DBIx::Custom::Result>クラスのC<filter>メソッドを使って  | 
              |
| 452 | 
                  +行います。  | 
              |
| 425 | 453 | 
                   | 
              
| 426 | 454 | 
                  my $result = $dbi->select(table => 'books');  | 
              
| 427 | 455 | 
                       $result->filter({title => 'decode_utf8', author => 'to_upper_case'});
                 | 
              
| 428 | 456 | 
                   | 
              
| 429 | 
                  -Filter works each column value, but you prepare a default filter  | 
              |
| 430 | 
                  -for all clumn value.  | 
              |
| 457 | 
                  +フィルタはそれぞれの列の値に作用しますが、  | 
              |
| 458 | 
                  +すべての列のためのデフォルのトフィルタを設定することもできます。  | 
              |
| 431 | 459 | 
                   | 
              
| 432 | 460 | 
                       $dbi->default_fetch_filter('decode_utf8');
                 | 
              
| 433 | 461 | 
                   | 
              
| 434 | 
                  -C<filter()> method of L<DBIx::Custom::Result>  | 
              |
| 435 | 
                  -overwrites this default filter.  | 
              |
| 462 | 
                  +C<filter>メソッドで設定されたフィルタはデフォルトのフィルタを上書きます。  | 
              |
| 436 | 463 | 
                   | 
              
| 437 | 464 | 
                       $dbi->default_fetch_filter('decode_utf8');
                 | 
              
| 438 | 465 | 
                  my $result = $dbi->select(  | 
              
| ... | ... | 
                  @@ -441,54 +468,54 @@ overwrites this default filter.  | 
              
| 441 | 468 | 
                  );  | 
              
| 442 | 469 | 
                       $result->filter({author => 'to_upper_case', price => undef});
                 | 
              
| 443 | 470 | 
                   | 
              
| 444 | 
                  -This is same as the following one.  | 
              |
| 471 | 
                  +C<title>の値にはデフォルトのフィルタであるC<decode_utf8>が適用され  | 
              |
| 472 | 
                  +C<author>の値にはC<to_upper_case>が適用されます。  | 
              |
| 473 | 
                  +C<price>にはundefを設定しているのでフィルタが解除されます。  | 
              |
| 445 | 474 | 
                   | 
              
| 446 | 
                  - my $result = $dbi->select(  | 
              |
| 447 | 
                  - table => 'books',  | 
              |
| 448 | 
                  - columns => ['title', 'author', 'price']  | 
              |
| 449 | 
                  - );  | 
              |
| 450 | 
                  -    $result->filter({title => 'decode_utf8', author => 'to_upper_case'});
                 | 
              |
| 451 | 
                  -  | 
              |
| 452 | 
                  -Note that in fetch filter, column names must be lower case  | 
              |
| 453 | 
                  -even if the column name conatains upper case charactors.  | 
              |
| 454 | 
                  -This is requirment not to depend database systems.  | 
              |
| 475 | 
                  +フェッチのためのフィルタにおいて、  | 
              |
| 476 | 
                  +たとえ、列名が大文字を含む場合であっても  | 
              |
| 477 | 
                  +列名は小文字であることに注意してください。  | 
              |
| 478 | 
                  +これはデータベースシステムに依存させないための要件です。  | 
              |
| 455 | 479 | 
                   | 
              
| 456 | 
                  -=head2 6. Get high performance  | 
              |
| 480 | 
                  +=head2 6. パフォーマンスの改善  | 
              |
| 457 | 481 | 
                   | 
              
| 458 | 
                  -=head3 Disable filter checking  | 
              |
| 482 | 
                  +=head3 フィルタのチェックを無効にする  | 
              |
| 459 | 483 | 
                   | 
              
| 460 | 
                  -Filter checking is executed by default.  | 
              |
| 461 | 
                  -This is done to check right filter name is specified,  | 
              |
| 462 | 
                  -but sometimes damage performance.  | 
              |
| 484 | 
                  +フィルタのチェックがデフォルトでは有効になっています。  | 
              |
| 485 | 
                  +これは正しいフィルタ名が指定されているかどうかをチェック  | 
              |
| 486 | 
                  +するためのものですが、ときにはパフォーマンスに影響を  | 
              |
| 487 | 
                  +及ぼす可能性があります。  | 
              |
| 463 | 488 | 
                   | 
              
| 464 | 
                  -If you disable this filter checking,  | 
              |
| 465 | 
                  -Set C<filter_check> attribute to 0.  | 
              |
| 489 | 
                  +フィルタのチェックを無効にするにはC<filter_check>  | 
              |
| 490 | 
                  +に0を設定してください。  | 
              |
| 466 | 491 | 
                   | 
              
| 467 | 492 | 
                  $dbi->filter_check(0);  | 
              
| 468 | 493 | 
                   | 
              
| 469 | 
                  -=head3 Use execute() method instead suger methods  | 
              |
| 470 | 
                  -  | 
              |
| 471 | 
                  -If you execute insert statement by C<insert()> method,  | 
              |
| 472 | 
                  -you sometimes can't get required performance.  | 
              |
| 494 | 
                  +=head3 シュガーメソッドを使わない  | 
              |
| 473 | 495 | 
                   | 
              
| 474 | 
                  -C<insert()> method is a little slow because SQL statement and statement handle  | 
              |
| 475 | 
                  -is created every time.  | 
              |
| 496 | 
                  +もしC<insert()>メソッドを使用してインサートを実行した場合、  | 
              |
| 497 | 
                  +必要なパフォーマンスを得られない場合があるかもしれません。  | 
              |
| 498 | 
                  +C<insert()>メソッドは、SQL文とステートメントハンドルを  | 
              |
| 499 | 
                  +毎回作成するためすこし遅いです。  | 
              |
| 476 | 500 | 
                   | 
              
| 477 | 
                  -In that case, you can prepare a query by C<create_query()> method.  | 
              |
| 501 | 
                  +そのような場合は、C<create_query()>メソッドによって  | 
              |
| 502 | 
                  +クエリを用意しておくことができます。  | 
              |
| 478 | 503 | 
                   | 
              
| 479 | 504 | 
                  my $query = $dbi->create_query(  | 
              
| 480 | 505 | 
                           "insert into books {insert_param title author};"
                 | 
              
| 481 | 506 | 
                  );  | 
              
| 482 | 507 | 
                   | 
              
| 483 | 
                  -Return value of C<create_query()> is L<DBIx::Custom::Query> object.  | 
              |
| 484 | 
                  -This keep the information of SQL and column names.  | 
              |
| 508 | 
                  +戻り値はL<DBIx::Custom::Query>オブジェクトです。  | 
              |
| 509 | 
                  +このオブジェクトはSQL文とパラメータバインド時の列名を  | 
              |
| 510 | 
                  +保持しています。またステートメントハンドルも保持しています。  | 
              |
| 485 | 511 | 
                   | 
              
| 486 | 512 | 
                       {
                 | 
              
| 487 | 513 | 
                  sql => 'insert into books (title, author) values (?, ?);',  | 
              
| 488 | 
                  - columns => ['title', 'author']  | 
              |
| 514 | 
                  + columns => ['title', 'author'],  | 
              |
| 515 | 
                  + sth => $sth  | 
              |
| 489 | 516 | 
                  }  | 
              
| 490 | 517 | 
                   | 
              
| 491 | 
                  -Execute query repeatedly.  | 
              |
| 518 | 
                  +クエリオブジェクトを使って繰り返し実行するには次のようにします。  | 
              |
| 492 | 519 | 
                   | 
              
| 493 | 520 | 
                  my $inputs = [  | 
              
| 494 | 521 | 
                           {title => 'Perl',      author => 'Ken'},
                 | 
              
| ... | ... | 
                  @@ -499,24 +526,18 @@ Execute query repeatedly.  | 
              
| 499 | 526 | 
                  $dbi->execute($query, $input);  | 
              
| 500 | 527 | 
                  }  | 
              
| 501 | 528 | 
                   | 
              
| 502 | 
                  -This is faster than C<insert()> method.  | 
              |
| 529 | 
                  +C<execute>メソッドの第一引数にクエリオブジェトを渡すことができます。  | 
              |
| 530 | 
                  +これはC<insert()>メソッドよりも高速です。  | 
              |
| 503 | 531 | 
                   | 
              
| 504 | 
                  -=head3 caching  | 
              |
| 532 | 
                  +=head3 キャッシング  | 
              |
| 505 | 533 | 
                   | 
              
| 506 | 
                  -C<execute()> method caches the parsed result of the source of SQL.  | 
              |
| 507 | 
                  -Default to 1  | 
              |
| 534 | 
                  +C<execute()>メソッドはデフォルトでSQL文への解析結果をキャッシュします。  | 
              |
| 508 | 535 | 
                   | 
              
| 509 | 536 | 
                  $dbi->cache(1);  | 
              
| 510 | 537 | 
                   | 
              
| 511 | 
                  -Caching is on memory, but you can change this by C<cache_method()>.  | 
              |
| 512 | 
                  -First argument is L<DBIx::Custom> object.  | 
              |
| 513 | 
                  -Second argument is a source of SQL,  | 
              |
| 514 | 
                  -such as "select * from books where {= title} and {= author};";
                 | 
              |
| 515 | 
                  -Third argument is parsed result, such as  | 
              |
| 516 | 
                  -{sql => "select * from books where title = ? and author = ?",
                 | 
              |
| 517 | 
                  - columns => ['title', 'author']}, this is hash reference.  | 
              |
| 518 | 
                  -If arguments is more than two, this method is called to set cache.  | 
              |
| 519 | 
                  -If not, this method is called to get cache.  | 
              |
| 538 | 
                  +キャッシングはメモリ上で行われますが、C<cache_method()>  | 
              |
| 539 | 
                  +を使って変更することができます。これはキャッシュされるデータの保存と取得  | 
              |
| 540 | 
                  +のためのメソッドを定義するのに利用されます。  | 
              |
| 520 | 541 | 
                   | 
              
| 521 | 542 | 
                       $dbi->cache_method(sub {
                 | 
              
| 522 | 543 | 
                           sub {
                 | 
              
| ... | ... | 
                  @@ -536,14 +557,44 @@ If not, this method is called to get cache.  | 
              
| 536 | 557 | 
                  }  | 
              
| 537 | 558 | 
                  });  | 
              
| 538 | 559 | 
                   | 
              
| 539 | 
                  -=head2 7. More features  | 
              |
| 560 | 
                  +最初の引数はL<DBIx::Custom>です。第二引数は、  | 
              |
| 561 | 
                  +"select * from books where {= title} and {= author};";
                 | 
              |
| 562 | 
                  +のようなSQL文の源です。  | 
              |
| 563 | 
                  +第三引数は  | 
              |
| 564 | 
                  +{sql => "select * from books where title = ? and author = ?",
                 | 
              |
| 565 | 
                  + columns => ['title', 'author']}  | 
              |
| 566 | 
                  +のような解析後のデータです。これはハッシュリファレンスである必要  | 
              |
| 567 | 
                  +があります。  | 
              |
| 568 | 
                  +もし引数がふたつより大きい場合は、このメソッドはキャッシュを保存  | 
              |
| 569 | 
                  +するのに利用されます。そうでない場合はキャッシュを取得するのに  | 
              |
| 570 | 
                  +利用されます。  | 
              |
| 571 | 
                  +  | 
              |
| 572 | 
                  +=head2 7. その他の機能  | 
              |
| 540 | 573 | 
                   | 
              
| 541 | 574 | 
                  =head3 トランザクション  | 
              
| 542 | 575 | 
                   | 
              
| 576 | 
                  +トランザクションを便利に利用するために、  | 
              |
| 577 | 
                  +C<begin_work()>、C<commit()>、C<rollback()>  | 
              |
| 578 | 
                  +という三つのメソッドが容易されています。  | 
              |
| 579 | 
                  +これはL<DBI>の同名のメソッドと同じ機能を持ちます。  | 
              |
| 580 | 
                  +  | 
              |
| 581 | 
                  + $dbi->begin_work;  | 
              |
| 582 | 
                  +  | 
              |
| 583 | 
                  +    eval {
                 | 
              |
| 584 | 
                  + $dbi->update(...);  | 
              |
| 585 | 
                  + $dbi->update(...);  | 
              |
| 586 | 
                  + };  | 
              |
| 587 | 
                  +  | 
              |
| 588 | 
                  +    if ($@) {
                 | 
              |
| 589 | 
                  + $dbi->rollback;  | 
              |
| 590 | 
                  + }  | 
              |
| 591 | 
                  +    else {
                 | 
              |
| 592 | 
                  + $dbi->commit;  | 
              |
| 593 | 
                  + }  | 
              |
| 543 | 594 | 
                   | 
              
| 544 | 
                  -=head3 Change Result class  | 
              |
| 595 | 
                  +=head3 selectメソッドの結果クラスの変更  | 
              |
| 545 | 596 | 
                   | 
              
| 546 | 
                  -You can change Result class if you need.  | 
              |
| 597 | 
                  +必要ならばC<select()>メソッドの結果クラスを変更することができます。  | 
              |
| 547 | 598 | 
                   | 
              
| 548 | 599 | 
                  package Your::Result;  | 
              
| 549 | 600 | 
                  use base 'DBIx::Custom::Result';  | 
              
| ... | ... | 
                  @@ -559,9 +610,10 @@ You can change Result class if you need.  | 
              
| 559 | 610 | 
                  my $dbi = DBIx::Custom->connect(...);  | 
              
| 560 | 611 | 
                       $dbi->result_class('Your::Result');
                 | 
              
| 561 | 612 | 
                   | 
              
| 562 | 
                  -=head3 Custamize SQL builder object  | 
              |
| 613 | 
                  +=head3 L<DBIx::Custom::QueryBuilder>の機能の拡張  | 
              |
| 563 | 614 | 
                   | 
              
| 564 | 
                  -You can custamize SQL builder object  | 
              |
| 615 | 
                  +新しいタグが欲しい場合はL<DBIx::Custom::QueryBuilder>の機能を拡張  | 
              |
| 616 | 
                  +することができます。  | 
              |
| 565 | 617 | 
                   | 
              
| 566 | 618 | 
                  my $dbi = DBIx::Custom->connect(...);  | 
              
| 567 | 619 | 
                  $dbi->query_builder->register_tag_processor(  | 
              
| ... | ... | 
                  @@ -570,9 +622,9 @@ You can custamize SQL builder object  | 
              
| 570 | 622 | 
                  }  | 
              
| 571 | 623 | 
                  );  | 
              
| 572 | 624 | 
                   | 
              
| 573 | 
                  -=head3 Resister helper method  | 
              |
| 625 | 
                  +=head3 ヘルパーメソッドの登録  | 
              |
| 574 | 626 | 
                   | 
              
| 575 | 
                  -You can resiter helper method.  | 
              |
| 627 | 
                  +ヘルパーメソッドを登録することができます。  | 
              |
| 576 | 628 | 
                   | 
              
| 577 | 629 | 
                  $dbi->helper(  | 
              
| 578 | 630 | 
                           update_or_insert => sub {
                 | 
              
| ... | ... | 
                  @@ -585,10 +637,33 @@ You can resiter helper method.  | 
              
| 585 | 637 | 
                  }  | 
              
| 586 | 638 | 
                  );  | 
              
| 587 | 639 | 
                   | 
              
| 588 | 
                  -Register helper methods.  | 
              |
| 589 | 
                  -These method can be called from L<DBIx::Custom> object directory.  | 
              |
| 640 | 
                  +<helper()>メソッドで登録したメソッドは  | 
              |
| 641 | 
                  +L<DBIx::Custom>オブジェクトから直接呼び出すことができます。  | 
              |
| 590 | 642 | 
                   | 
              
| 591 | 643 | 
                  $dbi->update_or_insert;  | 
              
| 592 | 644 | 
                  $dbi->find_or_create;  | 
              
| 593 | 645 | 
                   | 
              
| 646 | 
                  +=head3 ユーティリティメソッド(実験的)  | 
              |
| 647 | 
                  +  | 
              |
| 648 | 
                  +C<expand>メソッドを使用すると次のようなハッシュに含まれる  | 
              |
| 649 | 
                  +テーブル名と列名を結合することができます。  | 
              |
| 650 | 
                  +  | 
              |
| 651 | 
                  + my %expanded = $dbi->expand(\%source);  | 
              |
| 652 | 
                  +  | 
              |
| 653 | 
                  +以下のハッシュ  | 
              |
| 654 | 
                  +  | 
              |
| 655 | 
                  +    {books => {title => 'Perl', author => 'Ken'}}
                 | 
              |
| 656 | 
                  +  | 
              |
| 657 | 
                  +は次のように展開されます。  | 
              |
| 658 | 
                  +  | 
              |
| 659 | 
                  +    ('books.title' => 'Perl', 'books.author' => 'Ken')
                 | 
              |
| 660 | 
                  +  | 
              |
| 661 | 
                  +これはテーブル名を含むselect文で利用すると便利です。  | 
              |
| 662 | 
                  +  | 
              |
| 663 | 
                  +    my $param = {title => 'Perl', author => '%Ken%'};
                 | 
              |
| 664 | 
                  + $dbi->execute(  | 
              |
| 665 | 
                  +        'select * from books where {= books.title} && {like books.author};',
                 | 
              |
| 666 | 
                  +        param => {$dbi->expand({books => $param})}
                 | 
              |
| 667 | 
                  + );  | 
              |
| 668 | 
                  +  | 
              |
| 594 | 669 | 
                  =cut  |