public function artistAction($artistId, $artistName)
{
$key = 'artist' . $artistId;
$exists = $this->view->getCache()->exists($key);
if (!$exists) {
$artist = Artists::findFirst(array('id = ?0', 'bind' => array($artistId)));
if ($artist == false) {
return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
}
//Main tags
$phql = 'SELECT t.name
FROM AlbumOrama\\Models\\ArtistsTags at
JOIN AlbumOrama\\Models\\Tags t
WHERE at.artists_id = ' . $artist->id . '
LIMIT 10';
$tags = $this->modelsManager->executeQuery($phql);
//Top albums
$phql = 'SELECT
al.id,
al.name,
al.uri,
ap.url
FROM AlbumOrama\\Models\\Albums al
JOIN AlbumOrama\\Models\\AlbumsPhotos ap
WHERE
ap.type = "large" AND
al.artists_id = ' . $artist->id . ' AND
al.playcount > 25000
ORDER BY al.playcount DESC
LIMIT 18';
$albums = $this->modelsManager->executeQuery($phql);
//Similar Artists
$phql = 'SELECT
ar.id,
ar.name,
ar.uri,
ap.url
FROM AlbumOrama\\Models\\ArtistsSimilar ars,
AlbumOrama\\Models\\Artists ar,
AlbumOrama\\Models\\ArtistsPhotos ap
WHERE
ars.similar_artist_id = ar.id AND
ars.similar_artist_id = ap.artists_id AND
ap.type = "large" AND
ars.artists_id = ' . $artist->id . '
ORDER BY ar.listeners DESC
LIMIT 10';
$similars = $this->modelsManager->executeQuery($phql);
$this->view->setVars(array("artist" => $artist, "albums" => $albums, "similars" => $similars, "tags" => $tags, "photo" => $artist->getPhoto('extralarge')));
}
$this->view->cache(array("key" => $key));
}