Loading State from the DB (cont)
  • Select all of the columns from the table
    • More complex might delay loading of some columns until used
  • Use the primary key passed in to generate the where clause
    • Note, primary key spans two columns
    • SQLForm() is a utility routine to help format SQL queries
  • Throw exception if DB query can't find row
  • Extract data from query results back into instance data
    • Storage of long integer values in DB varies from DB to DB
    • Broke time value up into 2 integer values
  • Set marker that cached state is unmodified
    • Performance optimization
    • Avoid writing out instance data when it is unchanged

Next Slide >>