Difference between revisions of "ModelBase API"

From Warwick Student Cinema
Jump to: navigation, search
m
Line 22: Line 22:
   
 
===save===
 
===save===
  +
Updates the objects data in the database. If the data is new, it should insert a new row with the objects data.
  +
  +
===update===
  +
Pulls the objects data from the database again and updates the object.
   
 
===delete===
 
===delete===
  +
  +
===new/__construct===
  +
If <code>new X($id)</code> is called, it should instantiate the object with the information associated with that id.
  +
  +
If <code>new X()</code> is called, it should leave all fields blank and when save is called, it inserts into the DB rather than updates.
   
   

Revision as of 16:30, 9 November 2009

An API that should be common to all model classes. Includes core methods that should be available in all classes, and optional methods that provide a common structure for frequently used extensions.

Core API

Static methods

loadByID

get

mixed get(QueryCondition condition)

description

Returns a single object matching the condition. Raises an exception if 0 or more than one object match.

filter

mixed get(QueryCondition condition)

description

Returns a list of objects matching the condition.

Instance methods

save

Updates the objects data in the database. If the data is new, it should insert a new row with the objects data.

update

Pulls the objects data from the database again and updates the object.

delete

new/__construct

If new X($id) is called, it should instantiate the object with the information associated with that id.

If new X() is called, it should leave all fields blank and when save is called, it inserts into the DB rather than updates.


Common Extensions