[PHP] Re: Recursive Threading

2002-01-03 Thread Philip Hallstrom

There's a couple of ways you could do this...

- search zend.com and other PHP sites for something similar :)

- pick up Joe Celko's "SQL for Smarties" which talks about building trees
and graphs in SQL (which is what this is)... this can get kind of
complicated though.

or...


- modify your table so that every row has a threadID as well as a
parentID.

- change your query so that you select all the rows that have a given
threadID.

- use something like the code here for "sorting".

http://stuff.adhesivemedia.com/php/heirarchial-sorting.php


good luck!

On Thu, 3 Jan 2002, Jonathan Chum wrote:

> I'm using recursive threading for a simple thread board script, but the
> problem is the # of queries needed to execute. That is, once given the main
> thread post, it'll have to find all the posts where the parentID matches the
> current ID, then requery again for each of the post.
>
> So I'm trying to discover a way to limit the amount of querying, possibly
> there is some type of algo I don't know about or a method using arrays. Any
> wisdom on this is greatly appreciated.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Recursive Threading with PHP and MySQL.

2001-12-05 Thread Prottoss

Recursive functions are generally a bad idea especially in php.
By using a recursive function it is possible you may "smash the stack", which 
will crash an apache child (segfaults) and on a multi-threaded server take 
down the whole webserver.
Even with a default memory limit of 8 megs an attacker could crash php by 
accessing the same thread multiple times.

This is NOT a theoretical situation, I've actually came across it while 
writing a tree drawing code for a forum. The problem exists in all the php 
that I've tested (PHP 4.0.5,4.0.6,4.1.0RC5).

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Recursive Threading with PHP and MySQL.

2001-12-05 Thread Chris Lee

recursion is something that can be fun and practical at times, other times
its a bad coder trying to do something they think is clever. use it wisly.




this example is purposely coded bad to show you how recursion can mess up
with bad error checking. this example will work. change to power(30) and
you'll get a segfault because $num will allways equal anything but 2. this
gives you a starting point on recursion.

--

  Chris Lee
  [EMAIL PROTECTED]



"Alawi" <[EMAIL PROTECTED]> wrote in message
002201c17dc2$75276cd0$753f47d4@mcsh2l7jqy8bgj">news:002201c17dc2$75276cd0$753f47d4@mcsh2l7jqy8bgj...
I want to know how can i do that Recursive loop to get categories as example
can any body help me by give my tutorial or any thing to understand this
techniqe




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]