Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Label::add_method('getTrackIDs', function() {
- $db = static::getDB();
- return array_reduce(
- array_map(function($id) use($db) {
- $query = $db->prepare('SELECT id FROM tracks WHERE releaseID=:id;');
- $query->bindValue(':id', $id, PDO::PARAM_INT);
- $query->execute();
- return array_map(function($id) {
- return intval($id);
- }, $query->fetchAll(PDO::FETCH_COLUMN, 0));
- }, $this->getReleaseIDs()),
- function($a, $b) {
- return array_merge($a, $b);
- },
- []
- );
- });
- Label::add_method('getTrackIDs', function() {
- $rids = $this->getReleaseIDs();
- $condition = implode(
- ' OR ',
- array_map(function($index, $id) {
- return "releaseID=:id$index";
- }, array_keys($rids), $rids)
- );
- if(!$condition)
- return [];
- $db = static::getDB();
- $query = $db->prepare("SELECT id FROM tracks WHERE $condition;");
- foreach($rids as $index => $id) {
- $query->bindValue(":id$index", $id, PDO::PARAM_INT);
- }
- $query->execute();
- return array_map(function($id) {
- return intval($id);
- }, $query->fetchAll(PDO::FETCH_COLUMN, 0));
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement