## Class mr_repository_abstract

Description

MR Repository Abstract

Most basic repository mapper that maps data from the database to an application's models and also from the models to the database.

A repository mapper DOES NOT need to extend this class as this class might be too simplistic for your needs.

In the end, all database interactions that take place between your models and the database should be stored in this class.

- author: Mark Nielsen
- see: http://martinfowler.com/eaaCatalog/dataMapper.html
- abstract:
- throws: coding_exception
- example: See this class in action

Located in /repository/abstract.php (line 62)

Variable Summary
mr_db_table $table
Method Summary
mr_repository_abstract delete (mr_model_record_abstract $model)
boolean|mr_model_record_abstract get ( $conditions, [int $strictness = MUST_EXIST])
mr_model_record_abstract get_new_model ()
mr_repository_recordset get_recordset ([null $conditions = null], [string $sort = ''], [int $limitfrom = 0], [int $limitnum = 0])
mr_db_table get_table ()
string get_table_name ()
stdClass; model_to_record (mr_model_record_abstract $model)
mr_model_record_abstract record_to_model ( $record)
mr_repository_abstract save (mr_model_record_abstract $model, [bool $bulk = false])
mr_repository_abstract set_table (mr_db_table|string $table)
Variables
mr_db_table $table (line 69)

The table that this repository mapper is primarily associated with

- access: protected

Methods
delete (line 237)

Delete a model

The model's ID property is required, but after the delete, the ID property will be set to null.

- throws: coding_exception
- access: public

mr_repository_abstract delete (mr_model_record_abstract $model)

- mr_model_record_abstract $model

get (line 172)

Get a model based on conditions

- access: public

boolean|mr_model_record_abstract get ( $conditions, [int $strictness = MUST_EXIST])

- array $conditions: Where conditions for get_record()
- int $strictness: IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended); MUST_EXIST means throw exception if no record or multiple records found

get_new_model (line 77)

Get a new instance of the model that the repository uses

- abstract:
- access: public

mr_model_record_abstract get_new_model ()
get_recordset (line 192)

Get a mr_repository_recordset based on conditions, etc

Use this to iterate over your models.

- access: public

mr_repository_recordset get_recordset ([null $conditions = null], [string $sort = ''], [int $limitfrom = 0], [int $limitnum = 0])

- null $conditions: Where conditions for get_recordset()
- string $sort: Sorting
- int $limitfrom: Limit from
- int $limitnum: Limit number

get_table (line 114)

Get the table that this repository mapper uses

Warning: this method WILL set the table property if it's not set already.

- access: public

mr_db_table get_table ()
get_table_name (line 85)

The name of the table that the repository uses

- abstract:
- access: public

string get_table_name ()
model_to_record (line 130)

Convert the model to a record

If the default implementation doesn't work, it's 100% acceptable to override this method.

- access: public

stdClass; model_to_record (mr_model_record_abstract $model)

- mr_model_record_abstract $model

record_to_model (line 157)

Convert a record to a model

If the default implementation doesn't work, it's 100% acceptable to override this method.

- access: public

mr_model_record_abstract record_to_model ( $record)

- stdClass $record

save (line 212)

Save a model

Common reason for needing to override this method is perhaps to update a time modified timestamp and then calling this parent method.

- access: public

mr_repository_abstract save (mr_model_record_abstract $model, [bool $bulk = false])

- mr_model_record_abstract $model
- bool $bulk

set_table (line 95)

Set the table that this repository mapper uses. Generally you do not want to use this.

- throws: coding_exception
- access: public

mr_repository_abstract set_table (mr_db_table|string $table)

- mr_db_table|string $table

Documentation generated on Thu, 28 Jun 2012 16:33:46 -0700 by phpDocumentor 1.4.3