2024-03-22 */ use Propel\Runtime\ActiveQuery\Criteria; // ">=" filter criteria use Propel\Runtime\Propel; // for getConnection use Propel\Runtime\Formatter\ObjectFormatter; // for PropelObjectFormatter require_once(__DIR__.'/ui.php'); if (!$id = (int)Util::ValidateArrayKey($_GET, 'id')) { // no/false-y 'id' get param passed Util::Redirect('/'); } $artist = ArtistQuery::create()->findOneByArtistId($id); if (null === $artist) { // artist id does not exist Util::Redirect('/'); } // if we just have an ID and no description (ie. old-style URL) redirect to a nicer one. if (empty($_GET['desc'])) { Util::Redirect('/concert-dates/'.$artist->getNiceUrl()); } // next 20 events this artist is appearing at in the future. // relative to which timezone? right now will be php timezone // limited to 20 results, some venues have >100 events (venue 237 has >500). // including null event start time. event 1539403 shows 1 artist, 32757, // but when you click on the artist it shows no upcoming events... technically // missing datetime means it cant be 'upcoming', asked eric, he said include them. // as long as these events eventually get a time, everything is okay... we will see. $nowGmt = strtotime(gmdate('Y-m-d H:i:s')); $events = EventQuery::create() ->filterByArtist($artist) ->filterByEventStartTime($nowGmt, Criteria::GREATER_EQUAL) ->_or() ->filterByEventStartTime(null) ->orderByEventStartTimeLocal() ->limit(999) ->find(); // get artists who have performed with this artist. // gets a list of events the artist has performed at, then gets all artists // that have performed at those events. grouped by artist_id to filter duplicates. // this query is faster than i anticipated it would be. // order by count(artist_id) to order by # of times artist has played together // with the artist we are searching for. // note this can get long (eg flo rida, 2582, has 264 results) $sql = ' select tp_artists.* FROM tp_artist_event_relationships as a inner join tp_artist_event_relationships as b on (a.event_match=b.event_match) inner join tp_artists on (b.artist_match=tp_artists.artist_id) where a.artist_match = :search_artist and b.artist_match != :search_artist group by tp_artists.artist_id order by count(tp_artists.artist_id) desc '; $con = Propel::getConnection(); $stmt = $con->prepare($sql); $stmt->execute([ ':search_artist' => $artist->getArtistId() ]); $formatter = new ObjectFormatter(); $formatter->setClass('Artist'); $appearedWith = $formatter->format($con->getDataFetcher($stmt)); // add artist name to page title $template->title = "{$artist->getArtistName()} NEW " . date("Y") . " concert dates, {$artist->getArtistName()} tour stops, presale passwords and more | Box Office Hero"; // links for prev/next artist at bottom of page $nextArtist = ArtistQuery::create()->findOneByArtistId($artist->getArtistId()+1); $prevArtist = ArtistQuery::create()->findOneByArtistId($artist->getArtistId()-1); $template->assign('artist', $artist); $template->assign('events', $events); $template->assign('appearedWith', $appearedWith); $template->assign('nextArtist', $nextArtist); $template->assign('prevArtist', $prevArtist); $template->display('concert-dates.tpl');