Rename DBA::inArray to DBA::toArray
This commit is contained in:
		
					parent
					
						
							
								f051ae1698
							
						
					
				
			
			
				commit
				
					
						4db98eb43d
					
				
			
		
					 17 changed files with 34 additions and 34 deletions
				
			
		| 
						 | 
				
			
			@ -41,7 +41,7 @@ function q($sql) {
 | 
			
		|||
 | 
			
		||||
	$columns = DBA::columnCount($ret);
 | 
			
		||||
 | 
			
		||||
	$data = DBA::inArray($ret);
 | 
			
		||||
	$data = DBA::toArray($ret);
 | 
			
		||||
 | 
			
		||||
	if ((count($data) == 0) && ($columns == 0)) {
 | 
			
		||||
		return true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -116,7 +116,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
 | 
			
		|||
		$r = DBA::select('user', ['uid', 'username', 'nickname'],
 | 
			
		||||
			['parent-uid' => $master_record['uid'], 'account_removed' => false]);
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$a->identities = array_merge($a->identities, DBA::inArray($r));
 | 
			
		||||
			$a->identities = array_merge($a->identities, DBA::toArray($r));
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		// Just ensure that the array is always defined
 | 
			
		||||
| 
						 | 
				
			
			@ -126,14 +126,14 @@ function authenticate_success($user_record, $login_initial = false, $interactive
 | 
			
		|||
		$r = DBA::select('user', ['uid', 'username', 'nickname'],
 | 
			
		||||
			['uid' => $master_record['parent-uid'], 'account_removed' => false]);
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$a->identities = DBA::inArray($r);
 | 
			
		||||
			$a->identities = DBA::toArray($r);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Then add all siblings
 | 
			
		||||
		$r = DBA::select('user', ['uid', 'username', 'nickname'],
 | 
			
		||||
			['parent-uid' => $master_record['parent-uid'], 'account_removed' => false]);
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$a->identities = array_merge($a->identities, DBA::inArray($r));
 | 
			
		||||
			$a->identities = array_merge($a->identities, DBA::toArray($r));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
 | 
			
		|||
		$master_record['uid']
 | 
			
		||||
	);
 | 
			
		||||
	if (DBM::is_result($r)) {
 | 
			
		||||
		$a->identities = array_merge($a->identities, DBA::inArray($r));
 | 
			
		||||
		$a->identities = array_merge($a->identities, DBA::toArray($r));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ($login_initial) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -479,7 +479,7 @@ function admin_page_contactblock(App $a)
 | 
			
		|||
 | 
			
		||||
	$statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
 | 
			
		||||
 | 
			
		||||
	$contacts = DBA::inArray($statement);
 | 
			
		||||
	$contacts = DBA::toArray($statement);
 | 
			
		||||
 | 
			
		||||
	$t = get_markup_template('admin/contactblock.tpl');
 | 
			
		||||
	$o = replace_macros($t, [
 | 
			
		||||
| 
						 | 
				
			
			@ -782,7 +782,7 @@ function admin_page_workerqueue(App $a)
 | 
			
		|||
{
 | 
			
		||||
	// get jobs from the workerqueue table
 | 
			
		||||
	$statement = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
 | 
			
		||||
	$r = DBA::inArray($statement);
 | 
			
		||||
	$r = DBA::toArray($statement);
 | 
			
		||||
 | 
			
		||||
	for($i = 0; $i < count($r); $i++) {
 | 
			
		||||
		$r[$i]['parameter'] = implode(json_decode($r[$i]['parameter']), ': ');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -198,14 +198,14 @@ function community_getitems($start, $itemspage, $content)
 | 
			
		|||
			AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin`
 | 
			
		||||
			ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage)
 | 
			
		||||
		);
 | 
			
		||||
		return DBA::inArray($r);
 | 
			
		||||
		return DBA::toArray($r);
 | 
			
		||||
	} elseif ($content == 'global') {
 | 
			
		||||
		$r = DBA::p("SELECT `uri` FROM `thread`
 | 
			
		||||
				INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
 | 
			
		||||
				INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
 | 
			
		||||
				WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked`
 | 
			
		||||
				ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage));
 | 
			
		||||
		return DBA::inArray($r);
 | 
			
		||||
		return DBA::toArray($r);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Should never happen
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -845,7 +845,7 @@ function networkThreadedView(App $a, $update, $parent)
 | 
			
		|||
			local_user(), TERM_OBJ_POST, TERM_HASHTAG,
 | 
			
		||||
			$top_limit, $bottom_limit);
 | 
			
		||||
 | 
			
		||||
		$data = DBA::inArray($items);
 | 
			
		||||
		$data = DBA::toArray($items);
 | 
			
		||||
 | 
			
		||||
		if (count($data) > 0) {
 | 
			
		||||
			$tag_top_limit = current($data)['order_date'];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ class ContactSelector
 | 
			
		|||
		$o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
 | 
			
		||||
 | 
			
		||||
		$s = DBA::select('profile', ['id', 'profile-name', 'is-default'], ['uid' => $_SESSION['uid']]);
 | 
			
		||||
		$r = DBA::inArray($s);
 | 
			
		||||
		$r = DBA::toArray($s);
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			foreach ($r as $rr) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ class ACL extends BaseObject
 | 
			
		|||
			ORDER BY `name` ASC ", intval(local_user())
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		$contacts = DBA::inArray($stmt);
 | 
			
		||||
		$contacts = DBA::toArray($stmt);
 | 
			
		||||
 | 
			
		||||
		$arr = ['contact' => $contacts, 'entry' => $o];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -171,7 +171,7 @@ class ACL extends BaseObject
 | 
			
		|||
			ORDER BY `name` ASC ", intval(local_user())
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		$contacts = DBA::inArray($stmt);
 | 
			
		||||
		$contacts = DBA::toArray($stmt);
 | 
			
		||||
 | 
			
		||||
		$arr = ['contact' => $contacts, 'entry' => $o];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,7 +81,7 @@ class Addon
 | 
			
		|||
		if (strlen($addons)) {
 | 
			
		||||
			$r = DBA::select('addon', [], ['installed' => 1]);
 | 
			
		||||
			if (DBM::is_result($r)) {
 | 
			
		||||
				$installed = DBA::inArray($r);
 | 
			
		||||
				$installed = DBA::toArray($r);
 | 
			
		||||
			} else {
 | 
			
		||||
				$installed = [];
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -874,7 +874,7 @@ class Worker
 | 
			
		|||
		$r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			self::$db_duration += (microtime(true) - $stamp);
 | 
			
		||||
			return DBA::inArray($r);
 | 
			
		||||
			return DBA::toArray($r);
 | 
			
		||||
		}
 | 
			
		||||
		DBA::close($r);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -892,7 +892,7 @@ class Worker
 | 
			
		|||
 | 
			
		||||
		if ($found) {
 | 
			
		||||
			$r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
 | 
			
		||||
			return DBA::inArray($r);
 | 
			
		||||
			return DBA::toArray($r);
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -185,7 +185,7 @@ class DBA
 | 
			
		|||
	 */
 | 
			
		||||
	public static function databaseName() {
 | 
			
		||||
		$ret = self::p("SELECT DATABASE() AS `db`");
 | 
			
		||||
		$data = self::inArray($ret);
 | 
			
		||||
		$data = self::toArray($ret);
 | 
			
		||||
		return $data[0]['db'];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -266,7 +266,7 @@ class DBA
 | 
			
		|||
			case 'pdo':
 | 
			
		||||
				$r = self::p("SELECT 1");
 | 
			
		||||
				if (DBM::is_result($r)) {
 | 
			
		||||
					$row = self::inArray($r);
 | 
			
		||||
					$row = self::toArray($r);
 | 
			
		||||
					$connected = ($row[0]['1'] == '1');
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
| 
						 | 
				
			
			@ -1462,7 +1462,7 @@ class DBA
 | 
			
		|||
	 * @param object $stmt statement object
 | 
			
		||||
	 * @return array Data array
 | 
			
		||||
	 */
 | 
			
		||||
	public static function inArray($stmt, $do_close = true) {
 | 
			
		||||
	public static function toArray($stmt, $do_close = true) {
 | 
			
		||||
		if (is_bool($stmt)) {
 | 
			
		||||
			return $stmt;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ class Contact extends BaseObject
 | 
			
		|||
				local_user()
 | 
			
		||||
			);
 | 
			
		||||
			if (DBM::is_result($stmt)) {
 | 
			
		||||
				$return = DBA::inArray($stmt);
 | 
			
		||||
				$return = DBA::toArray($stmt);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -401,14 +401,14 @@ class Contact extends BaseObject
 | 
			
		|||
		$s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
 | 
			
		||||
			`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
 | 
			
		||||
		FROM `contact` WHERE `nurl` = ? AND `uid` = ?", normalise_link($url), $uid);
 | 
			
		||||
		$r = DBA::inArray($s);
 | 
			
		||||
		$r = DBA::toArray($s);
 | 
			
		||||
 | 
			
		||||
		// Fetch contact data from the contact table for the given user, checking with the alias
 | 
			
		||||
		if (!DBM::is_result($r)) {
 | 
			
		||||
			$s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
 | 
			
		||||
				`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
 | 
			
		||||
			FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = ?", normalise_link($url), $url, $ssl_url, $uid);
 | 
			
		||||
			$r = DBA::inArray($s);
 | 
			
		||||
			$r = DBA::toArray($s);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Fetch the data from the contact table with "uid=0" (which is filled automatically)
 | 
			
		||||
| 
						 | 
				
			
			@ -416,7 +416,7 @@ class Contact extends BaseObject
 | 
			
		|||
			$s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
 | 
			
		||||
			`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
 | 
			
		||||
			FROM `contact` WHERE `nurl` = ? AND `uid` = 0", normalise_link($url));
 | 
			
		||||
			$r = DBA::inArray($s);
 | 
			
		||||
			$r = DBA::toArray($s);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Fetch the data from the contact table with "uid=0" (which is filled automatically) - checked with the alias
 | 
			
		||||
| 
						 | 
				
			
			@ -424,7 +424,7 @@ class Contact extends BaseObject
 | 
			
		|||
			$s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
 | 
			
		||||
			`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
 | 
			
		||||
			FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = 0", normalise_link($url), $url, $ssl_url);
 | 
			
		||||
			$r = DBA::inArray($s);
 | 
			
		||||
			$r = DBA::toArray($s);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Fetch the data from the gcontact table
 | 
			
		||||
| 
						 | 
				
			
			@ -432,7 +432,7 @@ class Contact extends BaseObject
 | 
			
		|||
			$s = DBA::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
 | 
			
		||||
			`keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, 0 AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
 | 
			
		||||
			FROM `gcontact` WHERE `nurl` = ?", normalise_link($url));
 | 
			
		||||
			$r = DBA::inArray($s);
 | 
			
		||||
			$r = DBA::toArray($s);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -866,7 +866,7 @@ class Contact extends BaseObject
 | 
			
		|||
			);
 | 
			
		||||
 | 
			
		||||
			$s = DBA::select('contact', ['id'], ['nurl' => normalise_link($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
 | 
			
		||||
			$contacts = DBA::inArray($s);
 | 
			
		||||
			$contacts = DBA::toArray($s);
 | 
			
		||||
			if (!DBM::is_result($contacts)) {
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -739,7 +739,7 @@ class Event extends BaseObject
 | 
			
		|||
 | 
			
		||||
		$events = DBA::select('event', $fields, $conditions);
 | 
			
		||||
		if (DBM::is_result($events)) {
 | 
			
		||||
			$return = DBA::inArray($events);
 | 
			
		||||
			$return = DBA::toArray($events);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -114,7 +114,7 @@ class Group extends BaseObject
 | 
			
		|||
			local_user()
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		return DBA::inArray($stmt);
 | 
			
		||||
		return DBA::toArray($stmt);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -557,7 +557,7 @@ class Profile
 | 
			
		|||
				DateTimeFormat::utcNow()
 | 
			
		||||
			);
 | 
			
		||||
			if (DBM::is_result($s)) {
 | 
			
		||||
				$r = DBA::inArray($s);
 | 
			
		||||
				$r = DBA::toArray($s);
 | 
			
		||||
				Cache::set($cachekey, $r, CACHE_HOUR);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ class FKOAuthDataStore extends OAuthDataStore
 | 
			
		|||
		logger(__function__ . ":" . $consumer_key);
 | 
			
		||||
 | 
			
		||||
		$s = DBA::select('clients', ['client_id', 'pw', 'redirect_uri'], ['client_id' => $consumer_key]);
 | 
			
		||||
		$r = DBA::inArray($s);
 | 
			
		||||
		$r = DBA::toArray($s);
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			return new OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']);
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ class FKOAuthDataStore extends OAuthDataStore
 | 
			
		|||
		logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token);
 | 
			
		||||
 | 
			
		||||
		$s = DBA::select('tokens', ['id', 'secret', 'scope', 'expires', 'uid'], ['client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token]);
 | 
			
		||||
		$r = DBA::inArray($s);
 | 
			
		||||
		$r = DBA::toArray($s);
 | 
			
		||||
 | 
			
		||||
		if (DBM::is_result($r)) {
 | 
			
		||||
			$ot = new OAuthToken($r[0]['id'], $r[0]['secret']);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -408,7 +408,7 @@ class Notifier
 | 
			
		|||
				$condition['network'] = $networks;
 | 
			
		||||
			}
 | 
			
		||||
			$contacts = DBA::select('contact', ['id', 'url', 'network'], $condition);
 | 
			
		||||
			$r = DBA::inArray($contacts);
 | 
			
		||||
			$r = DBA::toArray($contacts);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// delivery loop
 | 
			
		||||
| 
						 | 
				
			
			@ -458,7 +458,7 @@ class Notifier
 | 
			
		|||
 | 
			
		||||
			$condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
 | 
			
		||||
				'pending' => false, 'archive' => false, 'rel' => [CONTACT_IS_FOLLOWER, CONTACT_IS_FRIEND]];
 | 
			
		||||
			$r2 = DBA::inArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
 | 
			
		||||
			$r2 = DBA::toArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
 | 
			
		||||
 | 
			
		||||
			$r = array_merge($r2, $r1);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ class Queue
 | 
			
		|||
			// Handling the pubsubhubbub requests
 | 
			
		||||
			PushSubscriber::requeue();
 | 
			
		||||
 | 
			
		||||
			$r = DBA::inArray(DBA::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
 | 
			
		||||
			$r = DBA::toArray(DBA::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
 | 
			
		||||
 | 
			
		||||
			Addon::callHooks('queue_predeliver', $r);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue