1
0
Fork 0

Optimize user group query

master
Anonymous Contributor 2023-08-23 18:16:36 +02:00
parent 391d716200
commit 0ecd9aed75
1 changed files with 5 additions and 11 deletions

View File

@ -25,19 +25,13 @@
$table = '<table class="table"><thead><tr><th scope="col">Name</th><th scope="col">Gründer</th><th scope="col">Aktionen</th></thead><tbody>%%ENTRY%%</tbody></table>';
$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 = '<tr><td>'.htmlspecialchars($rowGroups['Name']).'</td><td>'.htmlspecialchars($opensim->getUserName($rowGroups['FounderID'])).'</td><td><form action="index.php?page=groups" method="post">%%CSRF%%<input type="hidden" name="group" value="'.htmlspecialchars($rowGroups['GroupID']).'"><button type="submit" name="leave" class="btn btn-danger btn-sm">VERLASSEN</button></form></td></tr>';
$table = str_replace("%%ENTRY%%", $entry."%%ENTRY%%", $table);
}
$entry = '<tr><td>'.htmlspecialchars($rowGroups['Name']).'</td><td>'.htmlspecialchars($opensim->getUserName($rowGroups['FounderID'])).'</td><td><form action="index.php?page=groups" method="post">%%CSRF%%<input type="hidden" name="group" value="'.htmlspecialchars($rowGroups['GroupID']).'"><button type="submit" name="leave" class="btn btn-danger btn-sm">VERLASSEN</button></form></td></tr>';
$table = str_replace("%%ENTRY%%", $entry."%%ENTRY%%", $table);
}
$table = str_replace("%%ENTRY%%", "", $table);