[Dbix-class] Retrieving data from a link table
Jörg Braun
joerg at braun-senden.de
Mon Dec 10 08:36:10 GMT 2012
Hi,
I had a similar problem where the logical solution was to put an
additional attribute to the linking table. But I have not found a solution
besides fetching the data seperatly.
I am also interested how others solved this kind of problem.
Joerg
On Fri, 7 Dec 2012 16:53:06 +0100, "Ekki Plicht (DF4OR)" <ekki at plicht.de>
wrote:
> Hi.
> Two tables with a many_to_many relation via a link table:
>
> Table of web pages:
> table webpage(id, filename, ...)
>
> Table of images:
> table images (id, filename, ...)
>
> Table linking pages and images:
> table img_grp_page (id_img, groupnumber, id_page)
>
>
> The many_to_many relation works fine, I can retrieve all images
belonging
> to a certain webpage and all webpages where a certain image is used.
>
> What I want to have is the 'group number' from the link table as well.
> Images are clustered in certain groups on a page, that information is
> represented by that group number.
>
> Is there a way to get this in one go (one query)?
>
> Of course I could get this item with a separate query since I know all
> required id's. Still - is there a simpler way? I know that there is a
> similiar phrased question on stackoverflow (not by me), which does not
> really help me.
>
>
> TIA,
> Ekki
More information about the DBIx-Class
mailing list