From 0ecd9aed75e59dec805039211380244efb43351f Mon Sep 17 00:00:00 2001 From: Anonymous Contributor Date: Wed, 23 Aug 2023 18:16:36 +0200 Subject: [PATCH] Optimize user group query --- pages/groups.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/pages/groups.php b/pages/groups.php index 92789f6..1be9789 100644 --- a/pages/groups.php +++ b/pages/groups.php @@ -25,19 +25,13 @@ $table = '%%ENTRY%%
NameGrĂ¼nderAktionen
'; - $statementMembership = $RUNTIME['PDO']->prepare("SELECT GroupID FROM os_groups_membership WHERE PrincipalID = ? ORDER BY GroupID ASC"); - $statementMembership->execute(array($_SESSION['UUID'])); + $statementGroups = $RUNTIME['PDO']->prepare("SELECT Name,FounderID,os_groups_membership.GroupID FROM os_groups_groups JOIN os_groups_membership ON os_groups_groups.GroupID = os_groups_membership.GroupID WHERE PrincipalID = ?"); + $statementGroups->execute(array($_SESSION['UUID'])); - while($rowMembership = $statementMembership->fetch()) + while($rowGroups = $statementGroups->fetch()) { - $statementGroups = $RUNTIME['PDO']->prepare("SELECT Name,FounderID,GroupID FROM os_groups_groups WHERE GroupID = ? LIMIT 1"); - $statementGroups->execute(array($rowMembership['GroupID'])); - - while($rowGroups = $statementGroups->fetch()) - { - $entry = ''.htmlspecialchars($rowGroups['Name']).''.htmlspecialchars($opensim->getUserName($rowGroups['FounderID'])).'
%%CSRF%%
'; - $table = str_replace("%%ENTRY%%", $entry."%%ENTRY%%", $table); - } + $entry = ''.htmlspecialchars($rowGroups['Name']).''.htmlspecialchars($opensim->getUserName($rowGroups['FounderID'])).'
%%CSRF%%
'; + $table = str_replace("%%ENTRY%%", $entry."%%ENTRY%%", $table); } $table = str_replace("%%ENTRY%%", "", $table);