Re: Recursion with database tables
| From: | Ernest E Vogelsinger | Date: | Wed, 19 Feb 2003 14:03:29 +0000 |
| Subject: | Re: Recursion with database tables | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136178@lists.php.net to get a copy of this message | ||
At 15:16 19.02.2003, Jono Bacon spoke out and said:
--------------------[snip]--------------------
>How would I go about recursing down the tree? Has anyone done this before?
--------------------[snip]--------------------
Given the DB layout I sketched before, you would:
1) delete all comments
delete from COMMENT
where id_message in (
select id from MESSAGE where id_topic in $id_topic);
2) delete all messages
delete from MESSAGE where id_topic = $id_topic;
3) delete the topic
delete from TOPIC where id = $id_topic;
Wrap the whole stuff in a transaction if your database supports it and
you'll be fine.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/