[Catalyst] ask for help on table with 2 similar columns

nhyda nhydanhyda at gmail.com
Wed Mar 17 18:00:19 GMT 2010


I am learning Catalyst for my project.
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=3D>"name"})
__package__->has_many ("at_right","DB::Table2",{right=3D>"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 =3D t2.left or t1.name =3D t2.right

1. How do I put it into catalyst ->search ?

2. and can I use OR in has_many definition? something like
__packege__->has_many("neighbor","DB::Table2",{[{left=3D>"name"},{right=3D>=
"name"}]});

I tried, but debug information shows "Odd number of elements in anonymous
hash ..."

any help or idea is appreciated

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100317/1a0f3=
076/attachment.htm


More information about the Catalyst mailing list