in reply to Re: selecting again from a mysql database
in thread selecting again from a mysql database
Along the lines of "never say never", I find this oft repeated bit of advice completely misleading. Certainly one can get in trouble with "SELECT *" and should know about its pitfalls. But there are many situations in which it is perfectly fine to use it and others in which it is the *only* thing to use.
Example 1: if you are using bind_columns (which is, after all, the fastest way to fetch), then this is fine:
my $sth = $dbh->prepare("SELECT * FROM foo"); $sth->execute; my %row; $sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } )); while ($sth->fetch) { print "$row{region}: $row{sales}\n"; }
Example 2: You want to display a table to examine it's structure visually, without knowing its structure in advance.
Should one be wary of code that expects the structure of a table to remain unchanged? Yep. Should one therefore never use "SELECT *"? Nope.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: selecting again from a mysql database
by hardburn (Abbot) on Nov 25, 2003 at 18:47 UTC | |
by mpeppler (Vicar) on Nov 25, 2003 at 21:15 UTC |