Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Template::Toolkit - How do i access alias-based results?

by tangent (Priest)
on Jul 13, 2015 at 14:28 UTC ( #1134518=note: print w/replies, xml ) Need Help??


in reply to Re^2: Template::Toolkit - How do i access alias-based results?
in thread Template::Toolkit - How do i access alias-based results?

Using that code your @aRows will end up like this:
row1-iVertragsnummer row1-sArtikelNr row1-sVertragsStatus row1-sVertragsDatum row1-iMsgID row2-iVertragsnummer row2-sArtikelNr row2-sVertragsStatus row2-sVertragsDatum row2-iMsgID ...etc
I suspect you need something like this:
{ iVertragsnummer => 'row1-iVertragsnummer', sArtikelNr => 'row1-sArtikelNr', }, { iVertragsnummer => 'row2-iVertragsnummer', sArtikelNr => 'row2-sArtikelNr', },
So try changing to:
while ( my $row = $hStatement->fetchrow_hashref() ) { push ( @aRows, $row ); }

Replies are listed 'Best First'.
Re^4: Template::Toolkit - How do i access alias-based results?
by Yaerox (Scribe) on Jul 14, 2015 at 06:48 UTC
    Yeah this fixed it. I was trying around with fetchrow_arrayref but then I was in an endless loop. I should have better taken hasref ;)

    Anyway, thank you sir.
Re^4: Template::Toolkit - How do i access alias-based results?
by sundialsvc4 (Abbot) on Jul 13, 2015 at 16:21 UTC

    Bingo.   I think that the data-structure is wrong.   Data::Dumper will quickly show you what the data actually looks like, and (as noted elsewhere) so will Template itself.

    What you need to come up with is an array of hashrefs, one per record, preferably the correct “slice” of a larger result set.   The template then loops through this array.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1134518]
help
Chatterbox?
and the fog begins to lift...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-01-21 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (227 votes). Check out past polls.

    Notices?