Class Activerecord_table
Submitted by bingomanatee on 13 March, 2010 - 19:23
This class governs all the saving and loading of data from the database.
Properties:
- key_field: string. The name of the primary key.
- eq: string. The equality verb for key comparison (either '=' or 'LIKE');
- name: string. The name of the table.
- schema: array. An array of stdClass column descriptions from the database. NOTE: all fields in the schema have their first letter capitalized. (at least they do on my dev system -- hopefully yours too...)
Methods:
- insert(stdClass $pData): inserts a new record into the database.
- update(stdClass $pData): updates an existing record in the database.
- delete(var $record): deletes an existing record in the database.
- fields($pQualified = FALSE): string[]. Returns an array of the names of the table fields. If $pQualified, will be annotated with the table name as in {leads}.`first_name`, {leads}.`last_name`.
- filter_fields(stdClass $pFields): stdClass. Merges the fields passed in with the defaults in the schema and removes any fields that are not in the table.
- find($pCriteria): Activerecord[] see the attached article on the sql system. Returns the records matching the criteria that can be either a SQL statement (string) or a nested array describing a SQL statement.
- static get($pTable): Activerecord_table. A singleton factory that returns an object for a given table. Ensures that only one Activerecord_table exists per database table.
- get_key($pKey): scalar. returns the Activerecord corresponding to the given key.
- qualify_field($pField, $pAs = NULL): string. Returns a formal definition of a field with the table prefiix ({leads}.`last_name`) with an optional synonym from the second parameter.
- query(string $pQuery, $return): var[]. given a SQL string, returns an array of data from the database, either in array, stdClass, or Activerecord form.

Post new comment