Changes between Version 50 and Version 51 of DeveloperGuidelines/Optimisation


Ignore:
Timestamp:
06/18/10 09:57:51 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Optimisation

    v50 v51  
    201201}}}
    202202
     203The nested case:
     204
     205{{{
     206for id in ids:
     207  record1 = db(db.table1.id == id).select().first()
     208  if record1 and record1.some_attribute == some_value:
     209    record2 = db(db.table2.id == record1.some_key).select().first()
     210    if record2:
     211        ...
     212}}}
     213
     214...if there is nothing to else to do with the table1 records, try instead:
     215
     216{{{
     217query = (db.table1.id.belongs(ids)) & \
     218        (db.table1.some_attribute == some_value) & \
     219        (db.table2.id = db.table1.some_key)
     220record2 = db(query).select(db.table2.ALL, limitby(0,1)).first()
     221if record2:
     222    ...
     223}}}
     224
    203225----
    204226DeveloperGuidelines
    205 DeveloperGuidelines
    206 DeveloperGuidelines
     227