|
Moodle
2.2.1
http://www.collinsharper.com
|

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) |
A data abstraction object that holds methods and attributes
Definition at line 30 of file data_object.php.
| __construct | ( | $ | params = NULL, |
| $ | fetch = true |
||
| ) |
Constructor. Optionally (and by default) attempts to fetch corresponding row from DB.
| array | $params | an array with required parameters for this data object. |
| boolean | $fetch | Whether 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.

| delete | ( | ) |
Deletes this object from the database.
Definition at line 210 of file data_object.php.

| static fetch | ( | $ | params | ) | [static] |
Finds and returns a data_object instance based on params. abstract
| array | $params | associative arrays varname=>value |
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.

| static fetch_all | ( | $ | params | ) | [static] |
Finds and returns all data_object instances based on params.
| array | $params | associative arrays varname=>value |
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
Definition at line 143 of file data_object.php.

| static fetch_helper | ( | $ | table, |
| $ | classname, | ||
| $ | params | ||
| ) | [static, protected] |
Factory method - uses the parameters to retrieve matching instance from the DB. final protected
Definition at line 126 of file data_object.php.


| get_record_data | ( | ) |
Returns object with fields and values that are defined in database
Definition at line 232 of file data_object.php.


| 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.
Definition at line 253 of file data_object.php.


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.
| bool | $deleted |
Definition at line 315 of file data_object.php.

| 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.

| update | ( | ) |
Updates this object in the Database, based on its object variables. ID must be set.
Definition at line 190 of file data_object.php.


| update_from_db | ( | ) |
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.


| int $id |
The PK.
Definition at line 54 of file data_object.php.
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 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.