[dancer-users] list order from a hash

WK wanradt at gmail.com
Wed Aug 26 19:16:05 BST 2015


Hi!

2015-08-26 16:51 GMT+03:00 Richard Reina <gatorreina at gmail.com>:

> I have this table data that I load into a template as follows.
>
>   $q = "SELECT ID, NAME
>                 FROM jobs
>                 ORDER BY NAME";

Here you may just query with one line:

my $Jobs_ref = $dbh->selectall_arrayref( $q, { Slice => {} } );

And now in template

          <% FOREACH job IN Jobs %>
         <option value="<% job.ID %>"><% job.NAME %></option>
         <% END %>

So you will use exact order, like you got from DB.

Wbr,

-- 
Kõike hääd,

Gunnar


More information about the dancer-users mailing list