| |
doctrine-user |
Maybe use construct() method? (Yes, without leading underscores)
Read the docs: http://preview.tinyurl.com/nxeuvv
On 7 Lip, 20:09, Alex Farcas <alex.far...@gmail.com> wrote:
> For various reasons (like implementing extended validation with
> Now in Person, i have the setUp function where i add some entries into
> After some debug, it was clear that the array was populated correctly,
> So here's what was printed on the screen, when fetching a Person with
> In the hope i explained things clearly, can anyone tell me why this is
> Alex
> specifications) i decided to extend DoctrineRecord. So assuming i have
> the entity/class called Person, it would inherit from BasePerson (the
> default behavior when autogenerated), and BasePerson would inherit
> from My_Doctrine_Record. And of course, My_Doctrine_Record, inherits
> from DoctrineRecord. So i just added a middle class, and did not let
> BasePerson extend Doctrine_Record directly as it normally happens.
> an array, and the array is a member of Person. In order to retrieve a
> Person i use this: $person = Doctrine::getTable( 'person' )->find
> ( (int)$id ); Everything works, the person is fetched, and i can play
> with it, BUT, the array populated with the setUp method is empty!!
> so the only explanation remaining was that the Person, was somehow
> cloned, and the array got empty in the process. I debugged further,
> overriding the constructor in My_Doctrine_Record, and added an "echo('
> instance ')". In the setUp method of Person, i added "echo(' set-up
> ')";
> find: instance instance set-up instance.
> Which means there were 3 instances of Person created, and only the
> second one got it's setUp method called, and it was pretty obvious
> that i was getting the last instance, since setUp was not called, and
> my array was thus empty.
> happening, and how to fix it? I don't care that the class Person is
> instantiated 3 times (rather wasteful and redundant i would say), but
> i do care about my setUp method being called, or having the object
> cloned properly (if cloning occurs on the third instance). In short i
> need to be able to have that array member i was describing above (or
> any member for that matter), keep it's values. Btw, the array member
> is called $_specifications, so there isn't a naming conflict with one
> of Doctrine_Record's members.