Moodle  2.2.1
http://www.collinsharper.com
data_object Class Reference
Inheritance diagram for data_object:

Public Member Functions

 __construct ($params=NULL, $fetch=true)
 load_optional_fields ()
 update ()
 delete ()
 get_record_data ()
 insert ()
 update_from_db ()
 notify_changed ($deleted)

Static Public Member Functions

static fetch ($params)
static fetch_all ($params)
static fetch_all_helper ($table, $classname, $params)
static set_properties (&$instance, $params)

Data Fields

 $table
 $required_fields = array('id')
 $optional_fields = array()
 $id

Static Protected Member Functions

static fetch_helper ($table, $classname, $params)

Detailed Description

A data abstraction object that holds methods and attributes

Definition at line 30 of file data_object.php.


Constructor & Destructor Documentation

__construct ( params = NULL,
fetch = true 
)

Constructor. Optionally (and by default) attempts to fetch corresponding row from DB.

Parameters:
array$paramsan array with required parameters for this data object.
boolean$fetchWhether to fetch corresponding row from DB or not, optional fields might not be defined if false used

Definition at line 62 of file data_object.php.

Here is the call graph for this function:


Member Function Documentation

delete ( )

Deletes this object from the database.

Returns:
boolean success

Definition at line 210 of file data_object.php.

Here is the call graph for this function:

static fetch ( params) [static]

Finds and returns a data_object instance based on params. abstract

Parameters:
array$paramsassociative arrays varname=>value
Returns:
object data_object instance or false if none found.

Reimplemented in completion_criteria_completion, completion_completion, completion_aggregation, completion_criteria_grade, completion_criteria_course, completion_criteria_activity, completion_criteria_date, completion_criteria_duration, completion_criteria_role, completion_criteria_self, and completion_criteria_unenrol.

Definition at line 107 of file data_object.php.

Here is the caller graph for this function:

static fetch_all ( params) [static]

Finds and returns all data_object instances based on params.

Parameters:
array$paramsassociative arrays varname=>value
Returns:
array array of data_object instances or false if none found.

Reimplemented in completion_criteria, completion_criteria_completion, and completion_aggregation.

Definition at line 117 of file data_object.php.

static fetch_all_helper ( table,
classname,
params 
) [static]

Factory method - uses the parameters to retrieve all matching instances from the DB. final protected

Returns:
mixed array of object instances or false if not found

Definition at line 143 of file data_object.php.

Here is the call graph for this function:

static fetch_helper ( table,
classname,
params 
) [static, protected]

Factory method - uses the parameters to retrieve matching instance from the DB. final protected

Returns:
mixed object instance or false if not found

Definition at line 126 of file data_object.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns object with fields and values that are defined in database

Definition at line 232 of file data_object.php.

Here is the call graph for this function:

Here is the caller graph for this function:

insert ( )

Records this object in the Database, sets its id to the returned value, and returns that value. If successful this function also fetches the new object data from database and stores it in object properties.

Returns:
int PK ID if successful, false otherwise

Definition at line 253 of file data_object.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Makes sure all the optional fields are loaded. If id present (==instance exists in db) fetches data from db. Defaults are used for new instances.

Definition at line 86 of file data_object.php.

notify_changed ( deleted)

Called immediately after the object data has been inserted, updated, or deleted in the database. Default does nothing, can be overridden to hook in special behaviour.

Parameters:
bool$deleted

Definition at line 315 of file data_object.php.

Here is the caller graph for this function:

static set_properties ( &$  instance,
params 
) [static]

Given an associated array or object, cycles through each key/variable and assigns the value to the corresponding variable in this object. final

Definition at line 299 of file data_object.php.

Here is the caller graph for this function:

update ( )

Updates this object in the Database, based on its object variables. ID must be set.

Returns:
boolean success

Definition at line 190 of file data_object.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Using this object's id field, fetches the matching record in the DB, and looks at each variable in turn. If the DB has different data, the db's data is used to update the object. This is different from the update() function, which acts on the DB record based on the object.

Definition at line 278 of file data_object.php.

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

int $id

The PK.

Definition at line 54 of file data_object.php.

array $optional_fields = array()

Array of optional fields with default values - usually long text information that is not always needed. If you want to create an instance without optional fields use: new data_object($only_required_fields, false);

Definition at line 48 of file data_object.php.

array $required_fields = array('id')

Array of required table fields, must start with 'id'.

Reimplemented in completion_criteria, completion_completion, completion_aggregation, and completion_criteria_completion.

Definition at line 41 of file data_object.php.

string $table

Table that the class maps to in the database

Reimplemented in completion_criteria, completion_completion, completion_aggregation, and completion_criteria_completion.

Definition at line 35 of file data_object.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations