Manuel Lemos | 9 Aug 2006 00:12
Picon
Favicon

Re: Re: Dependency

Hello,

Sorry for the delay.

on 07/17/2006 02:18 PM comfortablementeadormecido said the following:
> Yes the references are nullified indeed, but I ment a cascading
> removal of elements that are dependant of the existance of a certain
> object.
> Using the same example as before: If each State has a Collection of
> Cities, when a State is removed, and if the existance of a City
> depends on the existance of the corresponding State, then every City
> for that state should be removed as well.
> Currently the references to the state are set to NULL (by means of
> this query = "'UPDATE city SET state=NULL WHERE
> state='.strval($this->id)") but then every city that has its State
> attribute set to NULL should be removed one by one. Besides, the
> persistance of objects with references to other objects set to null is
> invalid as a default behaviour. By means of deleting a State you would
> be settig every city for that State in an invalid 'situation' (the
> word 'state' would have been confusing :p ).
> 
> Perhaps I'm getting this all wrong, please correct me if I am. As I
> said before I really put a lot of faith in this project as I think it
> would be a great help in my job but I still cant convince myself that
> the application is fully capable of satisfying my needs. I hope that
> by means of questions liike this I am helping clarify and possibly
> correct the functionality of the project and not just annoying you.

If you want to remove cities that belong to a state, you can delete the
city objects one by one and they automatically will be removed from the
collections they they belonged.

Cascaded deletes can be dangerous. Even if the database supports them, a
simple mistake may wipe the whole database. I never used them. As a
matter of fact, usually I have a removed flag in objects that I may want
to check past information later, rather than actually delete them.

That does not mean it cannot be done. It means it can be done with
proper care. I have just added it to the todo list now so I can
implement it when I have more time.

http://www.meta-language.net/metastorage-progress.xml

--

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

 

Gmane