]> git.mxchange.org Git - friendica.git/commitdiff
Bugfix to PR 4046: Repaired query
authorMichael <heluecht@pirati.ca>
Sun, 10 Dec 2017 20:12:23 +0000 (20:12 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 10 Dec 2017 20:12:23 +0000 (20:12 +0000)
src/Model/Group.php

index 4431bdc88aad2a1f535aa23aa7580fb4ca1ecb1d..857b972d62b4c81c4f1d02ff64e54b689f0355a8 100644 (file)
@@ -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;