in reply to extract column data

->selectrow_array fetches only a single row.

Better use ->fetchall_arrayref instead.

Replies are listed 'Best First'.
Re^2: extract column data
by bigup401 (Pilgrim) on May 24, 2017 at 12:17 UTC

    i tried it but, i get cant locate object method fetchall_arrayref via package dbi::db

    i always get this error when i try to use fetchall_arrayref

    use DBI; my $host =""; my $db =""; my $usr =""; my $pwd =""; my $dbh = DBI->connect("DBI:mysql:$db:$host", $usr, $pwd, { AutoCommit => 0, RaiseError => 1, }) or die $DBI::errstr; my $sth = $dbh->fetchall_arrayref("SELECT lastname FROM dbase"); $dbh->disconnect; #its ok with array @data = $sth1; print @data;

      Maybe now is a good time to review DBI to see what methods can be called on which objects and what the sequence of when to call which is.

      If you are unable to modify your code to use ->fetchall_arrayref, consider reading the documentation for ->selectall_arrayref and using that method.

        selectall_arrayref seems to work but am getting

        ARRAY<0x1c56ba4>
        my $sth = $dbh->selectall_arrayref("SELECT lastname FROM dbase");
A reply falls below the community's threshold of quality. You may see it by logging in.