db(some_query) creates a DAL Set object (on which you can then call methods such as .select(), .update(), etc.). A Set object is also callable, and if you call it by passing in another query, it will simply add the new query as an AND condition. So, that code is just equivalent to:
db( (db.products.id == db.product_filter.product_id) & (db.filters.id == db.product_filter.filter_id) & (db.filters.name == "hoodie") ) or db(db.products.id == db.product_filter.product_id)(db.filters.id == db. product_filter.filter_id)\ (db.filters.name == "hoodie") The idea is that you can create a base Set object and then use it to create more specific sets by adding different conditions. Anthony On Tuesday, May 21, 2013 4:02:00 PM UTC-4, brac...@gmail.com wrote: > > Is there a section in the online web2py book that explains Niphlod's way > to building a query? > > Near the bottom of this > thread<https://groups.google.com/forum/?fromgroups=#!topic/web2py/qL1DKqeEFkA> > there > is: > > all_in_one = db( > (db.products.id == db.product_filter.product_id) & > (db.filters.id == db.product_filter.filter_id) > ) > > Then to get all corresponding rows in product_filter table, > > all_in_one_hoodies = all_in_one(db.filters.name == "hoodie").select() > > I understand his cumbersome example, where you have to select a resultset > and then pass that to another select(). But I don't understand how I can > pass all_in_one() a parameter and how it knows to return all products which > have the "hoodie" filter name. > > > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.