Model Base Class. More...
Public Member Functions | |
__construct (PDO $pdo, $id=null) | |
Constructor. | |
__sleep () | |
__sleep implementation | |
__get ($key) | |
__get implementation | |
__set ($key, $value) | |
__set implementation | |
__isset ($key) | |
__isset implementation | |
getData () | |
create (array $data) | |
Create method (Crud) | |
retrieve ($id) | |
Retrieve method (cRud) | |
update (array $data=array()) | |
Update method (crUd) | |
delete () | |
Delete method (cruD) | |
Protected Member Functions | |
_init ($statement) | |
Initialize a statement. | |
Protected Attributes | |
$_pdo | |
Database connection object. | |
$_idKey = "id" | |
Name of the identifying key (the PRIMARY KEY of your table in fact) | |
$_data = array() | |
Record data. | |
$_statements = array() | |
Statements cache. |
Model Base Class.
Definition at line 20 of file axBaseModel.class.php.
axBaseModel::__construct | ( | PDO $ | pdo, |
$ | id = null |
||
) |
Constructor.
If $id
is provided, the axModel::retrieve() method will be called with this parameter.
PDO | $pdo | The database connection object |
mixed | $id | [optional] [default null ] |
InvalidArgumentException | If the $pdo parameter is null |
RuntimeException | If the $id parameter did not match an existing record |
Implements axModel.
Reimplemented in axMySQLObject.
Definition at line 74 of file axBaseModel.class.php.
axBaseModel::__get | ( | $ | key | ) |
__get implementation
Retrieves a record data identified by the $key
parameter.
string | $key |
Definition at line 100 of file axBaseModel.class.php.
axBaseModel::__isset | ( | $ | key | ) |
__isset implementation
Tells if a record data exists.
string | $key |
Definition at line 126 of file axBaseModel.class.php.
axBaseModel::__set | ( | $ | key, |
$ | value | ||
) |
__set implementation
Updates a record data identified by the $key
parameter with the $value
parameter.
string | $key | |
mixed | $value |
Definition at line 114 of file axBaseModel.class.php.
axBaseModel::_init | ( | $ | statement | ) | [abstract, protected] |
Initialize a statement.
This method is intended to create the `PDOStatement` objects used by CRUD methods (create, retrieve, update, delete).
A statement is identified by its name:
string | $statement | The statement name |
Reimplemented in axMySQLObject.
axBaseModel::create | ( | array $ | data | ) |
Create method (Crud)
Creates the record over the RDBMS using the create
prepared statement. Will return false in case of error
array | $data |
RuntimeException | If the create statement couldn't be initialized |
Implements axModel.
Definition at line 151 of file axBaseModel.class.php.
Delete method (cruD)
Destruct the record over the RDBMS using the delete
prepared statement.
RuntimeException | If the delete statement coulnd't be initialized |
Implements axModel.
Definition at line 213 of file axBaseModel.class.php.
Get record data
Will return null if the record hasn't been fetched yet (no call to axModel::retrieve() has been done).
Implements axModel.
Definition at line 137 of file axBaseModel.class.php.
axBaseModel::retrieve | ( | $ | id | ) |
Retrieve method (cRud)
Reads the record over the RDBMS using the retrieve
prepared statement.
mixed | $id |
RuntimeException | If the retrieve statement couldn't be initialized |
Implements axModel.
Definition at line 171 of file axBaseModel.class.php.
axBaseModel::update | ( | array $ | data = array() | ) |
Update method (crUd)
Updates the record over the RDBMS using the update
prepared statement. The $data
parameter will be merged with the current record data.
array | $data | [optional] [default array() ] The data to add for updating |
RuntimeException | If the update statemetn couldn't be initialized |
Implements axModel.
Definition at line 194 of file axBaseModel.class.php.
array axBaseModel::$_data = array() [protected] |
Record data.
Definition at line 38 of file axBaseModel.class.php.
string axBaseModel::$_idKey = "id" [protected] |
Name of the identifying key (the PRIMARY KEY of your table in fact)
Definition at line 32 of file axBaseModel.class.php.
PDO axBaseModel::$_pdo [protected] |
Database connection object.
Definition at line 26 of file axBaseModel.class.php.
array axBaseModel::$_statements = array() [protected] |
Statements cache.
Definition at line 44 of file axBaseModel.class.php.