Improve efficiency of hasDataAssociated() by counting rows of a single column
instead of selecting *
This commit is contained in:
@@ -57,17 +57,20 @@ function inactiveSince($iMonths)
|
|||||||
|
|
||||||
function hasDataAssociated($iUserId)
|
function hasDataAssociated($iUserId)
|
||||||
{
|
{
|
||||||
$sQuery = "SELECT * FROM appComments WHERE userId = $iUserId";
|
$sQuery = "SELECT count(userId) as c FROM appComments WHERE userId = $iUserId";
|
||||||
$hResult = query_appdb($sQuery);
|
$hResult = query_appdb($sQuery);
|
||||||
if(mysql_num_rows($hResult)) return true;
|
$ob = mysql_fetch_object($hResult);
|
||||||
|
if($ob->c != 0) return true;
|
||||||
|
|
||||||
$sQuery = "SELECT * FROM appMaintainerQueue WHERE userId = $iUserId";
|
$sQuery = "SELECT count(userId) as c FROM appMaintainerQueue WHERE userId = $iUserId";
|
||||||
$hResult = query_appdb($sQuery);
|
$hResult = query_appdb($sQuery);
|
||||||
if(mysql_num_rows($hResult)) return true;
|
$ob = mysql_fetch_object($hResult);
|
||||||
|
if($ob->c != 0) return true;
|
||||||
|
|
||||||
$sQuery = "SELECT * FROM appVotes WHERE userId = $iUserId";
|
$sQuery = "SELECT count(userId) as c FROM appVotes WHERE userId = $iUserId";
|
||||||
$hResult = query_appdb($sQuery);
|
$hResult = query_appdb($sQuery);
|
||||||
if(mysql_num_rows($hResult)) return true;
|
$ob = mysql_fetch_object($hResult);
|
||||||
|
if($ob->c != 0) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user