the DAL has only these API: db(query).select(….) db(query).update(…) db(query).count() db(query).delete() table.insert(…)
which map into the corresponding SQL SELECT, UPDATE, COUNT, DELETE and INSERT. If you define a table with db.define_table(‘person’,Field(‘name’)) than you refer to it by db.person If you define it with Person = db.define_table(‘person’,Field(‘name’)) than you can refer to it by simply Person. other the query all the other arguments are optional. On Feb 24, 2015, at 7:49 AM, Abhijit Chatterjee <achatterjee...@gmail.com> wrote: > Hello, > > Does anyone know how to rewrite this two contoller line? After model and > view, I am trying to get familiar with controller and I am finding when a > code is summarized, its hard to understand at times. Wondering if someone can > break it down for me a little? > > first def: > > (1) categories = db(db.category).select(orderby=db.category.name) > > why two dbs? can we rewrite this without the select? Is select is a web2py > key word? I come from a MATLAB world where we define the structure first and > then use. I don't recall I defined select to be a struct. > > (2) similarly on my second def: > > category = db.category(request.args(0)) > > Now, I only see one db instead of two. Why? I understand the request args > means where I click. Which argument is it. > > also this line, > > news = db(db.news.category == category.id).select(orderby=db.news.vote) > > Its hard to understand when lot of arguments are combined into one. Anyone > can help break it down for me a little? Any idea about how to rewrite that, > may be even using "if"statement without structure if possible? > > > > > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.