in reply to Getting MySQL Data into an Array.
You are very close. The problem is that you first have to execute the query, which in itself does not return any results. After you execute the query, you then fetch the results, one row at a time. I'm not aware of a way to get all the results at once, sorry. Perhaps another monk can enlighten?
For more information, see perldoc DBI and also references, or try this:
update: added the semicolon. Thanks Parham. </code>
$dsn = "DBI:mysql:yip;db.yip.com"; $dbh = DBI->connect($dsn,'me','pass'); $sth = $dbh->prepare("SELECT company FROM company_public;"); $sth->execute(); while($ref = $sth->fetchrow_arrayref) { push @companies, $ref->[0]; } $dbh->disconnect;
update: added the semicolon. Thanks Parham. </code>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Getting MySQL Data into an Array.
by Parham (Friar) on Jan 06, 2002 at 21:22 UTC | |
by Corion (Patriarch) on Jan 06, 2002 at 21:53 UTC | |
by Parham (Friar) on Jan 07, 2002 at 03:03 UTC |
In Section
Seekers of Perl Wisdom