} else {
$user_id = User::authenticate(trim($user), trim($password));
if ($user_id) {
- $record = dba::select('user', [], ['uid' => $user_id], ['limit' => 1]);
+ $record = dba::selectOne('user', [], ['uid' => $user_id]);
}
}
*/
function api_unique_id_to_nurl($id)
{
- $r = dba::select('contact', array('nurl'), array('uid' => 0, 'id' => $id), array('limit' => 1));
+ $r = dba::selectOne('contact', array('nurl'), array('uid' => 0, 'id' => $id));
if (DBM::is_result($r)) {
return $r["nurl"];
// If this is a local user and it uses Frio, we can get its color preferences.
if ($ret['self']) {
- $theme_info = dba::select('user', ['theme'], ['uid' => $ret['uid']], ['limit' => 1]);
+ $theme_info = dba::selectOne('user', ['theme'], ['uid' => $ret['uid']]);
if ($theme_info['theme'] === 'frio') {
$schema = PConfig::get($ret['uid'], 'frio', 'schema');
if ($schema && ($schema != '---')) {
// traditional DFRN
- $r = dba::select('contact', [], ['uid' => api_user(), 'nurl' => $c_url], ['limit' => 1]);
+ $r = dba::selectOne('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
if (!DBM::is_result($r) || ($r['network'] !== NETWORK_DFRN)) {
throw new BadRequestException("Unknown contact");
if (!$cid) {
if (get_my_url()) {
- $r = dba::select('contact', array('id'),
- array('nurl' => normalise_link(get_my_url()), 'uid' => $profile_uid), array('limit' => 1));
+ $r = dba::selectOne('contact', ['id'],
+ ['nurl' => normalise_link(get_my_url()), 'uid' => $profile_uid]);
if (DBM::is_result($r)) {
$cid = $r['id'];
} else {
- $r = dba::select('gcontact', array('id'), array('nurl' => normalise_link(get_my_url())), array('limit' => 1));
+ $r = dba::selectOne('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
if (DBM::is_result($r)) {
$zcid = $r['id'];
}
$clean_url = normalise_link($item['author-link']);
if (local_user()) {
- $r = dba::select('contact', array('id'),
- array('network' => NETWORK_DFRN, 'uid' => local_user(), 'nurl' => normalise_link($clean_url), 'pending' => false),
- array('limit' => 1));
+ $r = dba::selectOne('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'];
$sparkle = true;
$cid = 0;
$network = '';
$rel = 0;
- $r = dba::select('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])), array('limit' => 1));
+ $r = dba::selectOne('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'];
$fields = array($array_key);
}
- $stmt = self::select($table, $fields, $condition, array('limit' => 1, 'only_query' => true));
+ $stmt = self::select($table, $fields, $condition, ['limit' => 1]);
if (is_bool($stmt)) {
$retval = $stmt;
if (is_bool($old_fields)) {
$do_insert = $old_fields;
- $old_fields = self::select($table, array(), $condition, array('limit' => 1));
+ $old_fields = self::selectOne($table, [], $condition);
if (is_bool($old_fields)) {
if ($do_insert) {
return self::e($sql, $params);
}
+ /**
+ * Retrieve a single record from a table and returns it in an associative array
+ *
+ * @brief Retrieve a single record from a table
+ * @param string $table
+ * @param array $fields
+ * @param array $condition
+ * @param array $params
+ * @return bool|array
+ * @see dba::select
+ */
+ public static function selectOne($table, array $fields = [], array $condition = [], $params = [])
+ {
+ $params['limit'] = 1;
+ $result = self::select($table, $fields, $condition, $params);
+
+ if (is_bool($result)) {
+ return $result;
+ } else {
+ $row = self::fetch($result);
+ self::close($result);
+ return $row;
+ }
+ }
+
/**
* @brief Select rows from a table
*
}
if (count($fields) > 0) {
- $select_fields = "`".implode("`, `", array_values($fields))."`";
+ $select_fields = "`" . implode("`, `", array_values($fields)) . "`";
} else {
$select_fields = "*";
}
$condition_string = self::buildCondition($condition);
- $param_string = '';
- $single_row = false;
-
if (isset($params['order'])) {
- $param_string .= " ORDER BY ";
+ $order_string = " ORDER BY ";
foreach ($params['order'] AS $fields => $order) {
if (!is_int($fields)) {
- $param_string .= "`".$fields."` ".($order ? "DESC" : "ASC").", ";
+ $order_string .= "`" . $fields . "` " . ($order ? "DESC" : "ASC") . ", ";
} else {
- $param_string .= "`".$order."`, ";
+ $order_string .= "`" . $order . "`, ";
}
}
- $param_string = substr($param_string, 0, -2);
+ $order_string = substr($order_string, 0, -2);
}
if (isset($params['limit']) && is_int($params['limit'])) {
- $param_string .= " LIMIT ".$params['limit'];
- $single_row = ($params['limit'] == 1);
+ $limit_string = " LIMIT " . $params['limit'];
}
if (isset($params['limit']) && is_array($params['limit'])) {
- $param_string .= " LIMIT ".intval($params['limit'][0]).", ".intval($params['limit'][1]);
- $single_row = ($params['limit'][1] == 1);
+ $limit_string = " LIMIT " . intval($params['limit'][0]) . ", " . intval($params['limit'][1]);
}
- if (isset($params['only_query']) && $params['only_query']) {
- $single_row = !$params['only_query'];
- }
-
- $sql = "SELECT ".$select_fields." FROM `".$table."`".$condition_string.$param_string;
+ $sql = "SELECT " . $select_fields . " FROM `" . $table . "`" . $condition_string . $order_string . $limit_string;
$result = self::p($sql, $condition);
- if (is_bool($result) || !$single_row) {
- return $result;
- } else {
- $row = self::fetch($result);
- self::close($result);
- return $row;
- }
+ return $result;
}
/**
}
if ($params['type'] == NOTIFY_COMMENT) {
- $p = dba::select('thread', ['ignored'], ['iid' => $parent_id], ['limit' => 1]);
+ $p = dba::selectOne('thread', ['ignored'], ['iid' => $parent_id]);
if (DBM::is_result($p) && $p["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
$p = null;
if ($params['otype'] === 'item' && $parent_id) {
- $p = dba::select('item', [], ['id' => $parent_id], ['limit' => 1]);
+ $p = dba::selectOne('item', [], ['id' => $parent_id]);
}
$item_post_type = item_post_type($p);
$profiles = $notification_data["profiles"];
$fields = ['notify-flags', 'language', 'username', 'email', 'nickname'];
- $user = dba::select('user', $fields, ['uid' => $uid], ['limit' => 1]);
+ $user = dba::selectOne('user', $fields, ['uid' => $uid]);
if (!DBM::is_result($user)) {
return false;
}
- $owner = dba::select('contact', ['url'], ['self' => true, 'uid' => $uid], ['limit' => 1]);
+ $owner = dba::selectOne('contact', ['url'], ['self' => true, 'uid' => $uid]);
if (!DBM::is_result($owner)) {
return false;
}
if (remote_user() && count($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $visitor) {
if ($visitor['uid'] == $uid) {
- $r = dba::select('contact', array('profile-id'), array('id' => $visitor['cid']), array('limit' => 1));
+ $r = dba::selectOne('contact', ['profile-id'], ['id' => $visitor['cid']]);
if (DBM::is_result($r)) {
$profile = $r['profile-id'];
}
// check for create date and expire time
$expire_interval = Config::get('system', 'dbclean-expire-days', 0);
- $r = dba::select('user', array('expire'), array('uid' => $uid), array("limit" => 1));
- if (DBM::is_result($r) && ($r['expire'] > 0) && (($r['expire'] < $expire_interval) || ($expire_interval == 0))) {
- $expire_interval = $r['expire'];
+ $user = dba::selectOne('user', ['expire'], ['uid' => $uid]);
+ if (DBM::is_result($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
+ $expire_interval = $user['expire'];
}
if (($expire_interval > 0) && !empty($arr['created'])) {
*/
function item_set_last_item($arr) {
// Unarchive the author
- $contact = dba::select('contact', [], ['id' => $arr["author-link"]], ['limit' => 1]);
+ $contact = dba::selectOne('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::select('contact', [], ['id' => $arr["contact-id"]], ['limit' => 1]);
+ $contact = dba::selectOne('contact', [], ['id' => $arr["contact-id"]]);
if ($contact['term-date'] > NULL_DATE) {
Contact::unmarkForArchival($contact);
}
'subject' => $subject, 'recips' => $handles);
dba::insert('conv', $fields);
- $r = dba::select('conv', array('id'), array('guid' => $conv_guid, 'uid' => local_user()), array('limit' => 1));
+ $r = dba::selectOne('conv', ['id'], ['guid' => $conv_guid, 'uid' => local_user()]);
if (DBM::is_result($r)) {
$convid = $r['id'];
}
'subject' => $subject, 'recips' => $handles);
dba::insert('conv', $fields);
- $r = dba::select('conv', array('id'), array('guid' => $conv_guid, 'uid' => $recipient['uid']), array('limit' => 1));
+ $r = dba::selectOne('conv', ['id'], ['guid' => $conv_guid, 'uid' => $recipient['uid']]);
if (!DBM::is_result($r)) {
logger('send message: conversation not found.');
return -4;
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
// user info
- $r = dba::select('contact', array('micro'), array('uid' => $a->user['uid'], 'self' => true), array('limit' => 1));
+ $r = dba::selectOne('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'],
return '';
}
- $r = dba::select('session', array('data'), array('sid' => $id), array('limit' => 1));
+ $r = dba::selectOne('session', ['data'], ['sid' => $id]);
if (DBM::is_result($r)) {
$session_exists = true;
return $r['data'];
$o = '';
$r = tagadelic($uid, $count, $owner_id, $flags, $type);
if (count($r)) {
- $contact = dba::select(
- 'contact',
- array('url'),
- array('id' => $uid),
- array('limit' => 1)
- );
+ $contact = dba::selectOne('contact', ['url'], ['id' => $uid]);
$url = System::removedBaseUrl($contact['url']);
foreach ($r as $rr) {
*/
if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
// we didn't loaded user data yet, but we need user language
- $r = dba::select('user', array('language'), array('uid' => $_SESSION['uid']), array('limit' => 1));
+ $r = dba::selectOne('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang;
if (DBM::is_result($r)) {
$_SESSION['language'] = $r['language'];
{
if ($a->argc > 2) {
$uid = $a->argv[3];
- $user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
- if (count($user) == 0) {
+ $user = dba::selectOne('user', ['username', 'blocked'], ['uid' => $uid]);
+ if (DBM::is_result($user)) {
notice('User not found' . EOL);
goaway('admin/users');
return ''; // NOTREACHED
// delete user
User::remove($uid);
- notice(t("User '%s' deleted", $user[0]['username']) . EOL);
+ notice(t("User '%s' deleted", $user['username']) . EOL);
break;
case "block":
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s",
- intval(1 - $user[0]['blocked']),
+ intval(1 - $user['blocked']),
intval($uid)
);
- notice(sprintf(($user[0]['blocked'] ? t("User '%s' unblocked") : t("User '%s' blocked")), $user[0]['username']) . EOL);
+ notice(sprintf(($user['blocked'] ? t("User '%s' unblocked") : t("User '%s' blocked")), $user['username']) . EOL);
break;
}
goaway('admin/users');
if ($a->argc > 1) {
$nick = $a->argv[1];
- $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
- dbesc($nick)
- );
-
- if (!count($user)) {
+ $user = dba::selectOne('user', [], ['nickname' => $nick, 'blocked' => false]);
+ if (!DBM::is_result($user)) {
return;
}
- $a->data['user'] = $user[0];
- $a->profile_uid = $user[0]['uid'];
+ $a->data['user'] = $user;
+ $a->profile_uid = $user['uid'];
// if it's a json request abort here becaus we don't
// need the widget data
}
if (!$cid && get_my_url()) {
- /// @todo : Initialize $profile_uid
- $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
- dbesc(normalise_link(get_my_url())),
- intval($profile_uid)
- );
- if (DBM::is_result($r)) {
- $cid = $r[0]['id'];
+ $contact = dba::selectOne('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
+ if (DBM::is_result($contact)) {
+ $cid = $contact['id'];
} else {
- $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
- dbesc(normalise_link(get_my_url()))
- );
- if (DBM::is_result($r)) {
- $zcid = $r[0]['id'];
+ $gcontact = dba::selectOne('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
+ if (DBM::is_result($gcontact)) {
+ $zcid = $gcontact['id'];
}
}
}
$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::select('contact', [], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
+ $contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
}
if (DBM::is_result($contact)) {
notice(t('Failed to update contact record.') . EOL);
}
- $contact = dba::select('contact', [], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
+ $contact = dba::selectOne('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
if (DBM::is_result($contact)) {
$a->data['contact'] = $contact;
}
function _contact_update($contact_id)
{
- $contact = dba::select('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
+ $contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
function _contact_update_profile($contact_id)
{
- $contact = dba::select('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()], ['limit' => 1]);
+ $contact = dba::selectOne('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
$cmd = $a->argv[2];
- $orig_record = dba::select('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false], ['limit' => 1]);
+ $orig_record = dba::selectOne('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');
{
$o = contacts_tab($a, $contact_id, 1);
- $contact = dba::select('contact', ['url'], ['id' => $contact_id], ['limit' => 1]);
+ $contact = dba::selectOne('contact', ['url'], ['id' => $contact_id]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
if ($update) {
$item_id = $_REQUEST['item_id'];
- $item = dba::select('item', ['uid', 'parent'], ['id' => $item_id], ['limit' => 1]);
+ $item = dba::selectOne('item', ['uid', 'parent'], ['id' => $item_id]);
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid']));
$item_parent = $item['parent'];
} else {
$s = dba::inArray($r);
if (local_user() && (local_user() == $a->profile['uid'])) {
- $unseen = dba::select('item', array('id'), array('parent' => $s[0]['parent'], 'unseen' => true), array('limit' => 1));
+ $unseen = dba::selectOne('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));
}
$cid = 0;
if (local_user() && strpos($profileurl, 'redir/') === 0) {
$cid = intval(substr($profileurl, 6));
- $r = dba::select('contact', array('nurl'), array('id' => $cid), array('limit' => 1));
+ $r = dba::selectOne('contact', ['nurl'], ['id' => $cid]);
$profileurl = defaults($r, 'nurl', '');
}
if ($cid) {
// If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
- $condition = array("`id` = ? AND (`forum` OR `prv`)", $cid);
- $contact = dba::select('contact', array('addr', 'nick'), $condition, array('limit' => 1));
+ $condition = ["`id` = ? AND (`forum` OR `prv`)", $cid];
+ $contact = dba::selectOne('contact', ['addr', 'nick'], $condition);
if (DBM::is_result($contact)) {
if ($contact["addr"] != '') {
$content = "!".$contact["addr"];
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
if ($group) {
- $r = dba::select('group', array('name'), array('id' => $group, 'uid' => $_SESSION['uid']), array('limit' => 1));
+ $r = dba::selectOne('group', ['name'], ['id' => $group, 'uid' => $_SESSION['uid']]);
if (!DBM::is_result($r)) {
if ($update)
killme();
$contact_str_self = "";
$contact_str = implode(',',$contacts);
- $self = dba::select('contact', array('id'), array('uid' => $_SESSION['uid'], 'self' => true), array('limit' => 1));
+ $self = dba::selectOne('contact', ['id'], ['uid' => $_SESSION['uid'], 'self' => true]);
if (DBM::is_result($self)) {
$contact_str_self = $self["id"];
}
)) . $o;
} elseif ($cid) {
- $fields = array('id', 'name', 'network', 'writable', 'nurl',
- 'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location');
- $condition = array("`id` = ? AND (NOT `blocked` OR `pending`)", $cid);
- $r = dba::select('contact', $fields, $condition, array('limit' => 1));
+ $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);
if (DBM::is_result($r)) {
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
// We display the last activity (post or login), reduced to year and week number
$last_active = 0;
- $condition = array('uid' => $a->profile['uid'], 'self' => true);
- $contact = dba::select('contact', array('last-item'), $condition, array('limit' => 1));
+ $condition = ['uid' => $a->profile['uid'], 'self' => true];
+ $contact = dba::selectOne('contact', ['last-item'], $condition);
if (DBM::is_result($contact)) {
$last_active = strtotime($contact['last-item']);
}
- $condition = array('uid' => $a->profile['uid']);
- $user = dba::select('user', array('login_date'), $condition, array('limit' => 1));
+ $condition = ['uid' => $a->profile['uid']];
+ $user = dba::selectOne('user', ['login_date'], $condition);
if (DBM::is_result($user)) {
if ($last_active < strtotime($user['login_date'])) {
$last_active = strtotime($user['login_date']);
$r = array();
if (!$direct_cache && ($cachefile == '')) {
- $r = dba::select('photo', array('data', 'desc'), array('resource-id' => $urlhash), array('limit' => 1));
+ $r = dba::selectOne('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
if (DBM::is_result($r)) {
$img_str = $r['data'];
$mime = $r['desc'];
}
$guid = $a->argv[2];
- $importer = dba::select('user', array(), array('guid' => $guid, 'account_expired' => false, 'account_removed' => false), array('limit' => 1));
+ $importer = dba::selectOne('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($importer)) {
http_status_exit(500);
}
require_once('include/acl_selectors.php');
- $profile = dba::select('profile', [], ['is-default' => true, 'uid' => local_user()], ['limit' => 1]);
+ $profile = dba::selectOne('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;
$url = notags(trim($_REQUEST['url']));
$return_url = $_SESSION['return_url'];
- $condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
+ $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::select('contact', array(), $condition, array('limit' => 1));
+ normalise_link($url), $url, NETWORK_STATUSNET];
+ $contact = dba::selectOne('contact', [], $condition);
if (!DBM::is_result($contact)) {
notice(t("Contact wasn't found or can't be unfollowed."));
$submit = t('Submit Request');
- $condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
+ $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::select('contact', array('url', 'network', 'addr', 'name'), $condition, array('limit' => 1));
+ normalise_link($url), $url, NETWORK_STATUSNET];
+ $contact = dba::selectOne('contact', ['url', 'network', 'addr', 'name'], $condition);
if (!DBM::is_result($contact)) {
notice(t("You aren't a friend of this contact.").EOL);
$name = substr($local, 0, strpos($local, '@'));
}
- $r = dba::select('user', array(), array('nickname' => $name), array('limit' => 1));
+ $r = dba::selectOne('user', [], ['nickname' => $name]);
if (!DBM::is_result($r)) {
killme();
}
\r
$a = get_app();\r
\r
- $condition = array('url' => normalise_link($embedurl));\r
- $r = dba::select('oembed', array('content'), $condition, array('limit' => 1));\r
-\r
+ $condition = ['url' => normalise_link($embedurl)];\r
+ $r = dba::selectOne('oembed', ['content'], $condition);\r
if (DBM::is_result($r)) {\r
$txt = $r["content"];\r
} else {\r
// Frequently clear cache
self::clear();
- $r = dba::select('cache', array('v'), array('k' => $key), array('limit' => 1));
+ $r = dba::selectOne('cache', ['v'], ['k' => $key]);
if (DBM::is_result($r)) {
$cached = $r['v'];
}
}
- $ret = dba::select('config', array('v'), array('cat' => $family, 'k' => $key), array('limit' => 1));
+ $ret = dba::selectOne('config', ['v'], ['cat' => $family, 'k' => $key]);
if (DBM::is_result($ret)) {
// manage array value
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
}
}
- $ret = dba::select('pconfig', array('v'), array('uid' => $uid, 'cat' => $family, 'k' => $key), array('limit' => 1));
+ $ret = dba::selectOne('pconfig', ['v'], ['uid' => $uid, 'cat' => $family, 'k' => $key]);
if (DBM::is_result($ret)) {
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
$a->config[$uid][$family][$key] = $val;
private static function highestPriority()
{
$condition = array("`executed` <= ? AND NOT `done`", NULL_DATE);
- $s = dba::select('workerqueue', array('priority'), $condition, array('limit' => 1, 'order' => array('priority')));
+ $s = dba::selectOne('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
if (DBM::is_result($s)) {
return $s["priority"];
} else {
// Are there waiting processes with a higher priority than the currently highest?
$result = dba::select(
'workerqueue',
- array('id'),
- array("`executed` <= ? AND `priority` < ? AND NOT `done`", NULL_DATE, $highest_priority),
- array('limit' => $limit, 'order' => array('priority', 'created'), 'only_query' => true)
+ ['id'],
+ ["`executed` <= ? AND `priority` < ? AND NOT `done`", NULL_DATE, $highest_priority],
+ ['limit' => $limit, 'order' => ['priority', 'created']]
);
while ($id = dba::fetch($result)) {
// Give slower processes some processing time
$result = dba::select(
'workerqueue',
- array('id'),
- array("`executed` <= ? AND `priority` > ? AND NOT `done`", NULL_DATE, $highest_priority),
- array('limit' => $limit, 'order' => array('priority', 'created'), 'only_query' => true)
+ ['id'],
+ ["`executed` <= ? AND `priority` > ? AND NOT `done`", NULL_DATE, $highest_priority],
+ ['limit' => $limit, 'order' => ['priority', 'created']]
);
while ($id = dba::fetch($result)) {
if (!$found) {
$result = dba::select(
'workerqueue',
- array('id'),
- array("`executed` <= ? AND NOT `done`", NULL_DATE),
- array('limit' => $limit, 'order' => array('priority', 'created'), 'only_query' => true)
+ ['id'],
+ ["`executed` <= ? AND NOT `done`", NULL_DATE],
+ ['limit' => $limit, 'order' => ['priority', 'created']]
);
while ($id = dba::fetch($result)) {
return true;
}
- $user = dba::select('user', ['uid', 'username', 'nickname'], ['uid' => $uid], ['limit' => 1]);
+ $user = dba::selectOne('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
if (!DBM::is_result($user)) {
return false;
}
public static function remove($id)
{
// We want just to make sure that we don't delete our "self" contact
- $r = dba::select('contact', array('uid'), array('id' => $id, 'self' => false), array('limit' => 1));
+ $r = dba::selectOne('contact', ['uid'], ['id' => $id, 'self' => false]);
if (!DBM::is_result($r) || !intval($r['uid'])) {
return;
return $menu;
}
- $r = dba::select('contact', array(), array('nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid), array('limit' => 1));
+ $r = dba::selectOne('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
if ($r) {
return self::photoMenu($r, $uid);
} else {
/// @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::select('contact', array('id', 'avatar-date'), array('nurl' => normalise_link($url), 'uid' => $uid), array('limit' => 1));
+ $contact = dba::selectOne('contact', ['id', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
// Then the addr (nick@server.tld)
if (!DBM::is_result($contact)) {
- $contact = dba::select('contact', array('id', 'avatar-date'), array('addr' => $url, 'uid' => $uid), array('limit' => 1));
+ $contact = dba::selectOne('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::select('contact', array('id', 'avatar', 'avatar-date'), array('`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid), array('limit' => 1));
+ $r = dba::selectOne('contact', ['id', 'avatar', 'avatar-date'], ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid]);
$contact = dba::fetch($r);
dba::close($r);
}
}
// Get data from the gcontact table
- $gcontacts = dba::select('gcontact', array('name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'), array('nurl' => normalise_link($url)), array('limit' => 1));
+ $gcontacts = dba::selectOne('gcontact', ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'], ['nurl' => normalise_link($url)]);
if (!DBM::is_result($gcontacts)) {
return 0;
}
$contact_id = $contacts[0]["id"];
// Update the newly created contact from data in the gcontact table
- $gcontact = dba::select('gcontact', array('location', 'about', 'keywords', 'gender'), array('nurl' => normalise_link($data["url"])), array('limit' => 1));
+ $gcontact = dba::selectOne('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'] != '') {
self::updateAvatar($data["photo"], $uid, $contact_id);
- $fields = array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey');
- $contact = dba::select('contact', $fields, array('id' => $contact_id), array('limit' => 1));
+ $fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey'];
+ $contact = dba::selectOne('contact', $fields, ['id' => $contact_id]);
// This condition should always be true
if (!DBM::is_result($contact)) {
return false;
}
- $blocked = dba::select('contact', array('blocked'), array('id' => $cid), array('limit' => 1));
+ $blocked = dba::selectOne('contact', ['blocked'], ['id' => $cid]);
if (!DBM::is_result($blocked)) {
return false;
}
return false;
}
- $hidden = dba::select('contact', array('hidden'), array('id' => $cid), array('limit' => 1));
+ $hidden = dba::selectOne('contact', ['hidden'], ['id' => $cid]);
if (!DBM::is_result($hidden)) {
return false;
}
public static function updateAvatar($avatar, $uid, $cid, $force = false)
{
// Limit = 1 returns the row so no need for dba:inArray()
- $r = dba::select('contact', array('avatar', 'photo', 'thumb', 'micro', 'nurl'), array('id' => $cid), array('limit' => 1));
+ $r = dba::selectOne('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
if (!DBM::is_result($r)) {
return false;
} else {
// Update the public contact (contact id = 0)
if ($uid != 0) {
- $pcontact = dba::select('contact', array('id'), array('nurl' => $r[0]['nurl']), array('limit' => 1));
+ $pcontact = dba::selectOne('contact', ['id'], ['nurl' => $r[0]['nurl']]);
if (DBM::is_result($pcontact)) {
self::updateAvatar($avatar, 0, $pcontact['id'], $force);
}
This will reliably kill your communication with Friendica contacts.
*/
- $r = dba::select('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id], ['limit' => 1]);
+ $r = dba::selectOne('contact', ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'], ['id' => $id]);
if (!DBM::is_result($r)) {
return false;
}
);
}
- $r = dba::select('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid], ['limit' => 1]);
+ $r = dba::selectOne('contact', ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
if (!DBM::is_result($r)) {
$result['message'] .= t('Unable to retrieve contact information.') . EOL;
'network', 'bd', 'gender',
'keywords', 'alias', 'contact-type',
'url', 'location', 'about');
- $old_contact = dba::select('contact', $fields, array('id' => $r[0]["id"]), array('limit' => 1));
+ $old_contact = dba::selectOne('contact', $fields, ['id' => $r[0]["id"]]);
// Update it with the current values
$fields = array('name' => $contact['name'], 'nick' => $contact['nick'],
// all the old members are gone, but the group remains so we don't break any security
// access lists. What we're doing here is reviving the dead group, but old content which
// was restricted to this group may now be seen by the new group members.
- $group = dba::select('group', ['deleted'], ['id' => $gid], ['limit' => 1]);
+ $group = dba::selectOne('group', ['deleted'], ['id' => $gid]);
if (DBM::is_result($group) && $group['deleted']) {
dba::update('group', ['deleted' => 0], ['gid' => $gid]);
notice(t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
return false;
}
- $group = dba::select('group', ['id'], ['uid' => $uid, 'name' => $name], ['limit' => 1]);
+ $group = dba::selectOne('group', ['id'], ['uid' => $uid, 'name' => $name]);
if (DBM::is_result($group)) {
return $group['id'];
}
return false;
}
- $group = dba::select('group', ['uid'], ['gid' => $gid], ['limit' => 1]);
+ $group = dba::selectOne('group', ['uid'], ['gid' => $gid]);
if (!DBM::is_result($group)) {
return false;
}
// remove group from default posting lists
- $user = dba::select('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']], ['limit' => 1]);
+ $user = dba::selectOne('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
if (DBM::is_result($user)) {
$change = false;
*/
public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '')
{
- $r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
+ $r = dba::selectOne('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
if (DBM::is_result($r)) {
$guid = $r['guid'];
} else {
$guid = get_guid();
}
- $x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
+ $x = dba::selectOne('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
$fields = array(
'uid' => $uid,
*/
public static function importProfilePhoto($photo, $uid, $cid, $quit_on_error = false)
{
- $r = dba::select(
- 'photo', array('resource-id'), array('uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos'), array('limit' => 1)
+ $r = dba::selectOne(
+ 'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
);
if (DBM::is_result($r) && strlen($r['resource-id'])) {
return $default_group;
}
- $user = dba::select('user', ['def_gid'], ['uid' => $uid], ['limit' => 1]);
+ $user = dba::selectOne('user', ['def_gid'], ['uid' => $uid]);
if (DBM::is_result($user)) {
$default_group = $user["def_gid"];
if (is_object($user_info)) {
$user = (array) $user_info;
} elseif (is_int($user_info)) {
- $user = dba::select('user',
- ['uid', 'password'],
+ $user = dba::selectOne('user', ['uid', 'password'],
[
'uid' => $user_info,
'blocked' => 0,
'account_expired' => 0,
'account_removed' => 0,
'verified' => 1
- ],
- ['limit' => 1]
+ ]
);
} elseif (is_string($user_info)) {
$user = dba::fetch_first('SELECT `uid`, `password`
if ($insert_result) {
$uid = dba::lastInsertId();
- $user = dba::select('user', [], ['uid' => $uid], ['limit' => 1]);
+ $user = dba::selectOne('user', [], ['uid' => $uid]);
} else {
throw new Exception(t('An error occurred during registration. Please try again.'));
}
logger('Removing user: ' . $uid);
- $user = dba::select('user', [], ['uid' => $uid], ['limit' => 1]);
+ $user = dba::selectOne('user', [], ['uid' => $uid]);
call_hooks('remove_user', $user);
} else {\r
$user_id = User::authenticate(trim($_POST['username']), trim($_POST['password']));\r
if ($user_id) {\r
- $record = dba::select('user', [], ['uid' => $user_id], ['limit' => 1]);\r
+ $record = dba::selectOne('user', [], ['uid' => $user_id]);\r
}\r
}\r
\r
$data = json_decode($_COOKIE["Friendica"]);\r
if (isset($data->uid)) {\r
\r
- $user = dba::select('user',\r
- [],\r
+ $user = dba::selectOne('user', [],\r
[\r
'uid' => $data->uid,\r
'blocked' => false,\r
'account_expired' => false,\r
'account_removed' => false,\r
'verified' => true,\r
- ],\r
- ['limit' => 1]\r
+ ]\r
);\r
-\r
if (DBM::is_result($user)) {\r
if ($data->hash != cookie_hash($user)) {\r
logger("Hash for user " . $data->uid . " doesn't fit.");\r
goaway(self::getApp()->get_baseurl());\r
}\r
\r
- $user = dba::select('user',\r
- [],\r
+ $user = dba::selectOne('user', [],\r
[\r
'uid' => $_SESSION['uid'],\r
'blocked' => false,\r
'account_expired' => false,\r
'account_removed' => false,\r
'verified' => true,\r
- ],\r
- ['limit' => 1]\r
+ ]\r
);\r
if (!DBM::is_result($user)) {\r
nuke_session();\r
{
logger("FKOAuth1::loginUser $uid");
$a = get_app();
- $record = dba::select('user', array(), array('uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1), array('limit' => 1));
+ $record = dba::selectOne('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
if (!DBM::is_result($record)) {
logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
$a->timezone = $a->user['timezone'];
}
- $r = dba::select('contact', array(), array('uid' => $_SESSION['uid'], 'self' => 1), array('limit' => 1));
+ $r = dba::selectOne('contact', [], ['uid' => $_SESSION['uid'], 'self' => 1]);
if (DBM::is_result($r)) {
$a->contact = $r;
*/
public function lookup_nonce($consumer, $token, $nonce, $timestamp)
{
- $r = dba::select('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp], ['limit' => 1]);
+ $r = dba::selectOne('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp]);
if (DBM::is_result($r)) {
return new \OAuthToken($r['id'], $r['secret']);
$condition = array('nurl' => normalise_link($data["url"]));
- $old_fields = dba::select('gcontact', $fieldnames, $condition, array('limit' => 1));
+ $old_fields = dba::selectOne('gcontact', $fieldnames, $condition);
dba::update('gcontact', $fields, $condition, $old_fields);
$condition = array('nurl' => normalise_link($data["url"]), 'self' => false, 'uid' => 0);
- $old_fields = dba::select('contact', $fieldnames, $condition, array('limit' => 1));
+ $old_fields = dba::selectOne('contact', $fieldnames, $condition);
dba::update('contact', $fields, $condition, $old_fields);
}
'classundo' => $item['starred'] ? "" : "hidden",
'starred' => t('starred'),
);
- $r = dba::select('thread', array('ignored'), array('uid' => $item['uid'], 'iid' => $item['id']), array('limit' => 1));
+ $r = dba::selectOne('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
if (DBM::is_result($r)) {
$ignore = array(
'do' => t("ignore thread"),
// like on comments have the comment as parent. So we need to fetch the toplevel parent
if ($parent_item["id"] != $parent_item["parent"]) {
- $toplevel = dba::select('item', array('origin'), array('id' => $parent_item["parent"]), array('limit' => 1));
+ $toplevel = dba::selectOne('item', ['origin'], ['id' => $parent_item["parent"]]);
$origin = $toplevel["origin"];
} else {
$origin = $parent_item["origin"];
$arr["last-child"] = 1;
- $user = dba::select('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]], ['limit' => 1]);
+ $user = dba::selectOne('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]]);
$arr["allow_cid"] = $user["allow_cid"];
$arr["allow_gid"] = $user["allow_gid"];
while ($item = dba::fetch($r)) {
// Fetch the parent item
- $parent = dba::select('item', array('author-link', 'origin'), array('id' => $item["parent"]), array('limit' => 1));
+ $parent = dba::selectOne('item', ['author-link', 'origin'], ['id' => $item["parent"]]);
// Only delete it if the parent author really fits
if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) {
// If the item belongs to a user, we take this user id.
if ($item['uid'] == 0) {
$condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
- $first_user = dba::select('user', ['uid'], $condition, ['limit' => 1]);
+ $first_user = dba::selectOne('user', ['uid'], $condition);
$owner = User::getOwnerDataById($first_user['uid']);
} else {
$owner = User::getOwnerDataById($item['uid']);
if (!$simulate) {
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
- $previous = dba::select('item', ['id'], $condition, ['limit' => 1]);
+ $previous = dba::selectOne('item', ['id'], $condition);
if (DBM::is_result($previous)) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
continue;
$found = false;
if ($aliaslink != '') {
- $condition = array("`uid` = ? AND `alias` = ? AND `network` != ?",
- $importer["uid"], $aliaslink, NETWORK_STATUSNET);
- $r = dba::select('contact', array(), $condition, array('limit' => 1));
+ $condition = ["`uid` = ? AND `alias` = ? AND `network` != ?",
+ $importer["uid"], $aliaslink, NETWORK_STATUSNET];
+ $r = dba::selectOne('contact', [], $condition);
if (DBM::is_result($r)) {
$found = true;
$aliaslink = $author["author-link"];
}
- $condition = array("`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
- normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET);
- $r = dba::select('contact', array(), $condition, array('limit' => 1));
+ $condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
+ normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET];
+ $r = dba::selectOne('contact', [], $condition);
if (DBM::is_result($r)) {
$found = true;
}
if (!$found && ($addr != "")) {
- $condition = array("`uid` = ? AND `addr` = ? AND `network` != ?",
- $importer["uid"], $addr, NETWORK_STATUSNET);
- $r = dba::select('contact', array(), $condition, array('limit' => 1));
+ $condition = ["`uid` = ? AND `addr` = ? AND `network` != ?",
+ $importer["uid"], $addr, NETWORK_STATUSNET];
+ $r = dba::selectOne('contact', [], $condition);
if (DBM::is_result($r)) {
$found = true;
$cid = Contact::getIdForURL($aliaslink, 0);
if ($cid) {
- $fields = array('url', 'nurl', 'name', 'nick', 'alias', 'about', 'location');
- $old_contact = dba::select('contact', $fields, array('id' => $cid), array('limit' => 1));
+ $fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location'];
+ $old_contact = dba::selectOne('contact', $fields, ['id' => $cid]);
// Update it with the current values
$fields = array('url' => $author["author-link"], 'name' => $contact["name"],
*/
private static function deleteNotice($item)
{
- $condition = array('uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']);
- $deleted = dba::select('item', array('id', 'parent-uri'), $condition, array('limit' => 1));
+ $condition = ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']];
+ $deleted = dba::selectOne('item', ['id', 'parent-uri'], $condition);
if (!DBM::is_result($deleted)) {
logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it. ");
return;
*/
private static function fetchRelated($related, $related_uri, $importer)
{
- $condition = array('`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON);
- $conversation = dba::select('conversation', array('source', 'protocol'), $condition, array('limit' => 1));
+ $condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
+ $conversation = dba::selectOne('conversation', ['source', 'protocol'], $condition);
if (DBM::is_result($conversation)) {
$stored = true;
$xml = $conversation['source'];
// Finally we take the data that we fetched from "ostatus:conversation"
if ($xml == '') {
- $condition = array('item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV);
- $conversation = dba::select('conversation', array('source'), $condition, array('limit' => 1));
+ $condition = ['item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV];
+ $conversation = dba::selectOne('conversation', ['source'], $condition);
if (DBM::is_result($conversation)) {
$stored = true;
logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG);
if ($cid) {
if (!$url || !$uid) {
- $r = dba::select('contact', ['poco', 'uid'], ['id' => $cid], ['limit' => 1]);
+ $r = dba::selectOne('contact', ['poco', 'uid'], ['id' => $cid]);
if (DBM::is_result($r)) {
$url = $r['poco'];
$uid = $r['uid'];
return false;
}
- $servers = dba::select('gserver', [], ['nurl' => normalise_link($server_url)], ['limit' => 1]);
+ $servers = dba::selectOne('gserver', [], ['nurl' => normalise_link($server_url)]);
if (DBM::is_result($servers)) {
if ($servers["created"] <= NULL_DATE) {
$fields = ['created' => datetime_convert()];
if ($a->get_hostname() == $aCommand[2]) {
$this->writeLog(LOG_INFO, 'internal auth for ' . $sUser . '@' . $aCommand[2]);
- $aUser = dba::select('user', ['uid', 'password'], ['nickname' => $sUser], ['limit' => 1]);
+ $aUser = dba::selectOne('user', ['uid', 'password'], ['nickname' => $sUser]);
if (DBM::is_result($aUser)) {
$uid = $aUser['uid'];
$success = User::authenticate($aUser, $aCommand[3]);
do {
dba::lock('locks');
- $lock = dba::select('locks', array('locked', 'pid'), array('name' => $fn_name), array('limit' => 1));
+ $lock = dba::selectOne('locks', ['locked', 'pid'], ['name' => $fn_name]);
if (DBM::is_result($lock)) {
if ($lock['locked']) {
}
return;
} elseif (intval($param) > 0) {
- $user = dba::select('user', array('uid', 'username', 'expire'), array('uid' => $param), array('limit' => 1));
+ $user = dba::selectOne('user', ['uid', 'username', 'expire'], ['uid' => $param]);
if (DBM::is_result($user)) {
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG);
item_expire($user['uid'], $user['expire']);
($owner['id'] != $target_item['contact-id']) &&
($target_item['uri'] === $target_item['parent-uri'])) {
- $fields = array('forum', 'prv');
- $condition = array('id' => $target_item['contact-id']);
- $contact = dba::select('contact', $fields, $condition, array('limit' => 1));
+ $fields = ['forum', 'prv'];
+ $condition = ['id' => $target_item['contact-id']];
+ $contact = dba::selectOne('contact', $fields, $condition);
if (!DBM::is_result($contact)) {
// Should never happen
return false;
$d = datetime_convert();
- $contact = dba::select('contact', [], ['id' => $contact_id], ['limit' => 1]);
+ $contact = dba::selectOne('contact', [], ['id' => $contact_id]);
if (!DBM::is_result($contact)) {
logger('Contact not found or cannot be used.');
return;
logger("Mail: Enabled", LOGGER_DEBUG);
$mbox = null;
- $x = dba::select('user', array('prvkey'), array('uid' => $importer_uid), array('limit' => 1));
+ $user = dba::selectOne('user', ['prvkey'], ['uid' => $importer_uid]);
- $condition = array("`server` != '' AND `uid` = ?", $importer_uid);
- $mailconf = dba::select('mailacct', array(), $condition, array('limit' => 1));
- if (DBM::is_result($x) && DBM::is_result($mailconf)) {
+ $condition = ["`server` != '' AND `uid` = ?", $importer_uid];
+ $mailconf = dba::selectOne('mailacct', [], $condition);
+ if (DBM::is_result($user) && DBM::is_result($mailconf)) {
$mailbox = Email::constructMailboxName($mailconf);
$password = '';
- openssl_private_decrypt(hex2bin($mailconf['pass']), $password, $x['prvkey']);
+ openssl_private_decrypt(hex2bin($mailconf['pass']), $password, $user['prvkey']);
$mbox = Email::connect($mailbox, $mailconf['user'], $password);
unset($password);
logger("Mail: Connect to " . $mailconf['user']);
$datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
// Have we seen it before?
- $fields = array('deleted', 'id');
- $condition = array('uid' => $importer_uid, 'uri' => $datarray['uri']);
- $r = dba::select('item', $fields, $condition, array('limit' => 1));
+ $fields = ['deleted', 'id'];
+ $condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']];
+ $r = dba::selectOne('item', $fields, $condition);
if (DBM::is_result($r)) {
logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
$q_item = $r[0];
- $contact = dba::select('contact', [], ['id' => $q_item['cid']], ['limit' => 1]);
+ $contact = dba::selectOne('contact', [], ['id' => $q_item['cid']]);
if (!DBM::is_result($contact)) {
remove_queue_item($q_item['id']);
return;
}
}
- $user = dba::select('user', [], ['uid' => $contact['uid']], ['limit' => 1]);
+ $user = dba::selectOne('user', [], ['uid' => $contact['uid']]);
if (!DBM::is_result($user)) {
remove_queue_item($q_item['id']);
return;
exit(1);
}
$nurl = normalise_link($net['url']);
-$r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit" => 1));
+$r = dba::selectOne("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
if (DBM::is_result($r)) {
dba::update("contact", array("hidden" => true), array("id" => $r["id"]));
echo "NOTICE: The account should be silenced from the global community page\r\n";