Beispiel #1
0
 /**
  * Saves or updates the persistent $object to the database.
  *
  * If the object is a new object an INSERT INTO query will be executed. If
  * the object is persistent already it will be updated with an UPDATE
  * query.
  *
  * Newly saved objects are automatically recorded in the identity map.
  * Updates to existing objects are reflected automatically, too.
  *
  * @throws ezcPersistentDefinitionNotFoundException
  *         if the definition of the persistent object could not be loaded.
  * @throws ezcPersistentObjectException
  *         if $object is not of a valid persistent object type.
  * @throws ezcPersistentObjectException
  *         if any of the definition requirements are not met.
  * @throws ezcPersistentObjectException
  *         if the insert or update query failed.
  *
  * @param ezcPersistentObject $object
  */
 public function saveOrUpdate($object)
 {
     $this->session->saveOrUpdate($object);
     $class = get_class($object);
     $def = $this->definitionManager->fetchDefinition($class);
     $state = $object->getState();
     $id = $state[$def->idProperty->propertyName];
     if ($this->properties['options']->refetch || $this->identityMap->getIdentity($class, $id) === null) {
         $this->identityMap->setIdentity($object);
     }
 }