Re: Recursion and threaded message boards...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, August 10, 2007 11:23 am, Tony Di Croce wrote:
> I have to write some PHP backend code for a threaded message board.
> The db
> has a message table, and each message has a parent id.
>
> Does anyone have any advice for someone whos never done this in PHP?
>
> I'm currently thinking that I write function that takes a db row as an
> argument, and initially, it is passed the root node of the whole tree.
> It is
> also probably passed a string variable.
>
> The first thing it will do is append the code for itself to the
> string.
>
> Then it will query the DB for all its children (with an order by post
> timestamp), and for every child, it will call itself on that child
> row.
>
> Am I on the right track? (I've done simmilar things in C++, just not
> in
> PHP)...

What you describe will "work" if you don't care about performance...

If there's any heavy activity at all, you'll be swamping your Database
in recursive "child" lookup queries.

Google for "SQL Tree Traversal" and you should find quite a few
solutions.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux