Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by tangent (Parson)
on Jul 13, 2015 at 14:28 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1134518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found