I have a dilemma. I used DI (read: factory) to provide the basic components for a homegrown ORM. The on-demand container provides database connections, DAO, Mappers, and their resulting domain objects.
Here is a general outline of the Mappers and Domain Object classes.
class Mapper{ public function __constructor($DAO){ $this->DAO = $DAO; } public function load($id){ if(isset(Monitor::members[$id]){ return Monitor::members[$id]; $values = $this->DAO->selectStmt($id);
ORM also contains a class (Monitor) based on the Unit of Work ie
class Monitor(){ private static array modified; private static array dirty; public function markClean($class); public function markModified($class); }
The ORM class itself simply coordinates the resources retrieved from the DI container. So, to create a new User object:
$Container = new DI_Container; $ORM = new ORM($Container); $User = $ORM->load('user',1);
My question is that. At that moment, when the user sets the values ββin the class of domain objects, I need to mark the class as "dirty" in the "Monitor" class. I have one of three options, as I see it
1: pass an instance of the Monitor class to a domain object. I noticed that this is marked as recursive in FirePHP - i.e. $ This-> Monitor-> markModified ($ this)
2: instantly starting the monitor directly in the domain object - does it break the DI? 3: Make monitoring methods static and call them from within a domain object - does this also interrupt DI?
What will be your recommended course of action (besides using the existing ORM, I do this for fun ...)
source share