summaryrefslogtreecommitdiff
path: root/models/album.py
diff options
context:
space:
mode:
Diffstat (limited to 'models/album.py')
-rw-r--r--models/album.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/models/album.py b/models/album.py
index 216b615..9ca3798 100644
--- a/models/album.py
+++ b/models/album.py
@@ -134,3 +134,26 @@ class Album():
)
return albums
+
+ def all(order="album.id", direction="ASC", limit=None, offset=None):
+ db = DbManager()
+ cursor = db.cursor()
+ albums = []
+
+ select_string = """SELECT * FROM album LEFT JOIN album_artist ON
+ album_artist.album_id = album.id LEFT JOIN artist ON
+ album_artist.artist_id = artist.id ORDER BY %s %s""" % (order,
+ direction)
+
+ if limit is not None and offset is not None:
+ select_string = " ".join((select_string,
+ "LIMIT %s OFFSET %s" % (limit, offset)))
+
+ result = cursor.execute(select_string)
+
+ for row in result:
+ albums.append(
+ Album(id=row[0], name=row[1], date=row[2])
+ )
+
+ return albums