A Data Mapper is meant to:
Move data between objects and a database while keeping them independent of each other and the mapper itself. - Martin Fowler
Most Data Mappers I work with only deal with and return a single object instance.
Is it okay use ONLY ONE Data Mapper to retrieve, manipulate and save multiple objects of the same type?
Example:
public class UserController {
public function index() {
UserMapper $um = new UserMapper();
User $u1 = $um->getById(34);
User $u2 = $um->getById(23);
User $u2 = $um->getById(02);
//Do stuff to user objects...
$um->save($u1);
$um->save($u2);
$um->save($u3);
}
}
Aucun commentaire:
Enregistrer un commentaire