Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to access to all distinct 'group' values within this table. So, in the Catalyst Controller, I try to do a custom DBIx::Class query:CREATE TABLE `table1` ( `id` char(15) NOT NULL, `label` char(255) default NULL, `group` char(255) default NULL, PRIMARY KEY (`id`) )
In the Template:sub test_distinct :Local { $c->stash->{distinct_groups} = [ $c->model('Database1')->resultset('Table1')->search( undef, { select => [ { distinct => 'group' }, ], order_by => 'group' }, ) ]; }
The result I obtain is:[% FOREACH item IN distinct_groups %] '[% item %]'<br /> [% END %]
In the table content, there are 3 distinct groups. The result seems to be consistent.'TestApp::Schema::Database1::Table1=HASH(0x34a21a4)' 'TestApp::Schema::Database1::Table1=HASH(0x34a2234)' 'TestApp::Schema::Database1::Table1=HASH(0x34a7f00)'
... and I just obtain empty strings. What am I doing wrong ?[% FOREACH item IN distinct_groups %] '[% item.group %]'<br /> [% END %]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Catalyst, DBIx::Class, SELECT DISTINCT and TT
by CountZero (Bishop) on Apr 16, 2009 at 10:40 UTC | |
by Anonymous Monk on Apr 16, 2009 at 11:20 UTC | |
by CountZero (Bishop) on Apr 16, 2009 at 11:40 UTC | |
by Anonymous Monk on Apr 16, 2009 at 13:57 UTC | |
by CountZero (Bishop) on Apr 16, 2009 at 14:38 UTC |