Re: [SMARTY] Array problem

From: Date: Sun, 24 Nov 2002 12:25:49 +0000
Subject: Re: [SMARTY] Array problem
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6534@lists.php.net to get a copy of this message
At 12:22 2002-11-24 +0100, you wrote:
I see that u have solved the problem but i'd like to ask u for some advice because i'm just working with the same thing as u. I have also some categories with cat_id and parent_id in db that i'm pulling out every time i show category. So, my question would be, is it better to load all that category tree in some session array and walk throgh it while displaying subcategories, then making db query on every page that has some categories to show? I'm working with mysql and currently a need to make 4 querys on a page dealing with categories to make all them display corectly. Thx.
My current solution allows a 2 level category system, which means there are top level categories, and each of those can have one sub-level. But I decided to design the database in a way, which would allow me to use more levels in case I'll be needing those. But to achieve that, It'd require different code. As for my designing guidelines, primarily I'm working to minimize the number of database queries needed to display a page. As you might have seen my code snippet, there was just one query and the rest was achieved by a loop. In the near future I'll be working on improving that even further, because those categories won't change too often, I'll just cache them. I'm not sure if I got your question right: your first solution was to get the categories from the database and store them in a session so that the database wouldn't need to be queried every time someone goes to another page on a website? As for my policy of minimizin database queries number, this looks like the better solution. But perhaps an even better way of doing it would be caching the database query result? This should even more improve performance, because a query to the database would be made only when the cache expires (which happens once in a while, depending on the cache lifetime you set) instead of every time a new session is created. Hope that helps. Have fun :) -- Michael Paluchowski { michal@nethut.pl } . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CEO, Editor www.NetHut.pl .:. webmaster vortal GSM Phone +48 503 496 837

« previous php.smarty.general (#6534) next »