src/Db.php
public function get($query, $token = null) {
		if (is_scalar($token)) $token = [$token];
				
		// search for access keys
		$accesskey = null;
		$found = preg_match('=SELECT.+>([a-z_]+).+FROM=is', $query, $match);
		if ($found === 1) {
			$accesskey = $match[1];
			$query = str_replace('>'.$accesskey, $accesskey, $query);
		}
		
		// do query
		$this->connect();
		$sth = $this->prepare($query);
		$returner['SUCCESS'] = $sth->execute($token);
		$returner['RESULT'] = $sth->fetchAll(\PDO::FETCH_ASSOC);
		$returner['NUM_ROWS'] = count($returner['RESULT']);
		
		// if an access key was provided rearrange array
		if (!is_null($accesskey)) {
			$newreturner = [];
			foreach ($returner['RESULT'] as $row) {
				$newreturner[$row[$accesskey]] = $row;
			}
			$returner['RESULT'] = $newreturner;
		}

		return $returner;
	}
public function get($query, $token = null) {
		if (is_scalar($token)) $token = [$token];
				
		// search for access keys
		$accesskey = null;
		$found = preg_match('=SELECT.+>([a-z_]+).+FROM=is', $query, $match);
		if ($found === 1) {
			$accesskey = $match[1];
			$query = str_replace('>'.$accesskey, $accesskey, $query);
		}
		
		// do query
		$this->connect();
		$sth = $this->prepare($query);
		$returner['SUCCESS'] = $sth->execute($token);
		$returner['RESULT'] = $sth->fetchAll(\PDO::FETCH_ASSOC);
		$returner['NUM_ROWS'] = count($returner['RESULT']);
		
		// if an access key was provided rearrange array
		if (!is_null($accesskey)) {
			$newreturner = [];
			foreach ($returner['RESULT'] as $row) {
				$newreturner[$row[$accesskey]] = $row;
			}
			$returner['RESULT'] = $newreturner;
		}

		return $returner;
	}
public function get ( $ query , $ token = null ) { if ( is_scalar ( $ token ) ) $ token = [ $ token ] ; // search for access keys $ accesskey = null ; $ found = preg_match ( '=SELECT.+>([a-z_]+).+FROM=is' , $ query , $ match ) ; if ( $ found === 1 ) { $ accesskey = $ match [ 1 ] ; $ query = str_replace ( '>' . $ accesskey , $ accesskey , $ query ) ; } // do query $ this -> connect ( ) ; $ sth = $ this -> prepare ( $ query ) ; $ returner [ 'SUCCESS' ] = $ sth -> execute ( $ token ) ; $ returner [ 'RESULT' ] = $ sth -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ returner [ 'NUM_ROWS' ] = count ( $ returner [ 'RESULT' ] ) ; // if an access key was provided rearrange array if ( ! is_null ( $ accesskey ) ) { $ newreturner = [ ] ; foreach ( $ returner [ 'RESULT' ] as $ row ) { $ newreturner [ $ row [ $ accesskey ] ] = $ row ; } $ returner [ 'RESULT' ] = $ newreturner ; } return $ returner ; }
This method sends a query to the database and returns the result.

@param  string $query  The SQL query to send.
@param  array $token An array with the prepared statement parameters (indexed or associative array, depends on the use of the prepared statement syntax)
@return array Returns an array with the keys `SUCCESS` (true if the query could successfully sent to the db, otherwise false), `RESULT` (array The complete result set of the request) and `NUM_ROWS` (integer 	The count of returned results).
This method sends a query to the database and returns the result .