Class desconstruct/available resources
I'm sure everybody will say yes to this, but... if I have a class that opens a connection to my database when its called, should I worry too much about setting up a __destruct that closes it and unset() at the end of every page? The page has already loaded, accessed all its functions and displayed everything... there's no open connections after the person leaves the page anyways, right?
Another question, not really relating, but kind of - I'm building a small customer support system for my site, and at the top of each administrative page I list the total posts, total new posts, and total posts awaiting reply (read but not replied).
As of now I have three seperate functions, dbTotalPosts(), dbNewPosts(), dbWaitingPosts(), each doing their own database query (SELECT ticket FROM contact, SELECT ticket FROM contact WHERE new='1', etc). All of them use the same db connection, they're not opening and closing it, so is this okay, or would it be better to do one query (SELECT new, replied FROM contact) and then loop through the results and provide a $count of each row? ($total++, $new++, $replied++, or I guess just $new++, $replied++ $total = $new + $replied)
Thanks in advance,
First question is still my most important, but here's the code I just wrote quick to reduce the number of database calls from 3 to 1.
|All times are GMT. The time now is 08:28 PM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0