Rename selectOne to selectFirst

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

View file

@ -1551,7 +1551,7 @@ function admin_page_users(App $a)
{
if ($a->argc > 2) {
$uid = $a->argv[3];
$user = dba::selectOne('user', ['username', 'blocked'], ['uid' => $uid]);
$user = dba::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
if (DBM::is_result($user)) {
notice('User not found' . EOL);
goaway('admin/users');

View file

@ -32,7 +32,7 @@ function cal_init(App $a)
if ($a->argc > 1) {
$nick = $a->argv[1];
$user = dba::selectOne('user', [], ['nickname' => $nick, 'blocked' => false]);
$user = dba::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBM::is_result($user)) {
return;
}

View file

@ -63,11 +63,11 @@ function common_content(App $a)
}
if (!$cid && get_my_url()) {
$contact = dba::selectOne('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
$contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
} else {
$gcontact = dba::selectOne('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
$gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
if (DBM::is_result($gcontact)) {
$zcid = $gcontact['id'];
}

View file

@ -33,7 +33,7 @@ function contacts_init(App $a)
$contact = [];
if ((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
}
if (DBM::is_result($contact)) {
@ -222,7 +222,7 @@ function contacts_post(App $a)
notice(t('Failed to update contact record.') . EOL);
}
$contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
if (DBM::is_result($contact)) {
$a->data['contact'] = $contact;
}
@ -233,7 +233,7 @@ function contacts_post(App $a)
function _contact_update($contact_id)
{
$contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
@ -254,7 +254,7 @@ function _contact_update($contact_id)
function _contact_update_profile($contact_id)
{
$contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
$contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
@ -389,7 +389,7 @@ function contacts_content(App $a)
$cmd = $a->argv[2];
$orig_record = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
$orig_record = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
if (!DBM::is_result($orig_record)) {
notice(t('Could not access contact record.') . EOL);
goaway('contacts');
@ -904,7 +904,7 @@ function contact_posts($a, $contact_id)
{
$o = contacts_tab($a, $contact_id, 1);
$contact = dba::selectOne('contact', ['url'], ['id' => $contact_id]);
$contact = dba::selectFirst('contact', ['url'], ['id' => $contact_id]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));

View file

@ -202,7 +202,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
if ($update) {
$item_id = $_REQUEST['item_id'];
$item = dba::selectOne('item', ['uid', 'parent'], ['id' => $item_id]);
$item = dba::selectFirst('item', ['uid', 'parent'], ['id' => $item_id]);
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid']));
$item_parent = $item['parent'];
} else {
@ -345,7 +345,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
$s = dba::inArray($r);
if (local_user() && (local_user() == $a->profile['uid'])) {
$unseen = dba::selectOne('item', ['id'], ['parent' => $s[0]['parent'], 'unseen' => true]);
$unseen = dba::selectFirst('item', ['id'], ['parent' => $s[0]['parent'], 'unseen' => true]);
if (DBM::is_result($unseen)) {
dba::update('item', array('unseen' => false), array('parent' => $s[0]['parent'], 'unseen' => true));
}

View file

@ -44,7 +44,7 @@ function hovercard_content()
$cid = 0;
if (local_user() && strpos($profileurl, 'redir/') === 0) {
$cid = intval(substr($profileurl, 6));
$r = dba::selectOne('contact', ['nurl'], ['id' => $cid]);
$r = dba::selectFirst('contact', ['nurl'], ['id' => $cid]);
$profileurl = defaults($r, 'nurl', '');
}

View file

@ -581,7 +581,7 @@ function networkThreadedView(App $a, $update = 0) {
if ($cid) {
// If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
$condition = ["`id` = ? AND (`forum` OR `prv`)", $cid];
$contact = dba::selectOne('contact', ['addr', 'nick'], $condition);
$contact = dba::selectFirst('contact', ['addr', 'nick'], $condition);
if (DBM::is_result($contact)) {
if ($contact["addr"] != '') {
$content = "!".$contact["addr"];
@ -632,7 +632,7 @@ function networkThreadedView(App $a, $update = 0) {
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
if ($group) {
$r = dba::selectOne('group', ['name'], ['id' => $group, 'uid' => $_SESSION['uid']]);
$r = dba::selectFirst('group', ['name'], ['id' => $group, 'uid' => $_SESSION['uid']]);
if (!DBM::is_result($r)) {
if ($update)
killme();
@ -647,7 +647,7 @@ function networkThreadedView(App $a, $update = 0) {
$contact_str_self = "";
$contact_str = implode(',',$contacts);
$self = dba::selectOne('contact', ['id'], ['uid' => $_SESSION['uid'], 'self' => true]);
$self = dba::selectFirst('contact', ['id'], ['uid' => $_SESSION['uid'], 'self' => true]);
if (DBM::is_result($self)) {
$contact_str_self = $self["id"];
}
@ -668,7 +668,7 @@ function networkThreadedView(App $a, $update = 0) {
$fields = ['id', 'name', 'network', 'writable', 'nurl',
'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location'];
$condition = ["`id` = ? AND (NOT `blocked` OR `pending`)", $cid];
$r = dba::selectOne('contact', $fields, $condition);
$r = dba::selectFirst('contact', $fields, $condition);
if (DBM::is_result($r)) {
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);

View file

@ -68,13 +68,13 @@ function noscrape_init(App $a) {
// We display the last activity (post or login), reduced to year and week number
$last_active = 0;
$condition = ['uid' => $a->profile['uid'], 'self' => true];
$contact = dba::selectOne('contact', ['last-item'], $condition);
$contact = dba::selectFirst('contact', ['last-item'], $condition);
if (DBM::is_result($contact)) {
$last_active = strtotime($contact['last-item']);
}
$condition = ['uid' => $a->profile['uid']];
$user = dba::selectOne('user', ['login_date'], $condition);
$user = dba::selectFirst('user', ['login_date'], $condition);
if (DBM::is_result($user)) {
if ($last_active < strtotime($user['login_date'])) {
$last_active = strtotime($user['login_date']);

View file

@ -148,7 +148,7 @@ function proxy_init(App $a) {
$r = array();
if (!$direct_cache && ($cachefile == '')) {
$r = dba::selectOne('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
$r = dba::selectFirst('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
if (DBM::is_result($r)) {
$img_str = $r['data'];
$mime = $r['desc'];

View file

@ -32,7 +32,7 @@ function receive_post(App $a)
}
$guid = $a->argv[2];
$importer = dba::selectOne('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
$importer = dba::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($importer)) {
http_status_exit(500);
}

View file

@ -997,7 +997,7 @@ function settings_content(App $a)
require_once('include/acl_selectors.php');
$profile = dba::selectOne('profile', [], ['is-default' => true, 'uid' => local_user()]);
$profile = dba::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
if (!DBM::is_result($profile)) {
notice(t('Unable to find your profile. Please contact your admin.') . EOL);
return;

View file

@ -26,7 +26,7 @@ function unfollow_post(App $a) {
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
$uid, CONTACT_IS_FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
$contact = dba::selectOne('contact', [], $condition);
$contact = dba::selectFirst('contact', [], $condition);
if (!DBM::is_result($contact)) {
notice(t("Contact wasn't found or can't be unfollowed."));
@ -65,7 +65,7 @@ function unfollow_content(App $a) {
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
local_user(), CONTACT_IS_FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
$contact = dba::selectOne('contact', ['url', 'network', 'addr', 'name'], $condition);
$contact = dba::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
if (!DBM::is_result($contact)) {
notice(t("You aren't a friend of this contact.").EOL);

View file

@ -36,7 +36,7 @@ function xrd_init(App $a)
$name = substr($local, 0, strpos($local, '@'));
}
$r = dba::selectOne('user', [], ['nickname' => $name]);
$r = dba::selectFirst('user', [], ['nickname' => $name]);
if (!DBM::is_result($r)) {
killme();
}