Jeff PHP framework  0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
model Class Reference

Model class of the MVC pattern, is the class used to represent a database record object. More...

+ Inheritance diagram for model:

Public Member Functions

 __construct ($id, $table=null)
 Constructs a model instance.
 __get ($pName)
 Getter method.
 __set ($pName, $value)
 Setter method.
 deleteData ()
 Deletes the object properties from database.
 saveData ($insert=false)
 Saves the model object.
 setIdName ($id_name)
 Setter method for $_id_name property.
 setTable ($table)
 Setter method for $_tbl_data property.

Protected Member Functions

 initDbProp ($id)
 Model initialization.
 initNullProp ()
 Initialization of an empty model object.

Protected Attributes

 $_chgP = array()
 changed model properties
 $_id_name = 'id'
 the name of the primary key field
 $_p = array()
 model properties
 $_registry
 the registry singleton instance
 $_tbl_data = ''
 the database table of the model

Detailed Description

Model class of the MVC pattern, is the class used to represent a database record object.

This is the general model class extended by all specific module models. It acts like an interface to the database table which stores the module data and so has:

  • the getter and setter methods to set and retrieve properties (field values)
  • the save and delete action methods to perform database actions (insert, update and delete statements)
  • the init methods to instantiate the object and set all its properties reading the field values from db.

A Model instance represents a record of a database table.
Each model stores all the record field values as elements of a property array. Each model property value can be retrieved calling it as a normal property.
i.e. $model->field is the same as $model->_p['field'] and contains the value of 'field' for the represented record.

Author:
abidibo abidi.nosp@m.bo@g.nosp@m.mail..nosp@m.com
Version:
0.99
Date:
2011-2012

Definition at line 41 of file model.class.php.


Constructor & Destructor Documentation

model::__construct ( id,
table = null 
)

Constructs a model instance.

Parameters:
mixed$idthe identifier of the record (the primary key value)
mixed$tablethe model database table. Default null (may be set after object construction)
Returns:
model instance

Definition at line 80 of file model.class.php.

+ Here is the call graph for this function:


Member Function Documentation

model::__get ( pName)

Getter method.

Returns the value of the given property. Calls the specific property getter method if exists, otherwise returns directly its value.

Parameters:
string$pNamethe property name
Returns:
null if the requested property is not a model property, the specific getter method for the property if exists or the property value

Definition at line 166 of file model.class.php.

model::__set ( pName,
value 
)

Setter method.

Sets the value of the given property. Calls a specific property setter method if exists.

Parameters:
string$pNamethe property name
mixed$valuethe property value
Returns:
mixed false if the propertiy is not a model property, the specific setter method for the property if exists or true.

Definition at line 183 of file model.class.php.

Deletes the object properties from database.

Returns:
the operation result, true on success, false on failure

Definition at line 224 of file model.class.php.

model::initDbProp ( id) [protected]

Model initialization.

Initializes the model object retrieving data from the database. If the record still doesn't exist, returns an associative array with all null values.

Parameters:
mixed$idthe identifier of the record (the primary key value)
Returns:
an associative array with all model properties in the form array("property_name" => "value")

Definition at line 123 of file model.class.php.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

model::initNullProp ( ) [protected]

Initialization of an empty model object.

Returns:
an associative array with all model properties set to null in the form array("property_name" => null)

Definition at line 147 of file model.class.php.

+ Here is the caller graph for this function:

model::saveData ( insert = false)

Saves the model object.

Stores the object properties in the database.

Parameters:
bool$insertforce new record insertion
Returns:
the operation result, true on success, false on failure

Definition at line 203 of file model.class.php.

model::setIdName ( id_name)

Setter method for $_id_name property.

Parameters:
mixed$id_namethe name of the primary key
Returns:
void

Definition at line 96 of file model.class.php.

model::setTable ( table)

Setter method for $_tbl_data property.

Parameters:
string$tablethe model database table
Returns:
void

Definition at line 108 of file model.class.php.


Field Documentation

model::$_chgP = array() [protected]

changed model properties

an array an array containing the list of changed model properties

Definition at line 55 of file model.class.php.

model::$_id_name = 'id' [protected]

the name of the primary key field

Definition at line 71 of file model.class.php.

model::$_p = array() [protected]

model properties

an associative array containing the record fields name and their value

Definition at line 48 of file model.class.php.

model::$_registry [protected]

the registry singleton instance

Definition at line 66 of file model.class.php.

model::$_tbl_data = '' [protected]

the database table of the model

Definition at line 61 of file model.class.php.


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