This is discussed here:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Many-to-many
db((db.images.id == db.int_table_galleries_images.image) &
(db.galleries.id == db.int_table_galleries_images.gallery) &
(db.galleries.id == 1)).select()
Anthony
On Wednesday, October 30, 2013 6:51:19 AM UTC-4, Gael Princivalle wrote:
>
>
> Hi.
>
> I'm still making a website where I'm gone have to manage a lot of little
> image galleries.
> An image could be shown inside more galleries, galleries have many images,
> so my relation is "many to many".
>
> Here is my db:
> db.define_table('images',
> Field('title_en'),
> Field('title_it'),
> Field('contents'),
> Field('image_file', 'upload'),
> Field('image_file_s', 'upload'))
> db.define_table('galleries',
> Field('title_en'),
> Field('title_it'))
> db.define_table('int_table_galleries_images',
> Field('gallery', 'reference galleries'),
> Field('image', 'reference images'))
>
> Now in the company page, I want to show only images from the "1" category.
>
> In the controller:
> def company():
> gallery_company = ?
> return dict(gallery_company=gallery_company)
>
> How can I select all fields from images and galleries where galleries.id==1
> ?
>
> Thanks.
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.