The fetchrow method is deprecated, it shouldn't be used.
When bind_columns is used and you just want to fetch rows without
checking the return status of the fetch then you can use
$sth->fetch (not fetchrow), which is an alias for fetchrow_arrayref.
Tim.
On Tue, Sep 24, 2002 at 03:27:50PM -0500, Michael Boudreau wrote:
> I am getting odd (to me) behavior from fetchrow and wonder if anybody else
> is aware of this problem. Apologies in advance if I've overlooked something
> really obvious, or if this is a long-squashed bug and I just need to update
> our Perl modules.
>
> Using Perl 5.6.0, DBI 1.14, DBD::mysql 2.0414, and MySQL 3.23.49.
>
> $sth = $dbh->prepare("SELECT PeopleID, Lastname, Email
> FROM People");
> $sth->execute;
> $sth->bind_columns(\$PeopleID, \$Lastname, \$Email);
> while ( $sth->fetchrow ) {
> print "ID: $PeopleID\n" ,
> "Name: $Lastname\n" ,
> "Email: $Email\n\n";
> }
>
> IF the last value (Email) in any row is an empty string, the fetchrow
> method returns false (and any remaining rows are not processed). Very bad
> when the *first* row in the data set happens to have a blank value in the
> last column.
>
> I first thought this was due to the "Email" column in my particular table,
> where it is not a primary key but is still required to be unique. However,
> I was able to get the same results selecting a plain old varchar column.
> Can also get this result with "SELECT PeopleID, Lastname, Email, '' " (and
> adding a fourth parameter to bind_columns).
>
> Removing the bind_columns statement and doing this instead
>
> while ( ($PeopleID, $Lastname, $Email) = $sth->fetchrow ) {
> # print something
> }
>
> works as expected. Also works properly doing fetchall_arrayref and stepping
> through the returned data structure.
>
> Is anybody else familiar with this behavior of fetchrow?
>
>
> =================================================
> Michael Boudreau
> Senior Electronic Publishing Developer
> The University of Chicago Press
> 1427 E. 60th Street
> Chicago, IL 60637-2954
>
> phone: 773 753 3298
> fax: 773 753 3383
> =================================================
>