04-02-2008, 04:31 AM
|
#3 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
The Code
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.
PHP Code:
// dbPostCount - counts total posts, new posts, and posts awaiting response
function dbPostCount() {
$query = "SELECT new, replied FROM " . TBL_CONTACT;
$result = mysql_query($query, $this->connection);
while ($row = mysql_fetch_row($result))
{
$c['total']++;
if ($row[0] == "1") { $c['new']++; } elseif ($row[0] == "0" && $row[1] == "0") { $c['waiting']++; }
}
return $c;
}
Can I improve on this? I'm willing to bet just from the 3 to 1 database calls that it IS quicker than my original method.
-m
|
|
|
|