I am creating this UnitOfWork object and an Db adapter that uses it. When the Adapter fetches a row:
- it will turn the row into an object of the correct type
- put the object into the UnitOfWork to be updated
- 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.