David Baird wrote:

On 8/8/05, Binish A R <[EMAIL PROTECTED]> wrote:
I am a bit confused whether this is possible or not?
I would like to have an array reference, the command am using is something like 
:

--
$sth = $dbh->prepare("SELECT * from tablename");
$sth->execute;

$aref = $sth->fetchrow_array;
--


Try fetchrow_arrayref

The last line, viz $aref = $sth->fetchrow_array;
I am expecting $aref to be an array reference ...

But its giving the first element of that array, not an array reference ... :-/
even its not giving me the length of the array ...
If I am counting on the scalar behaviour, it should give the length of the 
array right?
But its not so :(

From the docs:

If called in a scalar context for a statement handle that has more
than one column, it is undefined whether the driver will return the
value of the first column or the last. So don't do that. Also, in a
scalar context, an undef is returned if there are no more rows or if
an error occurred. That undef can't be distinguished from an undef
returned because the first field value was NULL. For these reasons you
should exercise some caution if you use fetchrow_array in a scalar
context.

Thanks ... that what i needed ... fetchrow_arrayref :)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to