Re: PHP / MySQL Threaded Discussion: One Query

From: Jochen Daum (jochen.daum_at_cabletalk.co.nz)
Date: 06/28/04


Date: Tue, 29 Jun 2004 08:44:12 +1200

Hi,

On 27 Jun 2004 23:43:23 -0700, ensnare@gmail.com (ensnare) wrote:

>I'm attempting to create a threaded comment system involving PHP /
>MySQL. Currently, I have a table called comments which looks like:
>
>Table Comments: (comment_id, comment_root_id, comment_parent_id, text,
>datetime_created).
>
>Most of the tutorials that I've found online discuss how to thread the
>results from the database with recursive query calls. This is all to
>the good; however, with lengthy discussion, this solution becomes slow
>and unacceptable.

Its a bit long to explain out of the box, but look up "nested set
model", which is well described in books of Joe Celko. It needs only
one self referencing query for a whole tree (discussion)

HTH, Jochen

-- 
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/


Relevant Pages

  • Re: help with mySQL and ORDER BY
    ... Jochen Daum - Cabletalk Group Ltd. ... PHP DB Edit Toolkit -- PHP scripts for building ... database editing interfaces. ...
    (comp.lang.php)
  • Re: Help with US Holidays
    ... >Grandparents Day seems to be giving me some trouble. ... Jochen Daum - Cabletalk Group Ltd. ... PHP DB Edit Toolkit -- PHP scripts for building ... database editing interfaces. ...
    (comp.lang.php)
  • Re: Chart
    ... this is not exactly what I am searching for. ... Jochen Daum - CANS Ltd. ... PHP DB Edit Toolkit -- PHP scripts for building ... database editing interfaces. ...
    (comp.lang.php)
  • Regex for nested structure
    ... I would like to capture the combinations of ... Jochen Daum - Cabletalk Group Ltd. ... PHP DB Edit Toolkit -- PHP scripts for building ... database editing interfaces. ...
    (comp.lang.php)
  • Re: Store db resultset in a session?
    ... >rows) and even with all the indexing it slows down a bit if too many ... Can I store a wholre resultset in a session variable? ... Jochen Daum - Cabletalk Group Ltd. ... PHP DB Edit Toolkit -- PHP scripts for building ...
    (comp.lang.php)