in reply to Catalyst DBIx Help
Can someone please help me instead of just pointing me to the manuals?
No such luck :)
There are areas of improvement that I see, one being an effective node title :) How do I compose an effective node title?
You probably had a tough time coming up with one, because your code is not self-contained, and you're asking more than one question , for improving on that :) see How do I post a question effectively?
I imagine, an effective title might be "Creating generic DBIx... model template" or "DBIx... introspection" or ...
The problem is, what if I want to display the results of a different DB? Seems that I should be able to use the same template... maybe I'm just not groking the model.
From your template/description, I can deduce, that resultset is basically this data structure ( an AoH, array of hashrefs)
So to make your template generic, you would use the Template equivalent of keys, which is keys so[ { username => 'username1', password => 'password1', ...}, { username => 'username2', password => 'password2', ...}, ... ],
<table> [% IF hash = resultset.first %] <tr> [% FOREACH key IN hash.keys.sort %] <th>[% key %]</th> [% END %] </tr> [% END %] [% FOREACH hash IN resultset %] <tr> [% FOREACH key IN hash.keys.sort %] <td>[% hash.$key %]</td> [% END %] </tr> [% END %] </table>
->all probably returns different data structures in different context, see Tutorials: Context in Perl: Context tutorial, about context, and also see the related DBIx documentation :)
For data structure info see perldata and the tuts it references, and same for Template :)
There are other ways to a generic template, but I can't help you with that :)
|
|---|