views:

49

answers:

1

I am creating this UnitOfWork object and an Db adapter that uses it. When the Adapter fetches a row:

  1. it will turn the row into an object of the correct type
  2. put the object into the UnitOfWork to be updated
  3. return the object

Example code

$entity = $adapter->findById(1);

The internal working dummy:

class Adapter {
  function findById($id) {
    $sql = $this->createFindByIdSql($id);
    $query = mysql_query($sql);

    $row = mysql_fetch_assoc($query);
    $entity = $this->entityFromRow($row);

    $this->getUnitOfWork()->lookForUpdates($entity);

    return $entity;
  }
}

Then I change the return object and commit

$entity->name = 'something else';
$adapter->commit();

But the stored entity in the UnitOfWork object is not changed on this one occassion. But it works most of the time.

A: 

i dont see anything wrong in there, probably you should provide the code where you assing the entity into the adapter, and also in the part of lookForUpdates ¿is that passed by reference? ¿is there where you assing it?

useless