On 7/23/14,
pa...@egallys.com <
pa...@egallys.com> wrote:
> Hello,
Hello,
>
> What about initialize default value of an BaseObject from default value in
> database schema ?
>
> Table A schema:
> - id serial
> - field_1 integer not null default 123
> - field_2 varchar
> - field_3 boolean not null default 't'
>
> $object = new A();
>
> $object->getField1() === 123;
> $object->getField2() === null;
> $object->getField3() === false
>
Since entities are hydrated with the result of a projection operation
(SELECT, RETURNING), which can be overrided, they cannot be statically
bound with a structure thus default values. This is why entities are
schemaless data containers with no knowledge of database nor
persistence.
> Another question, Will a PommEntityManager break the Pomm philosophy ?
>
> For now we are doing
> $a = $connection->getMapFor('\EntityA')->findByPk(...)
>
> So to get $a we must know $connection.
> If we have to find entityA from connection1 entityB from connection2 and
> entityC from connection3, we must have $connection1, $connection2 and
> $connection3
>
> But with PommEntityManager:
> $a = $pommEntityManager->getMapFor('\EntityA')->findByPk(...);
> $b = $pommEntityManager->getMapFor('\EntityB')->findByPk(...);
> $c = $pommEntityManager->getMapFor('\EntityC')->findByPk(...);
>
> $d = new \EntityD();
> $pommEntityManager->save($d);
>
> $a->setField1(12345);
> $pommEntityManager->save($a);
>
>
> The PommEntityManager will be in charge of getting the right Pomm
> Connection and Pomm Database from a BaseObject classname.
An entity manager is -- surprisingly -- entity centric. In order to
make you benefit from relational goodness, Pomm is mapping oriented.
Most of its logic is defined in the Map classes.
Aside of that, your point of not having to deal with connections is
good, I am going to open a feature request concerning that point.
Cheers,
Grégoire
> --
> You received this message because you are subscribed to the Google Groups
> "PommProject" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
pommproject...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/pommproject.
> For more options, visit
https://groups.google.com/d/optout.
>
--
Grégoire HUBERT
Pomm :
http://www.pomm-project.org