toonski has asked for the wisdom of the Perl Monks concerning the following question:

Heya monks... I'm trying to use some articles I found to program the tree for a SQL forum I'm making. The problem isnt implementing it, no... It works perfectly. The problem is, is it that it puts new posts at the bottom of a nested set instead of the top, so instead of this:

ROOT POST

It looks like this:

ROOT POST

Now, I can get around this by saying that to post, I make the new post's left and right values are one & two more than the left value of the parent instead of one and two less than the right, but this presents a problem. Because I'm putting the posts at the top and modifying every post under it, the SQL query is effectively modifying every single post in the database on every new post. Is there any way to get the threads to show in reverse order, or somehow put the posts in verse order starting at the bottom of the forum?
  • Comment on Modified Pre-orded something or another.

Replies are listed 'Best First'.
Re: Modified Pre-orded something or another.
by Zaxo (Archbishop) on Jan 16, 2004 at 17:53 UTC

    Not really enough code or info to help, but does your db support "ORDER BY" in the WHERE clause? If not, see sort.

    After Compline,
    Zaxo

      Well, if you read the article, using "ORDER BY lft" gives you the posts in indented order. But change that order doesnt help as much because you still have to modify every previous post if you want the threads to be in reverse order and its "descendent" posts in correct order.

      But this is more of a concept question rather than a code thing. How could this be done?

Re: Modified Pre-orded something or another.
by waswas-fng (Curate) on Jan 16, 2004 at 18:50 UTC
    Just have a root level item that has the full parent range and use the gap method listed at the end of his article to order the posts how you would like them, putting new articles at the right end of the gap.


    -Waswas