2008年10月17日星期五

Re: [fw-db] Re: Re[fw-db] ferencemap: delete CASCADE

I don't know if ZF has support for that, but that can be accomplished using references in MySQL. You'll need to use the InnoDB storage engine for it to work.


You can set up different type of constraints, like automatically updating all child rows when the parent row's primary key changes, or restricting the deletion of parent rows when child rows exist (which is what you want).

ALTER TABLE tbl_name     ADD [CONSTRAINT [symbol]] FOREIGN KEY     [index_name] (index_col_name, ...)     REFERENCES tbl_name (index_col_name,...)     [ON DELETE reference_option]     [ON UPDATE reference_option] 

On Fri, Oct 17, 2008 at 9:15 AM, EducatedFool <wimkumpen@hotmail.com> wrote:

In my opinion it must folow your reference map anywhere it goes. I'll try to
post this somewhere on the zend site. Maybe we get a good answer there...

Another question. Is there something in the zend framework where: when I
want to delete something it checks if the value is used in another table,
and don't delete it when it is.

e.g. table with articles. Every articles is connected with a category. when
I try to delete a category, it 'll check if that id is used in the table
articles. If used, it 'll not delete it. If not used, the category can be
deleted.

something like that would also be usefull for a lot of programmers...
View this message in context: http://www.nabble.com/Referencemap%3A-delete-CASCADE-tp20027817p20036445.html
Sent from the Zend DB mailing list archive at Nabble.com.




--
-Hector

没有评论: