Hi.

I cant get DBIx::Class og make this query.. I have a table with a has_many
relation.

Company has many Persons, that has many projects..

Company (id,name,address).
Person (id,company_id,name,address)
Projects (id,person_id,name)

I'd like to create a view that list persons with their company name and their
project-count and be sortable in the database on both elements from the
company-table and the count from the projects table.

I bumped into "distinct => 1" but when I add "+select =>
[\'count(projects.projectid')] it tries to group by this element, which
the
database complains about.

An example output:

Company_id,Cname, Caddress, Pid, Pname, Paddres, Count
1,test,test2,2,Jesper,Krogh,7
1,test,test2,3,Test,Test2,3

Getting data from the company table is "quite-easy" just putting it into
the "prefetch" => [qw/company/], but the "has_many group by count stuff is
"harder".

Any suggestions?

Jesper

-- 
Jesper Krogh


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to