1
0
Fork 0
oldhaven/php/app/musicbrainz/models/Release.class.php

37 lines
899 B
PHP
Raw Normal View History

2011-03-31 02:01:16 +00:00
<?php
class Musicbrainz_ReleaseModel extends Model {
public function getReleases($release_groups, $group_by_release = false, $only_official = false) {
if (!is_array($release_groups)) {
$release_groups = array($release_groups);
}
$releases = $this->db->getRows(
$this->db->q('
SELECT *
FROM musicbrainz.bh_release
WHERE
release_group IN (\''. implode('\',\'', $release_groups) .'\')
'. ($only_official ? 'AND type = 1' : 'AND type IS NOT NULL') .'
ORDER BY
date ASC,
id ASC
'),
'id'
);
if ($group_by_release) {
$g_releases = array();
foreach ($releases as $release) {
if (!isset($g_releases[$release['release_group']])) {
$g_releases[$release['release_group']] = array();
}
$g_releases[$release['release_group']][$release['id']] = $release;
}
return $g_releases;
} else {
return $releases;
}
}
}