On Mon, Apr 16, 2001 at 04:27:11PM +0100, Tim Bunce wrote:
> I tried the following:
> == snip ==
> my $statement = "SELECT user, session FROM benutzer WHERE session_key= ?";
> my $sth = $dbh->prepare($statement) || &error('SQL', $dbh->errstr);;
> my $success = $sth->execute($sk);
> my ($user, $session) = $sth->fetchrow_array || &error('SQL', $sth->errstr);
^^^^
> == end snip ==
>
> In that way only the scalar $user was set and contained the value of
> "session" from the database.
The || operator puts the call to $sth->fetchrow_array in a scalar context,
so it returns only one of the values selected. Replace the || with or, which
has lower precedence, and it should work as you expected.
However, if $sth->fetchrow_array() really returned the session value, not
the user value, that is a bug, because in a scalar context fetchrow_array()
should return the value of the first selected field, not the last. I don't
see this bug in the latest version of DBI, though.
Ronald