(I'm not sure what the unless($_[1]) is for...)sub db_execute { my(@return, @a, $cursor); unless ($VARS{connected}) {db_connect(); $VARS{connected}++;} $cursor = $dbh->prepare($_[0]) || db_error(); $cursor->execute || db_error(); unless ($_[1]) { return @{ $cursor->fetchall_arrayref }; } } my $SQL = "select a, b, c from my_table"; my @rows = db_execute($SQL); for (@rows) { my @row = @$_; ... }
Update: Use fetchall_arrayref() instead of looping over fetchrow().
In reply to Re: Weird DBI/Array Use
by chipmunk
in thread Weird DBI/Array Use
by madhatter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |