-
Notifications
You must be signed in to change notification settings - Fork 0
Object management
jeanphilippe-p edited this page Aug 13, 2016
·
58 revisions
- Object Collection
- Main Object Collection
- Local Object Collection
- Object serialization
- Object deserialization
- Object Import
- Object Export
An Object Collection permit to store objects and find them in constant time. Objects are grouped by model and by id. Obviously an object without id property cannot be stored in Object Collection.
Example of an Object Collection structure :
[
person : [
an_id_one : person_object_one,
an_id_two : person_object_two
],
town : [
an_id_one : town_object_one
],
house : [
an_id_one : house_object_one,
an_id_two : house_object_two
]
]
Example of usage :
$lPersonOne; // consider object already exists, has a model Person and has an id 'one'
$objectCollection = new OjectCollection();
$objectCollection->addObject($lPersonOne);
$objectCollection->hasObject('one', 'Person'); // return true
$object = $objectCollection->getObject('one', 'Person'); // return object previously added
$objectCollection->hasObject('two', 'Person'); // return false
$object = $objectCollection->getObject('two', 'Person'); // return null
$objectCollection->hasObject('one', 'House'); // return false
$object = $objectCollection->getObject('one', 'House'); // return null
## Local Object Collection
Whatever is your serialzation you just have to call one function save() to serialize your object. Obviously the model associated to your object must have a serialization.
$object->save();
### Your table has an incremental id
Like other serializations call save() function but there are two cases to identify :
- if your Object doesn't have id set, an insert will be executed. if insert is successfull, id will be set in your object.
- if Object has id set, an update will be executed
### Your table doesn't have an incremental id