Class Model
The model class of the MVC architecture. Extends the CRUD database abstraction layer to enhance it. This class should not be used directly. It should be extended with methods specific to the database table it is interacting with.
Located in /class.model.php (line 27)
CRUD | --Model
Inherited Variables
Inherited from CRUD
CRUD::$aData
CRUD::$oDatabase
CRUD::$oDataSet
CRUD::$sTableName
The Model's constructor - accepts the name of the table and an optional set of data to load into the parent CRUD object. Invokes CRUD::__construct() and passes these two parameters along.
- string $sTableName: The name of the table to work on
- mixed $oData: An array or object of data to load into the CRUD object
- CRUD::__construct()
- The constructor makes the necessary connection to the database (see Database::Construct) and attempts to load the schema of the specified table.
Wraps CRUD's Destroy() method to invoke the event OnBeforeDestroy() before calling CRUD::Destroy(), and to invoke the event OnAfterDestroy() afterwards. If either event returns false, execution of this method will stop and false will be returned.
- CRUD::Destroy()
- Destroys (deletes) the current data. This method will delete the primary record (assuming that the primary key for the data is set).
Triggered after a call to CRUD::Destroy(). If this method returns false, Model::Destroy() will return false. It is up to the user at this point to take the necessary actions, such as rolling back the database transaction.
Triggered after a call to CRUD::Save(), for INSERT only statements only. If this method returns false, Model::Save() will return false. It is up to the user at this point to take the necessary actions, such as Rolling back the database transaction.
Triggered after a call to CRUD::Save(), for both INSERT and UPDATE statements only. If this method returns false, Model::Save() will return false. It is up to the user at this point to take the necessary actions, such as Rolling back the database transaction.
Triggered after a call to CRUD::Save(), for UPDATE only statements only. If this method returns false, Model::Save() will return false. It is up to the user at this point to take the necessary actions, such as rolling back the database transaction.
Triggered before a call to CRUD::Destroy(). If this method returns false, Model::Destroy() will be halted and false returned.
Triggered before a call to CRUD::Save(), for INSERT statements only. If this method returns false, Model::Save() will be halted and false returned.
Triggered before a call to CRUD::Save(), for both INSERT and UPDATE actions. If this method returns false, Model::Save() will be halted and false returned.
Triggered before a call to CRUD::Save(), for UPDATE statements only. If this method returns false, Model::Save() will be halted and false returned.
Wraps CRUD's Save() method to invoke the events ValidateUpdate(), Validate(), OnBeforeUpdate(), OnBeforeSave(), respectively, before calling CRUD::Save() for an UPDATE query. Likewise, invokes the events ValidateInsert(), Validate(), OnBeforeInsert() and OnBeforeSave(), respectively, before calling CRUD::Save() for an INSERT statement.
If any of these events return false, Model::Save() returns false, before calling CRUD::Save().
If CRUD::Save() is invoked and returns true, the events OnAfterUpdate() and OnAfterSave() are invoked, respectively, for UPDATE queries. The events OnAfterInsert() and OnAfterSave() are invoked, respectively, for INSERT queries.
- CRUD::Save()
- Based on presence of primary key data, either creates a new record, or updates theexisting record
This method does the same thing as Save(), but also saves all related data loaded into the CRUD object as well. See CRUD::SaveAll() for more details
- CRUD::SaveAll()
- SaveAll() is misleading and really means SaveDeep(). This method will attempt to save all of the data stored within this CRUD class, and calls SaveAll() on all dependent CRUD data that is currently loaded into the class.
Triggered before a call to CRUD::Save(), for both INSERT and UPDATE actions. If this method returns false, Model::Save() will be halted and false returned.
Triggered before a call to CRUD::Save(), for INSERT only. If this method returns false, Model::Save() will be halted and false returned.
Triggered before a call to CRUD::Save(), for UPDATE only. If this method returns false, Model::Save() will be halted and false returned.
Inherited Methods
Inherited From CRUD
CRUD::__construct()
CRUD::AsJSON()
CRUD::AsXML()
CRUD::AsXMLString()
CRUD::buildWhereClause()
CRUD::Cleanup()
CRUD::Count()
CRUD::Current()
CRUD::Destroy()
CRUD::DestroyDataByColumnValue()
CRUD::Find()
CRUD::FindCount()
CRUD::FindRelationship()
CRUD::FindRelationship2()
CRUD::GetAll()
CRUD::GetDataByColumnValue()
CRUD::GetRecord()
CRUD::GetTableName()
CRUD::Insert()
CRUD::IsEmpty()
CRUD::Key()
CRUD::Load()
CRUD::Next()
CRUD::PrepareColumns()
CRUD::RecordExists()
CRUD::Rewind()
CRUD::Save()
CRUD::SaveAll()
CRUD::Update()
CRUD::UpdateQuery()
CRUD::Valid()
CRUD::__call()
CRUD::__clone()
CRUD::__get()
CRUD::__isset()
CRUD::__set()
CRUD::__toString()
CRUD::__unset()
Documentation generated on Thu, 25 Feb 2010 15:59:40 -0500 by phpDocumentor 1.4.3

