Re: [PHP] Re: creating a threaded message system--sorting messages

2006-06-30 Thread Adam Zey
Dan McCullough wrote: I've come into this discussion pretty late so please bear with me if I go over something that has been ruled out. You are trying to print out in a threaded method the first post in a thread followed by each post after that, that is a child/reply to that post. Is that

Re: Re: [PHP] Re: creating a threaded message system--sorting messages

2006-06-30 Thread Ben Liu
Thanks to everybody who posted on this thread. I wanted to post back the solution I came up with after removing the DB query from the recursion. In case anyone else is trying to accomplish the same thing, this is how I solved it (criticisms welcome, and note that I have not tested it extensively

Re: [PHP] Re: creating a threaded message system--sorting messages

2006-06-30 Thread Adam Zey
Ben Liu wrote: Thanks to everybody who posted on this thread. I wanted to post back the solution I came up with after removing the DB query from the recursion. In case anyone else is trying to accomplish the same thing, this is how I solved it (criticisms welcome, and note that I have not tested

Re: Re: [PHP] Re: creating a threaded message system--sorting messages

2006-06-30 Thread Ben Liu
On 6/30/06, Adam Zey [EMAIL PROTECTED] wrote: I think that will work, but there is one huge improvement you can make. You are making millions of copies of your work array! Not only do you pass the entire array by value recursively, but foreach makes copies of the arrays it loops through! So who

Re: [PHP] Re: creating a threaded message system--sorting messages

2006-06-30 Thread Adam Zey
Ben Liu wrote: The second thing to do is to make the foreach work on references instead of copies. I actually think that since what we have in our function is now a reference, the foreach WILL NOT copy it. Anyone have any ideas on this? Is the foreach loop in fact copying $workArr? And how

Re: [PHP] Re: creating a threaded message system--sorting messages

2006-06-30 Thread Ben Liu
On Jun 30, 2006, at 5:04 PM, Adam Zey wrote: I mean, do this: foreach ( array_keys($workArr) as $key ) { echo $workArr[$key]['foo']; } instead of this: foreach ( $workArr as $key = $value ) { echo $value['foo']; } Okay, I think I get the idea. So using my code example...

RE: [PHP] Re: creating a threaded message system--sorting messages

2006-06-29 Thread KermodeBear
Hello, As Adam pointed out, this can be deadly to your database, especially as the number of posts grows. If you want to go that route, I would recommend selecting all the posts in that particular thread and sorting the data out in PHP somehow. No need to slam your database with (potentially)

Re: [PHP] Re: creating a threaded message system--sorting messages

2006-06-29 Thread Dan McCullough
I've come into this discussion pretty late so please bear with me if I go over something that has been ruled out. You are trying to print out in a threaded method the first post in a thread followed by each post after that, that is a child/reply to that post. Is that correct? So something like