Fehrant Posted December 6, 2007 Share Posted December 6, 2007 I am building a forum, and I already got the basics working (registering, signing in, showing and posting in both threads and posts, section->forums->threads->posts architecture displaying properly). However, right now I'm starting to struggle over the details. Particularly this post will be about the navigation links (in this forum, the navigation bar would be: PHP Freaks Forums > PHP and MySQL > PHP Help -> Title of thread). Each of the pages that display any information from the db, use 2 queries tops, and I'd like to leave it at that to minimize hammering the db with multiple queries from multiple users. However, notice how the navigation bar is processed before the actual listing of either threads or posts. That would merit another query in itself, but I want to avoid it, so I thought of two possible solutions. I want to know however if the trouble would be worth it. 1) Creating a class to create all the HTML, that will be able to inject variables' content into the HTML thus created. This would enable me to first do all the PHP processing, and afterwards simply pouring the content conveniently as I see fit. 2) Storing all the threads/posts in an array beforehand, and then simply looping the array. I hope I was clear enough. Any questions, just ask. Quote Link to comment https://forums.phpfreaks.com/topic/80508-resource-management/ Share on other sites More sharing options...
PHP_PhREEEk Posted December 6, 2007 Share Posted December 6, 2007 Well, you've just encountered "programmer's choice". Decide which way you want to go, and get going with it. If you are comfortable with OOP, design a class to handle forum objects. Since I'm very comfortable with arrays, I would certainly choose that route out of convenience. In the end, you're going to create arrays anyways... whether you use them directly or within a class is the only question. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80508-resource-management/#findComment-408183 Share on other sites More sharing options...
Fehrant Posted December 6, 2007 Author Share Posted December 6, 2007 PhREEEk, thanks for the reply. It's kind of embarrassing now that put it that way ("programmer's choice"). I'm partly glad though that's the case. Since I'm a newbie, the solutions to the problems I find could be due to lack of knowledge rather than legitimate ways, so I was rather skeptical. You're dead-on on pointing out I'll be using arrays anyway. I am not very comfortable with OOP, I suppose I'll end up doing arrays. Quote Link to comment https://forums.phpfreaks.com/topic/80508-resource-management/#findComment-408193 Share on other sites More sharing options...
PHP_PhREEEk Posted December 6, 2007 Share Posted December 6, 2007 If you're good with arrays, you'll be fine as long as your array structure is well thought out. If you're not good with arrays, you're going to be... very soon! hehe Which is not a bad thing at all... = ^) If your array structure is built for it, you could use a template system for sending the page to the browser, but that's a whole 'nother subject/endeavor. Well, guess you're going be kind of 'busy' with arrays for a few days! Just walk slow and drink lots of water! You'll be fine! Best of luck... we're here when you need to cry 'Uncle!' = D PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80508-resource-management/#findComment-408201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.