Matt S Trout wrote:
On Mon, May 21, 2007 at 11:39:27AM +0100, Richard Jones wrote:
I've got table joins working OK where base table_1 (me) contains foreign
keys to 3 other tables (table_2, table_3 & table_4). So the 'base' (me)
table_1 contains 3 'belongs_to' relationships, and tables_ 2, 3 & 4 each
contain a 'has_many' relationship with the base table. Then:
my $rs = $c->model('Schema::Foo')->search( $where_href, # WHERE clause
{
select => qw( table1.id table2.field table3.something_else etc ),
join => [ qw/table_2 table_3 table_4/ ],
The join attribute takes relationship names as defined in your classes; you
-may- make some of these the same as the table name but that's none of DBIC's
business.
Hi Matt, sorry but I think I originally illustrated my problem rather
badly - in my actual code I -did- use relationship names rather than
table names.
I also think the problem is that I haven't managed to find a way to
define a relationship in Schema::Foo to a table removed by 2 levels:
foo: id bar_id
|
v
bar: id baz_id
|
v
baz: id the_field_I_want
Hopefully the diagram makes sense. foo.bar_id => bar.id and bar.baz_id
=> baz.id. I want a column from baz, and probably need to define the
relationship in Schema::Foo to avoid the 'no such relationship' error.
I tried add_relationship, but that just introduced another error (as
described in my reply to Fastjack).
--
Richard Jones
_______________________________________________
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]/