Public Member Functions | Protected Member Functions | Protected Attributes

InfoRecords Class Reference

Inheritance diagram for InfoRecords:
Collaboration diagram for InfoRecords:

List of all members.

Public Member Functions

 __construct ($table_name, $key_name, $key_value=null)
 is_key_set ()
 set_key ($metadata_key)
 __get ($name)
 getArrayCopy ()
 __set ($name, $value)
 __isset ($name)
 __unset ($name)
 get_url_args ()
 delete_all ()
 commit ($metadata_key=null)
 count ()

Protected Member Functions

 _load ()

Protected Attributes

 $__inforecord_array = array()
 $_table_name
 $_key_name
 $_key_value
 $_loaded = false
 $_dirty = false
 $url_args

Detailed Description

Habari InfoRecords Class

Base class for managing metadata about various Habari objects

Definition at line 15 of file inforecords.php.


Constructor & Destructor Documentation

InfoRecords::__construct ( table_name,
key_name,
key_value = null 
)

Takes three parameters. The table of the options table, the name of the master key and the record_id for which options are managed. posts take a slug as a record_id, comments take a comment_id and users take a user_id (user_name)

IMPORTANT: if $primary_key_value is not set in the constructor, set_key MUST be called before inforecords can be set. Or bad things (think swarms of locusts o'er the land) will happen

Parameters:
string $table_name name of the table to insert info (use the DB::o()->table_name syntax)
string $key_name name of the primary key (for example "post_id")
mixed $key_value (optional) the master record key value (for example, info for post_id = 1 managed by setting this param to 1). Use set_key method if not set here.

Definition at line 44 of file inforecords.php.


Member Function Documentation

InfoRecords::__get ( name  ) 

Fetch info record value.

Parameters:
string $name Name of the key to get
Returns:
mixed Stored value for specified key

Reimplemented in PostInfo.

Definition at line 116 of file inforecords.php.

InfoRecords::__isset ( name  ) 

Test for the existence of specified info value

Parameters:
string $name Name of the option to set
Returns:
boolean true if the info option exists, false in all other cases

Definition at line 160 of file inforecords.php.

InfoRecords::__set ( name,
value 
)

Update the info record. The value will not be stored in the database until calling $this->commit();

Parameters:
string $name Name of the key to set
mixed $value Value to set

Definition at line 143 of file inforecords.php.

InfoRecords::__unset ( name  ) 

Remove an info option; immediately unsets from the storage AND removes from database. Use with caution.

Parameters:
string $name Name of the option to unset
Returns:
boolean true if the option is successfully unset, false otherwise

Definition at line 172 of file inforecords.php.

InfoRecords::_load (  )  [protected]

Populate the internal hashmap with the values from the DB.

Definition at line 77 of file inforecords.php.

Referenced by __get(), __isset(), __set(), __unset(), count(), and get_url_args().

InfoRecords::commit ( metadata_key = null  ) 

Commit all of the changed info options to the database. If this function is not called, then the options will not be written.

Parameters:
mixed $metadata_key (optional) Key to use when writing info data.
Returns:
bool True if the commit succeeded.

Definition at line 228 of file inforecords.php.

InfoRecords::count (  ) 

Get the number of info records

Returns:
int Number of info records here

Definition at line 286 of file inforecords.php.

InfoRecords::delete_all (  ) 

Remove all info options. Primarily used when deleting the parent object. I.E. when deleting a user, the delete method would call this.

Returns:
boolean true if the options were successfully unset, false otherwise

Definition at line 202 of file inforecords.php.

InfoRecords::get_url_args (  ) 

Returns a set of properties used by URL::get to create URLs

Returns:
array Properties of this post used to build a URL

Implements URLProperties.

Definition at line 187 of file inforecords.php.

InfoRecords::is_key_set (  ) 

Test if the master record value has been set (and thus, safe to set info records).

Returns:
boolean true if master record value has been set already, false otherwise

Definition at line 57 of file inforecords.php.

InfoRecords::set_key ( metadata_key  ) 

function set_key For use in cases where the master record key is not known at the time of object instantiation (ie: a new post)

Parameters:
mixed $metadata_key the id of the master record (could be int or string, most likely int)

Definition at line 69 of file inforecords.php.


The documentation for this class was generated from the following file: