Re: Thinking out loud - a continuation...
| From: | Jay Blanchard | Date: | Thu, 22 Mar 2012 15:58:48 +0000 |
| Subject: | Re: Thinking out loud - a continuation... | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-317182@lists.php.net to get a copy of this message | ||
[snip]
Fix this code... I've come across codebases that did this specific type of nested querying and it resulted in 10000 queries to the database on every page. Instead, create a layered approach:
1. Select your root elements.
2. Loop over in PHP and create an array of child IDs.
3. Select the children from the database.
4. Go to step 2.
This way you will only every perform "depth" number of queries.
[/snip]
I see what you're saying but I don't know that this reduces the number of queries - it just handles them in a different order. How do I get to the output that I need?