Re: [PHP] Recursion with database tables

2003-02-19 Thread Jono Bacon
Hi all, Thanks for your help. I now have a wealth of things to try - I was initially going for the bottom up approach by starting at the bottom of the tree and working up, but I quite like the idea of storing id's in an array or list, although this would mean two queries to the DB. I am still

Re: [PHP] Recursion with database tables

2003-02-19 Thread Ernest E Vogelsinger
At 14:56 19.02.2003, Jono Bacon spoke out and said: [snip] >The code that you posed is the technique I have used at the moment. This >technique works fine, but like my mate said, this limits me to a single >parent for a comment/message. I admit that is unli

Re: [PHP] Recursion with database tables

2003-02-19 Thread Ernest E Vogelsinger
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 d

Re: [PHP] Recursion with database tables

2003-02-19 Thread David Otton
On Wed, 19 Feb 2003 14:16:47 +, you wrote: >>Otherwise, yes, in MySQL you have to recurse down the tree deleting >>comments. >How would I go about recursing down the tree? Has anyone done this before? I have, but it's been a while. Something like (pseudo-code) . def delete_comments(a) :

Re: [PHP] Recursion with database tables

2003-02-19 Thread rblack
Jono Bacon ahoo.co.uk> cc:

Re: [PHP] Recursion with database tables

2003-02-19 Thread Jono Bacon
David Otton wrote: On Wed, 19 Feb 2003 13:56:49 +, you wrote: One questions though - if I delete a topic, I need to delete all of its child messages and all of the child comments from each message. What is the best technique to do this? This has been driving me up the wall as it seems

Re: [PHP] Recursion with database tables

2003-02-19 Thread David Otton
On Wed, 19 Feb 2003 13:56:49 +, you wrote: >One questions though - if I delete a topic, I need to delete all of its >child messages and all of the child comments from each message. What is >the best technique to do this? This has been driving me up the wall as >it seems to involve some kind

Re: [PHP] Recursion with database tables

2003-02-19 Thread Jono Bacon
Ernest E Vogelsinger wrote: At 14:43 19.02.2003, Jono Bacon said: [snip] At the moment I have three tables: Topic, Message, Comment. A topic has messages and each message can have comments. I have set this up with a table each and a field for the id of

Re: [PHP] Recursion with database tables

2003-02-19 Thread Ernest E Vogelsinger
At 14:43 19.02.2003, Jono Bacon said: [snip] >At the moment I have three tables: Topic, Message, Comment. A topic has >messages and each message can have comments. I have set this up with a >table each and a field for the id of the parent (e.g. a comment wi

[PHP] Recursion with database tables

2003-02-19 Thread Jono Bacon
Hi all, I am still pretty new to PHP, but I was chatting to a friend the other day and he put some thoughts into my head about how tables are laid out and processed. At the moment I have three tables: Topic, Message, Comment. A topic has messages and each message can have comments. I have set