Skip to content

Commit 7208ce4

Browse files
committed
Merge pull request #18 from mbeijen/RT36730-num-of-fields
Rt36730 num of fields
2 parents 5c390cc + 22d10f4 commit 7208ce4

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

ChangeLog

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
2013-09-17 Michiel Beijen, Patrick Galbraith, DBI/DBD community
1+
2013-??-?? Patrick Galbraith, Michiel Beijen, DBI/DBD community (4.025)
2+
* Fix example in POD doc for NUM_OF_FIELDS - RT36730, reported by tapoutmma.
3+
4+
2013-09-17 Michiel Beijen, Patrick Galbraith, DBI/DBD community (4.024)
25
* Fix memory leak if mysql_server_prepare is enabled - RT76462 - Masahiro Chiba
36
* Small dist improvements: Michiel Beijen <michiel.beijen@otrs.com>
47
* Undefined $DBI::errstr on execute fail on Windows: Michiel Beijen <michiel.beijen@otrs.com>

eg/proc_example1.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/perl
22

33
use strict;
4+
use warnings;
5+
46
use DBI;
57

68
my $db='test';
@@ -34,7 +36,7 @@
3436
$sth->execute || die DBI::err.": ".$DBI::errstr;
3537
do {
3638
print "\nResult set ".++$i."\n---------------------------------------\n\n";
37-
for my $colno (0..$sth->{NUM_OF_FIELDS}) {
39+
for my $colno (0..$sth->{NUM_OF_FIELDS}-1) {
3840
print $sth->{NAME}->[$colno]."\t";
3941
}
4042
print "\n";

eg/proc_example2.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/perl
22

33
use strict;
4+
use warnings;
5+
46
use DBI;
57
use Data::Dumper;
68

@@ -43,7 +45,7 @@ BEGIN
4345
$sth->execute || die DBI::err.": ".$DBI::errstr;
4446
do {
4547
print "\nResult set ".++$i."\n---------------------------------------\n\n";
46-
for my $colno (0..$sth->{NUM_OF_FIELDS}) {
48+
for my $colno (0..$sth->{NUM_OF_FIELDS}-1) {
4749
print $sth->{NAME}->[$colno]."\t";
4850
}
4951
print "\n";

lib/DBD/mysql.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,13 +1501,13 @@ header of table names together with all rows:
15011501
die "Error:" . $sth->errstr . "\n";
15021502
}
15031503
my $names = $sth->{'NAME'};
1504-
my $numFields = $sth->{'NUM_OF_FIELDS'};
1505-
for (my $i = 0; $i < $numFields; $i++) {
1504+
my $numFields = $sth->{'NUM_OF_FIELDS'} - 1;
1505+
for my $i ( 0..$numFields ) {
15061506
printf("%s%s", $i ? "," : "", $$names[$i]);
15071507
}
15081508
print "\n";
15091509
while (my $ref = $sth->fetchrow_arrayref) {
1510-
for (my $i = 0; $i < $numFields; $i++) {
1510+
for my $i ( 0..$numFields ) {
15111511
printf("%s%s", $i ? "," : "", $$ref[$i]);
15121512
}
15131513
print "\n";
@@ -1764,7 +1764,7 @@ An example would be:
17641764
$sth->execute || die DBI::err.": ".$DBI::errstr; $rowset=0;
17651765
do {
17661766
print "\nRowset ".++$i."\n---------------------------------------\n\n";
1767-
foreach $colno (0..$sth->{NUM_OF_FIELDS}) {
1767+
foreach $colno (0..$sth->{NUM_OF_FIELDS}-1) {
17681768
print $sth->{NAME}->[$colno]."\t";
17691769
}
17701770
print "\n";

0 commit comments

Comments
 (0)