| ... | ... |
@@ -366,38 +366,37 @@ You don't have to wirte last semicolon in C<execute()>. |
| 366 | 366 |
|
| 367 | 367 |
$dbi->execute('select * from book');
|
| 368 | 368 |
|
| 369 |
-=head2 3. �s�̃t�F�b�` |
|
| 369 |
+=head2 3. Fetch row |
|
| 370 | 370 |
|
| 371 |
-C<select()>���\�b�h�̖߂�l��L<DBIx::Custom::Result>�I�u�W�F�N�g�ł��B |
|
| 372 |
-L<DBIx::Custom::Result>�ɂ͍s��t�F�b�`���邽�߂̂��܂��܂ȃ��\�b�h�� |
|
| 373 |
-�p�ӂ���Ă��܂��B |
|
| 371 |
+Return value of C<select()> is L<DBIx::Custom::Result> object. |
|
| 372 |
+There are many methods to fetch row. |
|
| 374 | 373 |
|
| 375 |
-=head3 1�s�Ât�F�b�`(�z��) C<fetch()> |
|
| 374 |
+=head3 Fetch a row (array) C<fetch()> |
|
| 376 | 375 |
|
| 377 |
-��s�t�F�b�`���Ĕz��̃��t�@�����X�Ɋi�[����ɂ�C<fetch()>��g�p���܂��B |
|
| 376 |
+use C<fetch()> to fetch a row and assign it into array reference. |
|
| 377 |
+ |
|
| 378 |
+ my $row = $result->fetch; |
|
| 379 |
+ |
|
| 380 |
+You can get all rows. |
|
| 378 | 381 |
|
| 379 | 382 |
while (my $row = $result->fetch) {
|
| 380 | 383 |
my $title = $row->[0]; |
| 381 | 384 |
my $author = $row->[1]; |
| 382 | 385 |
} |
| 383 | 386 |
|
| 384 |
-while���[�v��g��āA���ׂĂ̍s��擾���邱�Ƃ��ł��܂��B |
|
| 387 |
+=head3 Fetch only first row (array) C<fetch_first()> |
|
| 385 | 388 |
|
| 386 |
-=head3 �ŏ��̍s�����t�F�b�`(�z��) C<fetch_first()> |
|
| 387 |
- |
|
| 388 |
-��s�����t�F�b�`���Ĕz��̃��t�@�����X�Ɋi�[����ɂ�C<fetch_first()> |
|
| 389 |
-��g�p���܂��B |
|
| 389 |
+use C<fetch_first()> to fetch only first row. |
|
| 390 | 390 |
|
| 391 | 391 |
my $row = $result->fetch_first; |
| 392 | 392 |
|
| 393 |
-��s�̃t�F�b�`���I������͂���ȏ�t�F�b�`�ł��Ȃ��Ȃ�܂��B |
|
| 394 |
-���I�ɂ�1�s�̃t�F�b�`���I������� |
|
| 395 |
-�X�e�[�g�����g�n���h����C<finish()>����s����܂��B |
|
| 393 |
+You can't fetch rest rows |
|
| 394 |
+because statement handle C<finish()> is executed. |
|
| 396 | 395 |
|
| 397 |
-=head3 �����s��Ƀt�F�b�`(�z��) C<fetch_multi()> |
|
| 396 |
+=head3 Fetch rows (array) C<fetch_multi()> |
|
| 398 | 397 |
|
| 399 |
-�����s��t�F�b�`���Ĕz��̃��t�@�����X��v�f�Ɏ��� |
|
| 400 |
-�z��̃��t�@�����X�Ɋi�[����ɂ�C<fetch_multi()>��g�p���܂��B |
|
| 398 |
+use C<fetch_multi()> to fetch rows and assign it into |
|
| 399 |
+array reference which has array references as element. |
|
| 401 | 400 |
|
| 402 | 401 |
while (my $rows = $result->fetch_multi(2)) {
|
| 403 | 402 |
my $title0 = $rows->[0][0]; |
| ... | ... |
@@ -407,54 +406,52 @@ while |
| 407 | 406 |
my $author1 = $rows->[1][1]; |
| 408 | 407 |
} |
| 409 | 408 |
|
| 410 |
-��ɂ͎��o�������s����w�肵�܂��B |
|
| 409 |
+Specify row count as argument. |
|
| 411 | 410 |
|
| 412 |
-�w�肵���s��i�[�������̂悤�ȃf�[�^��擾�ł��܂��B |
|
| 411 |
+You can get the following data. |
|
| 413 | 412 |
|
| 414 | 413 |
[ |
| 415 | 414 |
['Perl', 'Ken'], |
| 416 | 415 |
['Ruby', 'Mark'] |
| 417 | 416 |
] |
| 418 | 417 |
|
| 419 |
-=head3 ���ׂĂ̍s��t�F�b�`(�z��) C<fetch_all> |
|
| 418 |
+=head3 Fetch all rows (array) C<fetch_all> |
|
| 420 | 419 |
|
| 421 |
-���ׂĂ̍s��t�F�b�`���Ĕz��̃��t�@�����X��v�f�Ɏ��� |
|
| 422 |
-�z��̃��t�@�����X�Ɋi�[����ɂ�C<fetch_all()>��g�p���܂��B |
|
| 420 |
+use C<fetch_all()> to fetch all rows and assign it into |
|
| 421 |
+array reference which has array reference as element. |
|
| 423 | 422 |
|
| 424 | 423 |
my $rows = $result->fetch_all; |
| 425 | 424 |
|
| 426 |
-���ׂĂ̍s��i�[�������̂悤�ȃf�[�^��擾�ł��܂��B |
|
| 425 |
+You can get the following data. |
|
| 427 | 426 |
|
| 428 | 427 |
[ |
| 429 | 428 |
['Perl', 'Ken'], |
| 430 | 429 |
['Ruby', 'Mark'] |
| 431 | 430 |
] |
| 432 | 431 |
|
| 433 |
-=head3 1�s�Ât�F�b�`(�n�b�V��) C<fetch_hash()> |
|
| 432 |
+=head3 Fetch a row (hash) C<fetch_hash()> |
|
| 434 | 433 |
|
| 435 |
-��s�t�F�b�`���ăn�b�V���̃��t�@�����X�Ɋi�[����ɂ�C<fetch_hash()>��g�p���܂��B |
|
| 434 |
+use C<fetch_hash()> to fetch a row and assign it into hash reference. |
|
| 436 | 435 |
|
| 437 | 436 |
while (my $row = $result->fetch_hash) {
|
| 438 | 437 |
my $title = $row->{title};
|
| 439 | 438 |
my $author = $row->{author};
|
| 440 | 439 |
} |
| 441 | 440 |
|
| 442 |
-=head3 �ŏ��̍s�����t�F�b�`(�n�b�V��) C<fetch_hash_first()> |
|
| 441 |
+=head3 Fetch only first row (hash) C<fetch_hash_first()> |
|
| 443 | 442 |
|
| 444 |
-��s�����t�F�b�`���ăn�b�V���̃��t�@�����X�Ɋi�[����ɂ� |
|
| 445 |
-C<fetch_hash_first()>��g�p���܂��B |
|
| 443 |
+use C<fetch_hash_first()> to fetch only first row |
|
| 444 |
+and assign it into hash reference. |
|
| 446 | 445 |
|
| 447 | 446 |
my $row = $result->fetch_hash_first; |
| 448 | 447 |
|
| 449 |
-��s�̃t�F�b�`���I������͂���ȏ�t�F�b�`�ł��Ȃ��Ȃ�܂��B |
|
| 450 |
-���I�ɂ�1�s�̃t�F�b�`���I������� |
|
| 451 |
-�X�e�[�g�����g�n���h����C<finish()>����s����܂��B |
|
| 448 |
+You can't fetch rest rows |
|
| 449 |
+because statement handle C<finish()> is executed. |
|
| 452 | 450 |
|
| 453 |
-=head3 �����s��Ƀt�F�b�`(�n�b�V��) C<fetch_hash_multi()> |
|
| 451 |
+=head3 Fetch rows (hash) C<fetch_hash_multi()> |
|
| 454 | 452 |
|
| 455 |
-�����s��t�F�b�`���ăn�b�V���̃��t�@�����X��v�f�Ɏ��� |
|
| 456 |
-�z��̃��t�@�����X�Ɋi�[����ɂ�C<fetch_hash_multi()> |
|
| 457 |
-��g�p���܂��B |
|
| 453 |
+use C<fetch_hash_multi()> to fetch rows and |
|
| 454 |
+assign it into array reference which has hash references as element. |
|
| 458 | 455 |
|
| 459 | 456 |
while (my $rows = $result->fetch_hash_multi(5)) {
|
| 460 | 457 |
my $title0 = $rows->[0]{title};
|
| ... | ... |
@@ -463,41 +460,36 @@ C<fetch_hash_first()> |
| 463 | 460 |
my $author1 = $rows->[1]{author};
|
| 464 | 461 |
} |
| 465 | 462 |
|
| 466 |
-��ɂ͎��o�������s����w�肵�܂��B |
|
| 463 |
+Specify row count as argument. |
|
| 467 | 464 |
|
| 468 |
-�w�肵���s��i�[�������̂悤�ȃf�[�^��擾�ł��܂��B |
|
| 465 |
+You can get the following data. |
|
| 469 | 466 |
|
| 470 | 467 |
[ |
| 471 | 468 |
{title => 'Perl', author => 'Ken'},
|
| 472 | 469 |
{title => 'Ruby', author => 'Mark'}
|
| 473 | 470 |
] |
| 474 | 471 |
|
| 475 |
-=head3 ���ׂĂ̍s��t�F�b�`(�n�b�V��) C<fetch_hash_all()> |
|
| 472 |
+=head3 Fetch all rows (hash) C<fetch_hash_all()> |
|
| 476 | 473 |
|
| 477 |
-���ׂĂ̍s��t�F�b�`���ăn�b�V���̃��t�@�����X��v�f�Ɏ��� |
|
| 478 |
-�z��̃��t�@�����X�Ɋi�[����ɂ�C<fetch_hash_all()> |
|
| 479 |
-��g�p���܂��B |
|
| 474 |
+use C<fetch_hash_all()> to fetch all rows and |
|
| 475 |
+assign it into array reference which has hash |
|
| 476 |
+references as element. |
|
| 480 | 477 |
|
| 481 | 478 |
my $rows = $result->fetch_hash_all; |
| 482 | 479 |
|
| 483 |
-���ׂĂ̍s��i�[�������̂悤�ȃf�[�^��擾�ł��܂��B |
|
| 480 |
+You can get the following data. |
|
| 484 | 481 |
|
| 485 | 482 |
[ |
| 486 | 483 |
{title => 'Perl', author => 'Ken'},
|
| 487 | 484 |
{title => 'Ruby', author => 'Mark'}
|
| 488 | 485 |
] |
| 489 | 486 |
|
| 490 |
-=head3 �X�e�[�g�����g�n���h�� C<sth()> |
|
| 487 |
+=head3 Statement handle C<sth()> |
|
| 491 | 488 |
|
| 492 |
-�X�e�[�g�����g�n���h���ɒ��ڃA�N�Z�X�������ꍇ�� |
|
| 493 |
-<sth>�Ŏ擾���邱�Ƃ��ł��܂��B |
|
| 489 |
+use <sth()> to get statement handle. |
|
| 494 | 490 |
|
| 495 | 491 |
my $sth = $result->sth; |
| 496 | 492 |
|
| 497 |
-�t�F�b�`�̃p�t�H�[�}���X���p�������Ȃ��Ƃ��ɂ́A |
|
| 498 |
-�X�e�[�g�����g�n���h������ |
|
| 499 |
-���p�ł��鑬�x�̑������\�b�h�𗘗p���邱�Ƃ��ł��܂��B |
|
| 500 |
- |
|
| 501 | 493 |
=head2 4. �t�B���^�����O |
| 502 | 494 |
|
| 503 | 495 |
�f�[�^�x�[�X�Ƀf�[�^��o�^����Ƃ���f�[�^�x�[�X����f�[�^��擾���� |
| ... | ... |
@@ -376,20 +376,21 @@ SQLを実行するにはC<execute()>を使用します。 |
| 376 | 376 |
=head2 3. 行のフェッチ |
| 377 | 377 |
|
| 378 | 378 |
C<select()>メソッドの戻り値はL<DBIx::Custom::Result>オブジェクトです。 |
| 379 |
-L<DBIx::Custom::Result>には行をフェッチするためのさまざまなメソッドが |
|
| 380 |
-用意されています。 |
|
| 379 |
+行をフェッチするためのさまざまなメソッドがあります。 |
|
| 381 | 380 |
|
| 382 | 381 |
=head3 1行づつフェッチ(配列) C<fetch()> |
| 383 | 382 |
|
| 384 | 383 |
一行フェッチして配列のリファレンスに格納するにはC<fetch()>を使用します。 |
| 385 | 384 |
|
| 385 |
+ my $row = $result->fetch; |
|
| 386 |
+ |
|
| 387 |
+以下のようにすべての行を取得することができます。 |
|
| 388 |
+ |
|
| 386 | 389 |
while (my $row = $result->fetch) {
|
| 387 | 390 |
my $title = $row->[0]; |
| 388 | 391 |
my $author = $row->[1]; |
| 389 | 392 |
} |
| 390 | 393 |
|
| 391 |
-whileループを使って、すべての行を取得することができます。 |
|
| 392 |
- |
|
| 393 | 394 |
=head3 最初の行だけフェッチ(配列) C<fetch_first()> |
| 394 | 395 |
|
| 395 | 396 |
一行だけフェッチして配列のリファレンスに格納するにはC<fetch_first()> |
| ... | ... |
@@ -397,9 +398,8 @@ whileループを使って、すべての行を取得することができます |
| 397 | 398 |
|
| 398 | 399 |
my $row = $result->fetch_first; |
| 399 | 400 |
|
| 400 |
-一行のフェッチが終わった後はそれ以上フェッチできなくなります。 |
|
| 401 |
-内部的には1行のフェッチが終わった後に |
|
| 402 |
-ステートメントハンドルのC<finish()>が実行されます。 |
|
| 401 |
+ステートメントハンドルのC<finish()>が実行される |
|
| 402 |
+ので残りの行をフェッチできません。 |
|
| 403 | 403 |
|
| 404 | 404 |
=head3 複数行を順にフェッチ(配列) C<fetch_multi()> |
| 405 | 405 |
|
| ... | ... |
@@ -414,9 +414,9 @@ whileループを使って、すべての行を取得することができます |
| 414 | 414 |
my $author1 = $rows->[1][1]; |
| 415 | 415 |
} |
| 416 | 416 |
|
| 417 |
-引数には取り出したい行数を指定します。 |
|
| 417 |
+取り出したい行数を引数に指定します。 |
|
| 418 | 418 |
|
| 419 |
-指定した行を格納した次のようなデータを取得できます。 |
|
| 419 |
+次のようなデータを取得できます。 |
|
| 420 | 420 |
|
| 421 | 421 |
[ |
| 422 | 422 |
['Perl', 'Ken'], |
| ... | ... |
@@ -453,11 +453,10 @@ C<fetch_hash_first()>を使用します。 |
| 453 | 453 |
|
| 454 | 454 |
my $row = $result->fetch_hash_first; |
| 455 | 455 |
|
| 456 |
-一行のフェッチが終わった後はそれ以上フェッチできなくなります。 |
|
| 457 |
-内部的には1行のフェッチが終わった後に |
|
| 458 |
-ステートメントハンドルのC<finish()>が実行されます。 |
|
| 456 |
+ステートメントハンドルのC<finish()>が実行される |
|
| 457 |
+ので残りの行をフェッチできません。 |
|
| 459 | 458 |
|
| 460 |
-=head3 複数行を順にフェッチ(ハッシュ) C<fetch_hash_multi()> |
|
| 459 |
+=head3 複数行をフェッチ(ハッシュ) C<fetch_hash_multi()> |
|
| 461 | 460 |
|
| 462 | 461 |
複数行をフェッチしてハッシュのリファレンスを要素に持つ |
| 463 | 462 |
配列のリファレンスに格納するにはC<fetch_hash_multi()> |
| ... | ... |
@@ -472,7 +471,7 @@ C<fetch_hash_first()>を使用します。 |
| 472 | 471 |
|
| 473 | 472 |
引数には取り出したい行数を指定します。 |
| 474 | 473 |
|
| 475 |
-指定した行を格納した次のようなデータを取得できます。 |
|
| 474 |
+次のようなデータを取得できます。 |
|
| 476 | 475 |
|
| 477 | 476 |
[ |
| 478 | 477 |
{title => 'Perl', author => 'Ken'},
|
| ... | ... |
@@ -487,7 +486,7 @@ C<fetch_hash_first()>を使用します。 |
| 487 | 486 |
|
| 488 | 487 |
my $rows = $result->fetch_hash_all; |
| 489 | 488 |
|
| 490 |
-すべての行を格納した次のようなデータを取得できます。 |
|
| 489 |
+次のようなデータを取得できます。 |
|
| 491 | 490 |
|
| 492 | 491 |
[ |
| 493 | 492 |
{title => 'Perl', author => 'Ken'},
|
| ... | ... |
@@ -496,15 +495,11 @@ C<fetch_hash_first()>を使用します。 |
| 496 | 495 |
|
| 497 | 496 |
=head3 ステートメントハンドル C<sth()> |
| 498 | 497 |
|
| 499 |
-ステートメントハンドルに直接アクセスしたい場合は |
|
| 500 |
-<sth>で取得することができます。 |
|
| 498 |
+ステートメントハンドル取得したい場合は |
|
| 499 |
+<sth()>を使用します。 |
|
| 501 | 500 |
|
| 502 | 501 |
my $sth = $result->sth; |
| 503 | 502 |
|
| 504 |
-フェッチのパフォーマンスが用件を満たさないときには、 |
|
| 505 |
-ステートメントハンドルから |
|
| 506 |
-利用できる速度の速いメソッドを利用することができます。 |
|
| 507 |
- |
|
| 508 | 503 |
=head2 4. フィルタリング |
| 509 | 504 |
|
| 510 | 505 |
データベースにデータを登録するときやデータベースからデータを取得する |