in reply to Class::DBI: Filtering a many-to-many mapping does not work as advertised on CDBI manpage?

I have used Class::DBI just a few times, so please excuse potentially incorrect advice.

IMHO, the links should be made like this:

__PACKAGE__->has_many(hotels => [HotelCategories => 'Hotels']);
Using the 'package name' instead of a specific column name for the linkage.

     Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax

  • Comment on Re: Class::DBI: Filtering a many-to-many mapping does not work as advertised on CDBI manpage?
  • Download Code

Replies are listed 'Best First'.
Re^2: Class::DBI: Filtering a many-to-many mapping does not work as advertised on CDBI manpage?
by unlinker (Monk) on Nov 09, 2008 at 03:43 UTC
    Thanks. The documentation says that the following generic template
    A->has_many(bees => [AB => 'a'])
    will call the method 'a' on each of the objects of type AB. This is exactly what I thought I should have got. I will check your suggestion (where did you see that syntax?) and report.
    Thank you once again for the help
      The documentation for "has_many" reads:
      Class->has_many(method_to_create => "Foreign::Class");
      This method declares that another table is referencing us (i.e. storing our primary key in its table). It creates a named accessor method in our class which returns a list of all the matching Foreign::Class objects. In addition it creates another method which allows a new associated object to be constructed, taking care of the linking automatically. This method is the same as the accessor method with ``add_to_'' prepended.
      The syntax that you reference has this to say:
      Sometimes we don't want to return an instance of the Foreign::Class, but instead the result of calling a method on that object. We can do this by changing the Foreign::Class declaration to a listref of the Foreign::Class and the method to call on that class.
      Which I don't fully comprehend.

           Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax