]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact/Relation.php
Merge remote-tracking branch 'upstream/develop' into item-view
[friendica.git] / src / Model / Contact / Relation.php
index 24d663cbbf41b34b09b046fe33b0cdb2864740ce..3c95973238e1e9d43aae474927db3c2e35519529 100644 (file)
@@ -160,11 +160,11 @@ class Relation
        }
 
        /**
-        * Fetch contact list from the given local user
+        * Fetch contact url list from the given local user
         *
         * @param integer $uid
         * @param array $rel
-        * @return void
+        * @return array contact list
         */
        private static function getContacts(int $uid, array $rel)
        {
@@ -469,7 +469,7 @@ class Relation
                );
 
                return DI::dba()->selectToArray('contact', [], $condition,
-                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
                );
        }
 
@@ -485,8 +485,8 @@ class Relation
        public static function countAll(int $cid, array $condition = [])
        {
                $condition = DBA::mergeConditions($condition,
-                       ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`) 
-                       OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
+                       ['(`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`) 
+                       OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`))',
                                $cid, $cid]
                );
 
@@ -507,13 +507,13 @@ class Relation
        public static function listAll(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
        {
                $condition = DBA::mergeConditions($condition,
-                       ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`) 
-                       OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
+                       ['(`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`) 
+                       OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`))',
                                $cid, $cid]
                );
 
                return DI::dba()->selectToArray('contact', [], $condition,
-                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
                );
        }
 
@@ -560,7 +560,7 @@ class Relation
                );
 
                return DI::dba()->selectToArray('contact', [], $condition,
-                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
                );
        }
 
@@ -605,7 +605,7 @@ class Relation
                );
 
                return DI::dba()->selectToArray('contact', [], $condition,
-                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+                       ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
                );
        }
 
@@ -650,7 +650,7 @@ class Relation
                );
 
                return DI::dba()->selectToArray('contact', [], $condition,
-                       ['limit' => [$offset, $count],  'order' => [$shuffle ? 'name' : 'RAND()']]
+                       ['limit' => [$offset, $count],  'order' => [$shuffle ? 'RAND()' : 'name']]
                );
        }
 }