Rename selectOne to selectFirst

This commit is contained in:
Hypolite Petovan 2018-01-10 08:36:02 -05:00
parent c7a7658316
commit ae66bcaff3
51 changed files with 821 additions and 821 deletions

View file

@ -222,7 +222,7 @@ function api_login(App $a)
} else {
$user_id = User::authenticate(trim($user), trim($password));
if ($user_id) {
$record = dba::selectOne('user', [], ['uid' => $user_id]);
$record = dba::selectFirst('user', [], ['uid' => $user_id]);
}
}
@ -473,7 +473,7 @@ function api_rss_extra(App $a, $arr, $user_info)
*/
function api_unique_id_to_nurl($id)
{
$r = dba::selectOne('contact', array('nurl'), array('uid' => 0, 'id' => $id));
$r = dba::selectFirst('contact', array('nurl'), array('uid' => 0, 'id' => $id));
if (DBM::is_result($r)) {
return $r["nurl"];
@ -792,7 +792,7 @@ function api_get_user(App $a, $contact_id = null)
// If this is a local user and it uses Frio, we can get its color preferences.
if ($ret['self']) {
$theme_info = dba::selectOne('user', ['theme'], ['uid' => $ret['uid']]);
$theme_info = dba::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
if ($theme_info['theme'] === 'frio') {
$schema = PConfig::get($ret['uid'], 'frio', 'schema');
if ($schema && ($schema != '---')) {
@ -4870,7 +4870,7 @@ function api_friendica_remoteauth()
// traditional DFRN
$r = dba::selectOne('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
$r = dba::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
if (!DBM::is_result($r) || ($r['network'] !== NETWORK_DFRN)) {
throw new BadRequestException("Unknown contact");

View file

@ -224,12 +224,12 @@ function common_friends_visitor_widget($profile_uid)
if (!$cid) {
if (get_my_url()) {
$r = dba::selectOne('contact', ['id'],
$r = dba::selectFirst('contact', ['id'],
['nurl' => normalise_link(get_my_url()), 'uid' => $profile_uid]);
if (DBM::is_result($r)) {
$cid = $r['id'];
} else {
$r = dba::selectOne('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
$r = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
if (DBM::is_result($r)) {
$zcid = $r['id'];
}

View file

@ -968,7 +968,7 @@ function best_link_url($item, &$sparkle, $url = '') {
$clean_url = normalise_link($item['author-link']);
if (local_user()) {
$r = dba::selectOne('contact', ['id'],
$r = dba::selectFirst('contact', ['id'],
['network' => NETWORK_DFRN, 'uid' => local_user(), 'nurl' => normalise_link($clean_url), 'pending' => false]);
if (DBM::is_result($r)) {
$best_url = 'redir/' . $r['id'];
@ -1019,7 +1019,7 @@ function item_photo_menu($item) {
$cid = 0;
$network = '';
$rel = 0;
$r = dba::selectOne('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])));
$r = dba::selectFirst('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])));
if (DBM::is_result($r)) {
$cid = $r['id'];
$network = $r['network'];

View file

@ -1047,7 +1047,7 @@ class dba {
if (is_bool($old_fields)) {
$do_insert = $old_fields;
$old_fields = self::selectOne($table, [], $condition);
$old_fields = self::selectFirst($table, [], $condition);
if (is_bool($old_fields)) {
if ($do_insert) {
@ -1095,7 +1095,7 @@ class dba {
* @return bool|array
* @see dba::select
*/
public static function selectOne($table, array $fields = [], array $condition = [], $params = [])
public static function selectFirst($table, array $fields = [], array $condition = [], $params = [])
{
$params['limit'] = 1;
$result = self::select($table, $fields, $condition, $params);

View file

@ -106,7 +106,7 @@ function notification($params)
}
if ($params['type'] == NOTIFY_COMMENT) {
$p = dba::selectOne('thread', ['ignored'], ['iid' => $parent_id]);
$p = dba::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
if (DBM::is_result($p) && $p["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
@ -131,7 +131,7 @@ function notification($params)
$p = null;
if ($params['otype'] === 'item' && $parent_id) {
$p = dba::selectOne('item', [], ['id' => $parent_id]);
$p = dba::selectFirst('item', [], ['id' => $parent_id]);
}
$item_post_type = item_post_type($p);
@ -672,12 +672,12 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles = $notification_data["profiles"];
$fields = ['notify-flags', 'language', 'username', 'email', 'nickname'];
$user = dba::selectOne('user', $fields, ['uid' => $uid]);
$user = dba::selectFirst('user', $fields, ['uid' => $uid]);
if (!DBM::is_result($user)) {
return false;
}
$owner = dba::selectOne('contact', ['url'], ['self' => true, 'uid' => $uid]);
$owner = dba::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
if (!DBM::is_result($owner)) {
return false;
}

View file

@ -162,7 +162,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0)
if (remote_user() && count($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $visitor) {
if ($visitor['uid'] == $uid) {
$r = dba::selectOne('contact', ['profile-id'], ['id' => $visitor['cid']]);
$r = dba::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
if (DBM::is_result($r)) {
$profile = $r['profile-id'];
}

View file

@ -562,7 +562,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
// check for create date and expire time
$expire_interval = Config::get('system', 'dbclean-expire-days', 0);
$user = dba::selectOne('user', ['expire'], ['uid' => $uid]);
$user = dba::selectFirst('user', ['expire'], ['uid' => $uid]);
if (DBM::is_result($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
$expire_interval = $user['expire'];
}
@ -1149,14 +1149,14 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
*/
function item_set_last_item($arr) {
// Unarchive the author
$contact = dba::selectOne('contact', [], ['id' => $arr["author-link"]]);
$contact = dba::selectFirst('contact', [], ['id' => $arr["author-link"]]);
if ($contact['term-date'] > NULL_DATE) {
Contact::unmarkForArchival($contact);
}
// Unarchive the contact if it is a toplevel posting
if ($arr["parent-uri"] === $arr["uri"]) {
$contact = dba::selectOne('contact', [], ['id' => $arr["contact-id"]]);
$contact = dba::selectFirst('contact', [], ['id' => $arr["contact-id"]]);
if ($contact['term-date'] > NULL_DATE) {
Contact::unmarkForArchival($contact);
}

View file

@ -69,7 +69,7 @@ function send_message($recipient = 0, $body = '', $subject = '', $replyto = '')
'subject' => $subject, 'recips' => $handles);
dba::insert('conv', $fields);
$r = dba::selectOne('conv', ['id'], ['guid' => $conv_guid, 'uid' => local_user()]);
$r = dba::selectFirst('conv', ['id'], ['guid' => $conv_guid, 'uid' => local_user()]);
if (DBM::is_result($r)) {
$convid = $r['id'];
}
@ -188,7 +188,7 @@ function send_wallmessage($recipient = '', $body = '', $subject = '', $replyto =
'subject' => $subject, 'recips' => $handles);
dba::insert('conv', $fields);
$r = dba::selectOne('conv', ['id'], ['guid' => $conv_guid, 'uid' => $recipient['uid']]);
$r = dba::selectFirst('conv', ['id'], ['guid' => $conv_guid, 'uid' => $recipient['uid']]);
if (!DBM::is_result($r)) {
logger('send message: conversation not found.');
return -4;

View file

@ -94,7 +94,7 @@ function nav_info(App $a)
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
// user info
$r = dba::selectOne('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$r = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$userinfo = array(
'icon' => (DBM::is_result($r) ? $a->remove_baseurl($r['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'],

View file

@ -33,7 +33,7 @@ function ref_session_read($id)
return '';
}
$r = dba::selectOne('session', ['data'], ['sid' => $id]);
$r = dba::selectFirst('session', ['data'], ['sid' => $id]);
if (DBM::is_result($r)) {
$session_exists = true;
return $r['data'];

View file

@ -226,7 +226,7 @@ function wtagblock($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
$o = '';
$r = tagadelic($uid, $count, $owner_id, $flags, $type);
if (count($r)) {
$contact = dba::selectOne('contact', ['url'], ['id' => $uid]);
$contact = dba::selectFirst('contact', ['url'], ['id' => $uid]);
$url = System::removedBaseUrl($contact['url']);
foreach ($r as $rr) {