From 48b49dbc4b4f03e3ba386120f53ad5f080ab184b Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 10 Dec 2017 20:12:23 +0000 Subject: [PATCH] Bugfix to PR 4046: Repaired query --- src/Model/Group.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Model/Group.php b/src/Model/Group.php index 4431bdc88a..857b972d62 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -62,21 +62,13 @@ class Group extends BaseObject */ private static function getByContactIdForUserId($uid, $cid) { - $stmt = dba::p('SELECT `id` - FROM `group` - INNER JOIN `group_member` - ON `group_member`.`gid` = `group`.`id` - WHERE `group`.`uid` = ? - AND `group_member`.`contact-id` = ?', - $uid, - $cid - ); + $condition = ['uid' => $uid, 'contact-id' => $cid]; + $stmt = dba::select('group_member', ['gid'], $condition); $return = []; - if (DBM::is_result($stmt)) { - while($group = dba::fetch($stmt)) { - $return[] = $group['id']; - } + + while ($group = dba::fetch($stmt)) { + $return[] = $group['gid']; } return $return; -- 2.39.5