Re: [htmltmpl] [Question] H::T and DBI => stuffing query info into <TMPL_LOOP>'s
Brought to you by:
samtregar
From: Mathew R. <mat...@re...> - 2004-04-13 23:21:31
|
> > I can get the results to print directly with this code: > >=20 > > $sth =3D $dbh->prepare ("SELECT * FROM $working_tbl WHERE = first=3D'one'=20 > > ORDER BY Location"); > > $sth->execute (); > > while ( my $hash_ref =3D $sth->fetchrow_hashref ) { > > print "ID: $hash_ref->{'ID'} -- Name: $hash_ref->{'Name'} =20 > > (etc....) <br>\n"; > > } > this is cool, but do note that the DBI docs generally advise against = the=20 > use of a variable table name (well... I understand them to be advising = > against) as it doesn't allow for creating a plan and optimizing the=20 > query. Anyway... What has Perl's string interpolation got to do with DBI?=20 "SELECT * FROM $working_tbl WHERE first=3D'one' ORDER BY Location" The variable $working_tbl will be interpolated by Perl, long before DBI = ever gets to see the SQL statement, due to the double-quote. Mathew |