Load matches from db

Possible filters: league_id, hero_id, account_id, start_at_match_id
Also matches_requested used as LIMIT
@return Match[]
502781
public function load()
    {
        $matchesInfo = $this->_getMatchesIdsFromMatches();
        $matchesIds = array();
        foreach ($matchesInfo as $matchInfo) {
            array_push($matchesIds, $matchInfo['match_id']);
        }
        if (count($matchesIds) === 0) {
            return array();
        }
        $slotsInfo = $this->_loadSlotsInfo($matchesIds);
        $picksBansFormattedInfo = $this->_loadPicksBansInfo($matchesIds);

        $slotsIds = array();
        foreach ($slotsInfo as $slotInfo) {
            array_push($slotsIds, $slotInfo['id']);
        }

        $abilitiesUpgradeFormattedInfo = $this->_loadAbilityUpgradesInfo($slotsIds);
        $additionalUnitsFormattedInfo = $this->_loadAdditionalUnitsInfo($slotsIds);

        // we load all matches info and now need to make proper match objects
        $matches = array();
        foreach ($matchesInfo as $matchInfo) {
            $match = new Match();
            $match->setArray($matchInfo);
            $slots_count = 0;
            foreach ($slotsInfo as $slotInfo) {
                if ($slots_count > 9) {
                    // match can't has more than 10 slots
                    break;
                }
                if ($slotInfo['match_id'] == $match->get('match_id')) {
                    $slot = new slot();
                    $slot->setArray($slotInfo);
                    if (array_key_exists($slot->get('id'), $abilitiesUpgradeFormattedInfo)) {
                        $slot->setAbilitiesUpgrade($abilitiesUpgradeFormattedInfo[$slot->get('id')]);
                    }
                    if (array_key_exists($slot->get('id'), $additionalUnitsFormattedInfo)) {
                        $slot->setAdditionalUnitItems($additionalUnitsFormattedInfo[$slot->get('id')]);
                    }
                    $match->addSlot($slot);
                    $slots_count++;
                }
            }
            if (array_key_exists($match->get('match_id'), $picksBansFormattedInfo)) {
                $match->setAllPickBans($picksBansFormattedInfo[$match->get('match_id')]);
            }
            $matches[$match->get('match_id')] = $match;
        }
        return $matches;
    }
1205486
public function players() : array 
    {
        $returnPlayers = [];

        $players = $this->get(sprintf(self::GAME_ENDPOINT . 'titles/%s/players', $this->titleId));

        if ($players->size === 0) return $returnPlayers;

        foreach ($players->data as $player) {
            $returnPlayers[] = new User($this->client, $player->onlineId);
        }

        return $returnPlayers;
    }
338811
def get_match_history(start_at_match_id=None, player_name=None, hero_id=None,
                      skill=0, date_min=None, date_max=None, account_id=None,
                      league_id=None, matches_requested=None, game_mode=None,
                      min_players=None, tournament_games_only=None,
                      **kwargs):
    

    params = {
        "start_at_match_id": start_at_match_id,
        "player_name": player_name,
        "hero_id": hero_id,
        "skill": skill,
        "date_min": date_min,
        "date_max": date_max,
        "account_id": account_id,
        "league_id": league_id,
        "matches_requested": matches_requested,
        "game_mode": game_mode,
        "min_players": min_players,
        "tournament_games_only": tournament_games_only
    }

    return make_request("GetMatchHistory", params, **kwargs)
249756
public function loadFaqs() : array
    {
        return $this->repository->matching(
            $this->repository->criteria()
                ->orderByAsc(Faq::ORDER_TO_DISPLAY)
        );
    }
1257915
public function getPlaylists(): array
    {
        if (is_array($this->playlists)) {
            return $this->playlists;
        }

        $controller = $this->getController();
        $data = $controller->soap("ContentDirectory", "Browse", [
            "ObjectID"          =>  "SQ:",
            "BrowseFlag"        =>  "BrowseDirectChildren",
            "Filter"            =>  "",
            "StartingIndex"     =>  0,
            "RequestedCount"    =>  100,
            "SortCriteria"      =>  "",
        ]);
        $parser = new XmlParser($data["Result"]);

        $playlists = [];
        foreach ($parser->getTags("container") as $container) {
            $playlists[] = new Playlist($container, $controller);
        }

        return $this->playlists = $playlists;
    }
381685
public function selectErrors($limit = null)
    {
        if (!$this->isDb()) {
            return array();
        }

        $sql = "SELECT * FROM log WHERE type LIKE ? ORDER BY created DESC";

        if (isset($limit)) {
            settype($limit, 'integer');
            $sql .= " LIMIT 0,$limit";
        }

        try {
            $results = $this->db->fetchAll($sql, array('php_%'), array('unserialize' => 'data'));
        } catch (Exception $ex) {
            return array();
        }

        $list = array();

        foreach ($results as $result) {
            $list[] = $result['data'];
        }

        return $list;
    }
759354
public function get_entries($start=0, $limit=10) {
        global $DB;

        if ($this->entries === null) {
            if ($sqlarray = $this->get_entry_fetch_sql(false, 'created DESC')) {
                $this->entries = $DB->get_records_sql($sqlarray['sql'], $sqlarray['params'], $start, $limit);
                if (!$start && count($this->entries) < $limit) {
                    $this->totalentries = count($this->entries);
                }
            } else {
                return false;
            }
        }

        return $this->entries;
    }
1042604
public function get()
    {
        $players = [];

        foreach (parent::get() as $login) {
            $player = $this->playerDb->get($login);
            if (is_null($player)) {
                $player = new Player();
                $player->setLogin($login);
            }

            $players[] = $player;
        }

        return $players;
    }
