2012-06-28 08:00:13 +00:00
|
|
|
<?php
|
|
|
|
|
2013-05-04 08:00:48 +00:00
|
|
|
if (empty($_GET['id']) || !is_number($_GET['id']) || empty($_GET['limit']) || !is_number($_GET['limit'])) {
|
2012-09-19 08:00:35 +00:00
|
|
|
print
|
|
|
|
json_encode(
|
|
|
|
array(
|
|
|
|
'status' => 'failure'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2012-06-28 08:00:13 +00:00
|
|
|
$artist_id = $_GET["id"];
|
2012-06-29 08:00:08 +00:00
|
|
|
$artist_limit = $_GET["limit"];
|
2012-06-28 08:00:13 +00:00
|
|
|
|
|
|
|
$DB->query("
|
2013-05-04 08:00:48 +00:00
|
|
|
SELECT
|
2012-09-19 08:00:35 +00:00
|
|
|
s2.ArtistID,
|
|
|
|
ag.Name,
|
|
|
|
ass.Score
|
2013-05-04 08:00:48 +00:00
|
|
|
FROM artists_similar AS s1
|
2013-10-30 08:01:19 +00:00
|
|
|
JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID AND s1.ArtistID != s2.ArtistID
|
|
|
|
JOIN artists_similar_scores AS ass ON ass.SimilarID = s1.SimilarID
|
|
|
|
JOIN artists_group AS ag ON ag.ArtistID = s2.ArtistID
|
|
|
|
WHERE s1.ArtistID = $artist_id
|
2013-05-04 08:00:48 +00:00
|
|
|
ORDER BY ass.Score DESC
|
|
|
|
LIMIT $artist_limit");
|
2012-06-28 08:00:13 +00:00
|
|
|
|
2012-09-24 08:00:33 +00:00
|
|
|
|
2013-05-04 08:00:48 +00:00
|
|
|
while (list($ArtistID, $Name, $Score) = $DB->next_record(MYSQLI_NUM, false)) {
|
|
|
|
if ($Score < 0) {
|
2012-09-19 08:00:35 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-10-30 08:01:19 +00:00
|
|
|
$results[] = array(
|
|
|
|
'id' => (int)$ArtistID,
|
|
|
|
'name' => $Name,
|
|
|
|
'score' => (int)$Score);
|
2012-09-19 08:00:35 +00:00
|
|
|
}
|
2012-06-28 08:00:13 +00:00
|
|
|
|
|
|
|
print json_encode($results);
|
|
|
|
exit();
|
|
|
|
?>
|