in reply to DBI Select results confussion
There are several ways (besides fetchrow_array()) to retrieve results from a query. Which others have you tried using, and what happened?
A suggestion: For a number of reasons that you'll find covered if you search for "bind", it's a good idea to use parameter binding in queries. This looks like:
Since your count(*) query returns a single row of data, you don't need to call it in a loop. It's good form, however, to do $sth->finish(); when you're done.my $sql = <<SQL; SELECT count(*) FROM files WHERE geo=? AND lob="is" AND country=? SQL my $sth = $dbh->prepare($sql); $sth->execute($geo, $country); my($count) = $sth->fetchrow_array(); $sth->finish();
(Edited to correct a typo in the code.)
(Eeek. Edited again to correct a worse typo.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: DBI Select results confussion
by heezy (Monk) on Nov 10, 2002 at 21:02 UTC | |
by dws (Chancellor) on Nov 10, 2002 at 21:22 UTC | |
by heezy (Monk) on Nov 11, 2002 at 16:04 UTC |