[dancer-users] Only even items
Hugues Max
huguesmax at gmail.com
Mon Apr 8 20:39:45 BST 2013
Thanks you, very much, It's works
but I not really understand why with hash , half of result go to keys
and other to values
and how template toolkit do the relation between database fiels and
values with simple list ?
for my point of view , a simple "complet" example will be good idea in
documentation.
complet = perl part AND ttk part
bye
Hugues
Le 08/04/2013 21:25, David Precious a écrit :
> On Mon, 08 Apr 2013 19:44:24 +0200
> Hugues Max <huguesmax at gmail.com> wrote:
>
>> Hello
>> I've got stange problem with dancer with twitter boostrap
>> I use
>>
>> use Dancer::Plugin::Database;
>> my $dbh = database({driver => 'mysql', database => 'asav'});
>> my %allCommandeBNP = database->quick_select('CommandeBNP', {} );
> The docs[0] say of quick_select:
>
> returns either the first matching row as a hashref if called in scalar
> context, or a list of matching rows as hashrefs if called in list
> context
>
> You're assigning that to a hash; that implies list context, so your
> hash will have both keys and values representing rows.
>
> e.g. you'll end up with a hash looking like:
>
> (
> 'HASH(0x5356)' => \%row1,
> 'HASH(0x5367)' => \%row2,
> )
>
> etc.
>
> You want to assign straight to a list:
>
> my @allCommandeBNP = database->quick_select('CommandeBNP', {} );
>
> Then pass that straight to your template, e.g.
>
> ccmd => \@allCommandeBNP,
>
> And in your template, just iterate over that.
>
>
> [0] https://metacpan.org/module/Dancer::Plugin::Database::Handle
>
>
>
More information about the dancer-users
mailing list