Both questions are in the manual, which you can reread many times w/o
fully grasping all the details.

<snip>
> 1. how can i put the output of a select query to a array?

my $dbh = DBI->connect('<your connect string>', $user, $pass);
my $sql = 'Select field1, field2 from temp';
my $sth = $dbh->prepare($sql);

$sth->execute();

while (my @row = $sth->fetchrow_array()) {
    print join("\t", @row), "\n";
    }

$dbh->disconnect();

> 2. i need a count of the selected/found rows (for e.g. i select users and
> like to display how many users i have collected with this statement)

In the above code use:

my $sql = 'SELECT COUNT(*) FROM temp';

or:

my $i = 0;
while (my @row = $sth->fetchrow_array()) {
    $i++;
    }

HTH,
Paul

Reply via email to