I am trying to use DBIx::Class in Catalyst
Here is my problem.
I have two tables as shown below
Table 1             Table 2
id  name      id  left right
1   A            1    A   B
2   B            2    B   C
3   C            3    C   D
4   D            4    A    E
5   E            5    B    E

I want to list who is B's neighbor.
result expected
1 A
2 C
3 E

I have two has_many relationship defined in Table 1
__package__->has_many ("at_left","DB::Table2",{left=
>"name"})
__package__->has_many ("at_right","DB::Table2",{right=>"name"})
and corresponding belongs_to in Table 2

I want to do something like
select name from table 1 as t1
join table 2 as t2 on t1.name = t2.left or t1.name = t2.right

How do I put it into model(DB::Table1) ->search ?

any help or idea is appreciated
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to