Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl Monks,
I'm trying to get information that is stored in a DB along with the total number of rows.
My code is:
$sth->execute(user) or die $db->errstr; $user_info = $sth->fetchall_arrayref(); foreach $info (@{client_info}) { $usr_info[0] = $info->[0]; ... (to [6]) } $num_rows = $sth->rows; return (@usr_info, $num_rows);
I tried printing the contents of my array and the number of lines by doing:
print "Rows = ".$num_rows."\n"; foreach $info (@usr_info) { print "Info = ".$info."\n"; } /code> <p>I got the following output:</p> <code> Row = Info = user A ... (to 6) Info = 1
It appears i'm getting an extra value that doesn't exist in the database.
My question is: is this value the number of columns?
Please advice, thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question about fetchall_arrayref
by GotToBTru (Prior) on Apr 28, 2014 at 15:03 UTC | |
|
Re: Question about fetchall_arrayref
by NetWallah (Canon) on Apr 28, 2014 at 15:13 UTC | |
|
Re: Question about fetchall_arrayref
by Anonymous Monk on Apr 28, 2014 at 14:38 UTC | |
|
Re: Question about fetchall_arrayref
by locked_user sundialsvc4 (Abbot) on Apr 28, 2014 at 16:13 UTC |