in reply to Re: Re: Re: Re: Inheritance and objects tied to a database
in thread Inheritance and objects tied to a database

I reckon you only need to untie and destroy the object once - if the data's shared then updating the child's data updates the parent's data automatically.

By the sounds of it, you don't need to worry about DESTROY in the child - just call the parent module's DESTROY and let it take care of the untieing of the object and the DB update.

Hope that helps ..
-- Foxcub

Replies are listed 'Best First'.
Re: Re[5]: Inheritance and objects tied to a database
by relax99 (Monk) on Dec 20, 2002 at 13:47 UTC
    That assumes that the data IS shared, and I don't think it is... In this case parent's data is different from child's data.
      If that's the case, and you can call the $self->Parent::DESTROY to save the child data, why not undef the parent's data at the same time, and add if defined around the untie?

      That way when the DESTROY method gets called for the parent, it finds that the data is undefd, and does nothing.

      Alternatively, always untie the parent's data first, then the child's, again testing defined and that should get you round the problem.

      Not sure if either of those methodologies are the best, though.

      Hope that helps
      -- Foxcub

        That would probably work. Basically you arrived at the same solution suggested by gjb. I am not sure if it's the best way of doing it either. I just don't know how it's usually done. It does seem to solve my original problem though - so that's cool. Thank you!