Hmm. Seems you're right. Try this:
while ( my $grade = $sth->fetchrow_arrayref )
{
push(@grades,$grade->[0]);
}
> -----Original Message-----
> From: Peter R. Wood - Lists [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 23, 2001 1:19 PM
> To: [EMAIL PROTECTED]
> Subject: fetchrow returns only nonzero ints?
>
>
> Hello,
>
> I'm using the Perl DBI to access a MySQL database.
>
> I'm trying to fetch all rows in a integer column. When I
> manually interact
> with MySQL, I get all of the values, whether they're zero or
> not. But when I
> use DBI to do it, it seems to throw out any zero values. e.g.
>
> (apologies for the formatting)
>
> The query in the mysql interface:
> mysql> select grade from student_assignment;
> +-------+
> | grade |
> +-------+
> | 22 |
> | 20 |
> | 20 |
> | 22 |
> | 25 |
> | 15 |
> | 0 |
> | 17 |
> | 16 |
>
> --snip--
>
>
> The query in perl dbi:
>
> --snip--
> my $assignment_query =
> "SELECT grade " .
> "FROM student_assignment";
> my $sth = $dbh->prepare($assignment_query);
> $sth->execute();
> my @assignments;
> while ( my $grade = $sth->fetchrow() )
> {
> push(@grades,$grade);
> }
> print "@grades";
> --snip--
>
> This generates an array containing
> 22 20 20 22 25 15 17 16
>
> The 0 value is missing.
>
> Is there any way to have zero values not thrown away?
>
> (Please excuse any oddities in my perl coding technique, I
> have not been at
> this long...)
>
> Thanks,
>
> Peter
>
__________________________________________________________________________
Please Note :
Only the intended recipient is authorised to access or use this e-mail. If
you are not the intended recipient,
please delete this e-mail and notify the sender immediately. The contents
of this e-mail are the writer's
opinion and are not necessarily endorsed by the Gunz Companies unless
expressly stated.
We use virus scanning software but exclude all liability for viruses or
similar in any attachment.