]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Rename selectOne to selectFirst
[friendica.git] / src / Model / Contact.php
index bb8302e31de769703204a2eebb94cba02412deb2..a78c796edcbb7ec5c2a483ce076b9bf5ffcbb65b 100644 (file)
@@ -103,7 +103,7 @@ class Contact extends BaseObject
                        return true;
                }
 
-               $user = dba::selectOne('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
+               $user = dba::selectFirst('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
                if (!DBM::is_result($user)) {
                        return false;
                }
@@ -145,7 +145,7 @@ class Contact extends BaseObject
        public static function remove($id)
        {
                // We want just to make sure that we don't delete our "self" contact
-               $r = dba::selectOne('contact', ['uid'], ['id' => $id, 'self' => false]);
+               $r = dba::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
 
                if (!DBM::is_result($r) || !intval($r['uid'])) {
                        return;
@@ -490,7 +490,7 @@ class Contact extends BaseObject
                                return $menu;
                        }
 
-                       $r = dba::selectOne('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
+                       $r = dba::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
                        if ($r) {
                                return self::photoMenu($r, $uid);
                        } else {
@@ -653,18 +653,18 @@ class Contact extends BaseObject
 
                /// @todo Verify if we can't use Contact::getDetailsByUrl instead of the following
                // We first try the nurl (http://server.tld/nick), most common case
-               $contact = dba::selectOne('contact', ['id', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
+               $contact = dba::selectFirst('contact', ['id', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
 
                // Then the addr (nick@server.tld)
                if (!DBM::is_result($contact)) {
-                       $contact = dba::selectOne('contact', ['id', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
+                       $contact = dba::selectFirst('contact', ['id', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
                }
 
                // Then the alias (which could be anything)
                if (!DBM::is_result($contact)) {
                        // The link could be provided as http although we stored it as https
                        $ssl_url = str_replace('http://', 'https://', $url);
-                       $r = dba::selectOne('contact', ['id', 'avatar', 'avatar-date'], ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid]);
+                       $r = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid]);
                        $contact = dba::fetch($r);
                        dba::close($r);
                }
@@ -697,7 +697,7 @@ class Contact extends BaseObject
                        }
 
                        // Get data from the gcontact table
-                       $gcontacts = dba::selectOne('gcontact', ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'], ['nurl' => normalise_link($url)]);
+                       $gcontacts = dba::selectFirst('gcontact', ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'], ['nurl' => normalise_link($url)]);
                        if (!DBM::is_result($gcontacts)) {
                                return 0;
                        }
@@ -735,7 +735,7 @@ class Contact extends BaseObject
                        $contact_id = $contacts[0]["id"];
 
                        // Update the newly created contact from data in the gcontact table
-                       $gcontact = dba::selectOne('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
+                       $gcontact = dba::selectFirst('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
                        if (DBM::is_result($gcontact)) {
                                // Only use the information when the probing hadn't fetched these values
                                if ($data['keywords'] != '') {
@@ -759,7 +759,7 @@ class Contact extends BaseObject
                self::updateAvatar($data["photo"], $uid, $contact_id);
 
                $fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey'];
-               $contact = dba::selectOne('contact', $fields, ['id' => $contact_id]);
+               $contact = dba::selectFirst('contact', $fields, ['id' => $contact_id]);
 
                // This condition should always be true
                if (!DBM::is_result($contact)) {
@@ -817,7 +817,7 @@ class Contact extends BaseObject
                        return false;
                }
 
-               $blocked = dba::selectOne('contact', ['blocked'], ['id' => $cid]);
+               $blocked = dba::selectFirst('contact', ['blocked'], ['id' => $cid]);
                if (!DBM::is_result($blocked)) {
                        return false;
                }
@@ -837,7 +837,7 @@ class Contact extends BaseObject
                        return false;
                }
 
-               $hidden = dba::selectOne('contact', ['hidden'], ['id' => $cid]);
+               $hidden = dba::selectFirst('contact', ['hidden'], ['id' => $cid]);
                if (!DBM::is_result($hidden)) {
                        return false;
                }
@@ -980,7 +980,7 @@ class Contact extends BaseObject
        public static function updateAvatar($avatar, $uid, $cid, $force = false)
        {
                // Limit = 1 returns the row so no need for dba:inArray()
-               $r = dba::selectOne('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
+               $r = dba::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
                if (!DBM::is_result($r)) {
                        return false;
                } else {
@@ -999,7 +999,7 @@ class Contact extends BaseObject
 
                                // Update the public contact (contact id = 0)
                                if ($uid != 0) {
-                                       $pcontact = dba::selectOne('contact', ['id'], ['nurl' => $r[0]['nurl']]);
+                                       $pcontact = dba::selectFirst('contact', ['id'], ['nurl' => $r[0]['nurl']]);
                                        if (DBM::is_result($pcontact)) {
                                                self::updateAvatar($avatar, 0, $pcontact['id'], $force);
                                        }
@@ -1023,7 +1023,7 @@ class Contact extends BaseObject
                This will reliably kill your communication with Friendica contacts.
                */
 
-               $r = dba::selectOne('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id]);
+               $r = dba::selectFirst('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id]);
                if (!DBM::is_result($r)) {
                        return false;
                }
@@ -1246,7 +1246,7 @@ class Contact extends BaseObject
                        );
                }
 
-               $r = dba::selectOne('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
+               $r = dba::selectFirst('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
 
                if (!DBM::is_result($r)) {
                        $result['message'] .= t('Unable to retrieve contact information.') . EOL;