Skip to content
jeanphilippe-p edited this page Aug 13, 2016 · 58 revisions

Table of contents

  1. Object Collection
  2. Main Object Collection
  3. Local Object Collection
  4. Object serialization
  5. Object deserialization
  6. Object Import
  7. Object Export

Object Collection

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

Main Object Collection

## Local Object Collection

Object serialization

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();

Specific case for sql database

### Your table has an incremental id Like other serializations call save() function but there are two cases to identify :

  1. if your Object doesn't have id set, an insert will be executed. if insert is successfull, id will be set in your object.
  2. if Object has id set, an update will be executed

### Your table doesn't have an incremental id

Clone this wiki locally