public static function getSponsorOffers(WebSoccer $websoccer, DbConnection $db, $teamId) { $team = TeamsDataService::getTeamSummaryById($websoccer, $db, $teamId); $teamRank = TeamsDataService::getTableRankOfTeam($websoccer, $db, $teamId); $columns["S.id"] = "sponsor_id"; $columns["S.name"] = "name"; $columns["S.b_spiel"] = "amount_match"; $columns["S.b_heimzuschlag"] = "amount_home_bonus"; $columns["S.b_sieg"] = "amount_win"; $columns["S.b_meisterschaft"] = "amount_championship"; $fromTable = $websoccer->getConfig("db_prefix") . "_sponsor AS S"; $whereCondition = "S.liga_id = %d AND (S.min_platz = 0 OR S.min_platz >= %d)" . " AND (S.max_teams <= 0 OR S.max_teams > (SELECT COUNT(*) FROM " . $websoccer->getConfig("db_prefix") . "_verein AS T WHERE T.sponsor_id = S.id AND T.sponsor_spiele > 0))" . " ORDER BY S.b_spiel DESC"; $parameters = array($team["team_league_id"], $teamRank); return $db->queryCachedSelect($columns, $fromTable, $whereCondition, $parameters, 20); }