From c6d02eab8845deb0fd59c9bb43abcf4e0975ab6e Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Tue, 15 Feb 2005 19:19:36 +0000 Subject: [PATCH] Improve efficiency of hasDataAssociated() by counting rows of a single column instead of selecting * --- cron/cleanup.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cron/cleanup.php b/cron/cleanup.php index 15053bb..79d592d 100644 --- a/cron/cleanup.php +++ b/cron/cleanup.php @@ -57,17 +57,20 @@ function inactiveSince($iMonths) 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); - 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); - 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); - if(mysql_num_rows($hResult)) return true; + $ob = mysql_fetch_object($hResult); + if($ob->c != 0) return true; return false; }