TDBM internals
AbstractTDBMObject
All beans extend the AbstractTDBMObject
class.
This class represents a bean. A bean is usually linked to one row in one table but can be linked to many rows in many
tables is DB inheritance is used (a primary key of one table is also a foreign key).
Therefore, a AbstractTDBMObject
object contains:
- A list of
$dbRows
(A DbRow object represent a row in one table)- As soon as the object leaves the "detached" mode, this array is supposed to be sorted from parent to child table.
$status
: the status of the current object
A DbRow
object contains the following properties:
$dbRow
: the data contained by the object, as an array of column => value$primaryKeys
: the list of primary keys to access this object, as an array of column => value$status
: the status of the current object
Statuses
AbstractTDBMObject
and DbRow
can have the following statuses:
TDBMObjectStateEnum::STATE_DETACHED
: when an object has been created with thenew
keyword and is not yet aware of theTDBMService
instance.DbRow::$primaryKeys
: emptyTDBMService::$toSaveObjects
: noTDBMService::$objectStorage
: no
TDBMObjectStateEnum::STATE_NEW
: when an object is known fromTDBMService
but not yet stored in database. This happens after calling theTDBMService->attach
method on a detached object.DbRow::$primaryKeys
: emptyTDBMService::$toSaveObjects
: yesTDBMService::$objectStorage
: no
TDBMObjectStateEnum::STATE_LOADED
: when an object has been loaded fromTDBMService
and is not modified. This happens after calling theTDBMService->getObject
for instance.DbRow::$primaryKeys
: setTDBMService::$toSaveObjects
: noTDBMService::$objectStorage
: yes
TDBMObjectStateEnum::STATE_DIRTY
: when an object has been loaded fromTDBMService
and is modified. This happens after calling theTDBMService->getObject
for instance, then calling a setter on the bean.DbRow::$primaryKeys
: setTDBMService::$toSaveObjects
: yesTDBMService::$objectStorage
: yes
TDBMObjectStateEnum::NOT_LOADED
: when an object has been lazy-loaded fromTDBMService
and no getter has been called on it.DbRow::$primaryKeys
: setTDBMService::$toSaveObjects
: noTDBMService::$objectStorage
: yes
TDBMObjectStateEnum::DELETED
: when an object has been deleted usingTDBMService->delete
.DbRow::$primaryKeys
: it depends on original state (before call to delete)TDBMService::$toSaveObjects
: noTDBMService::$objectStorage
: no
Found a typo? Something is wrong in this documentation? Just fork and edit it!