[Templates] tt2 and horizontal tables in database
Andy Wardley
abw at wardley.org
Mon Oct 8 14:23:35 BST 2007
jagdish eashwar wrote:
> use DBI;
> $dbh = DBI->connect('dbi:mysql:tt2','user_name','user_password');
> $sth = $dbh->prepare('SELECT * FROM salary_data');
> $sth->execute();
> while ($hash_ref = $sth->fetchrow_hashref) {
> foreach $key(keys %$hash_ref) {
> print "$key = $hash_ref->{$key}\n";
> }
The TT equivalent would be something like this:
[% USE DBI('dbi:mysql:tt2','user_name','user_password');
FOREACH record IN DBI.query('SELECT * from salary_data');
FOREACH key IN record.keys;
key; ' = '; record.$key;
END;
END;
%]
HTH
A
More information about the templates
mailing list