From: Evan Prodromou Date: Mon, 1 Aug 2011 20:59:43 +0000 (-0400) Subject: reduce the number of queries required to get a notice's groups X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=200e18cd713fadcc24f5fe3b2c8db1f353f279a7;p=quix0rs-gnu-social.git reduce the number of queries required to get a notice's groups --- diff --git a/classes/Notice.php b/classes/Notice.php index 6540490b9a..d577408fef 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1438,25 +1438,14 @@ class Notice extends Memcached_DataObject $gi->notice_id = $this->id; - if ($gi->find()) { - while ($gi->fetch()) { - $ids[] = $gi->group_id; - } - } - + $ids = $gi->fetchAll('group_id'); + self::cacheSet($keypart, implode(',', $ids)); } - $groups = array(); - - foreach ($ids as $id) { - $group = User_group::staticGet('id', $id); - if ($group) { - $groups[] = $group; - } - } - - return $groups; + $groups = User_group::multiGet('id', $ids); + + return $groups->fetchAll(); } /**