This topic is locked

Master detail how to delete all associated records

9/14/2012 7:15:44 AM
PHPRunner General questions
I
igiacchi author

In my database I have in cascade two master detail tables.
The first table is:

Company master

Address detail
The second is:

Address master (and Company detail)

Contact detail
I would like to delete all Contact record when I delete an Address associated to all Contact.

And delete all records associated to all Address and all Contact when I delete one Company record.
Eg.
Company_db

1 Company_1

2 Company_2
Address_db

1 Address_1 link the record Company_1

2 Address_2 link the record Company_1

3 Address_3 link the record Company_2
Contact_db

1 Contact_1 link the record Address_1

2 Contact_2 link the record Address_1

3 Contact_3 link the record Address_2

4 Contact_4 link the record Address_3
So when I delete the record Company_1 I need aslo to delete Address_1,_2,Contact_1,_2,_3
I'm using PHPrunner 6.1 with MySQL 5.1.
I'm a novice and I don't know how do this.
There is anyone that can help me about or some example.
Many thanks in advance

Sergey Kornilov admin 9/14/2012

You can use BeforeDelete event of the master tables to delete all associated details records.

More info: http://xlinesoft.com/phprunner/docs/before_record_deleted.htm