1344151
public function getList()
	{
		$this->getResponse()
			->setStatusCode(Response::STATUS_CODE_200);
		
		// 1) getting params
		$page = (int) $this->params()->fromQuery("page", 1);
		$category = $this->params()->fromQuery("category", "usato");
		$purpose = $this->params()->fromQuery("purpose", "compravendita");
		$location = $this->params()->fromQuery("location", "italia");
		$limit = 30;
		$offset = ($page * $limit) - $limit;
		$returnSelect = true;
		
		// 2) Discard useless params and prepare them to be passed to the model
		$params = $this->requestToSearchParams($this->params()->fromQuery());
		$params = is_array($params) ? $params + compact('returnSelect', 'offset', 'limit') : array();
		
		if(empty($params)) {
            return new JsonModel(array());
		}
		
		// 3) get only for current user?
		$onlyCurrentUser = (bool) $this->params()->fromQuery("current", false);
		$k = 0;
		foreach($params['field'] as $f) {
			if('current' == $f || 'user' == $f) {
				unset($params['field'][$k]);
				unset($params['value'][$k]);
			}
			$k++;
		}
		if($onlyCurrentUser) {
			if($this->zfcUserAuthentication()->hasIdentity()) {
				$identity = $this->zfcUserAuthentication()->getIdentity();
// 				$params['field'][] = 'user';
// 				$params['value'][] = sha1('neo' . $identity->getUserId() . 'bazaar');
				$params['field'][] = 'account';
				$params['value'][] = sha1('neo' . $identity->getUserId() . 'bazaar');
			} else {
				// Questo è necessario per non far restituire la lista completa se l'utente non è connesso
				$params['field'][] = 'account';
				$params['value'][] = sha1('usernotconnected');
			}
		}
		
		// 4) all classifieds? This should be requested only by the admin, will not use sphinx
		if((bool) $this->params()->fromQuery("full", false)) {
			if($this->zfcUserAuthentication()->hasIdentity()) {
			    $params = $this->params()->fromQuery();
				$identity = $this->zfcUserAuthentication()->getIdentity();
				$userModel = $this->getServiceLocator()->get('user.model.user');
				$userModel->init($identity, $this->getServiceLocator());
				if(!$userModel->getIsAdmin()) {
				    return new JsonModel(array());
				}
				
				$paginator = $this->getServiceLocator()->get('document.paginator.classifiedFull');
				$paginator->build($params);

				$data = array();
				foreach($paginator as $post) {
            		$file = $this->getServiceLocator()->get('document.model.classifiedAdminListing');
				    $data[] = $file->init($post);
				}

				$routeName = 'DocumentAdminClassified/page';
				$routeParams = array('page' => $this->params()->fromQuery("page", 1));
				$queryParams = array('full' => 1, 'user' => $this->params()->fromQuery("user"));
				$data = $this->getModel()->getPaginationData($this->getServiceLocator(), $paginator, $data, $routeName, $routeParams, $queryParams);

				return new JsonModel($data);
			}
		}
		
		// 5) Pass param to the model and get the data
		$data = $this->getModel()->getList($params, $this->getServiceLocator());
		
		return new JsonModel($data);
	}
302845
protected function getIDListFromDB() : array
    {
        $arElementIDList = (array) Product::getByCategory($this->sValue)
            ->where('brand_id', '>', 0)
            ->lists('brand_id', 'id');

        $obCategory = Category::find($this->sValue);
        if (!empty($obCategory)) {
            $arAdditionalElementIDList = (array) $obCategory->product_link()
                ->where('brand_id', '>', 0)
                ->lists('brand_id', 'id');

            $arElementIDList = $arElementIDList + $arAdditionalElementIDList;
        }

        return $arElementIDList;
    }
689111
public List<Object> match() {
        final IntMatchResults result = new IntMatchResults();
        if (matches(result)) {
            return result.getIntResultList();
        } else {
            return null;
        }
    }
1083561
public function getMatchData()
    {
        if (!$this->lastMatchResult) {
            $this->throwException(
                'Failed to get match data: No match result found. Use match first'
            );
        }

        $data = [];
        foreach ($this->lastMatchResult as $key => $value) {
            if (is_string($key)) {
                $data[$key] = $value;
            }
        }

        return $data;
    }
763155
public function fetchAll(): array
    {
        $sql = $this->builder->buildSql();
        $this->builder = new QueryBuilder($this->pdo);
        return $this->fetchAllBySql($sql);
    }
343178
public function findAllIdentifiers(): array
    {
        $queryBuilder = $this->createQuery();
        $rows = $queryBuilder->select('identifier')
            ->from($this->getTableName())
            ->groupBy('identifier')
            ->execute()
            ->fetchAll();

        $cacheIdentifiers = [];
        foreach ($rows as $row) {
            $cacheIdentifiers[] = $row['identifier'];
        }

        return $cacheIdentifiers;
    }
198198
protected function loadRelated(): array
    {
        $innerKey = $this->parent->getField($this->key(Record::INNER_KEY));
        if (!empty($innerKey)) {
            return $this->createSelector($innerKey)->fetchData();
        }

        return [];
    }
493038
protected function findOrphanedHashes(): array
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('if.hash AS hash')
                     ->from(IconFile::class, 'if')
                     ->leftJoin('if.icons', 'i')
                     ->andWhere('i.id IS NULL');

        $result = [];
        foreach ($queryBuilder->getQuery()->getResult() as $data) {
            $result[] = $data['hash'];
        }
        return $result;
    }
1061784
function load($key,$val) {
		if ($found=$this->find($key,$val)) {
			$this->id=$found[0]->id;
			return $this->item=$found[0]->item;
		}
		$this->reset();
		return [];
	}