aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marshall <jmarshall@xbmc.org>2013-11-30 18:21:49 +1300
committerJonathan Marshall <jmarshall@xbmc.org>2013-12-24 13:48:57 +1300
commit12fa837e85ef9e5215fc36e8148def582c578b0c (patch)
treea9d48cc7ec6b0fbef1a71cde5b5c58922e212186
parent3229c9cd71453082ccaf0c0749f671a7e19f2669 (diff)
[musicdb] retrieve the song artist credits in GetSong
-rw-r--r--xbmc/music/MusicDatabase.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp
index ff9f4aef33..5952e68f47 100644
--- a/xbmc/music/MusicDatabase.cpp
+++ b/xbmc/music/MusicDatabase.cpp
@@ -663,9 +663,9 @@ bool CMusicDatabase::GetSong(int idSong, CSong& song)
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
- CStdString strSQL=PrepareSQL("select * from songview "
- "where idSong=%i"
- , idSong);
+ CStdString strSQL=PrepareSQL("SELECT songview.*,songartistview.* FROM songview "
+ " JOIN songartistview ON songview.idSong = songartistview.idSong "
+ " WHERE songview.idSong = %i", idSong);
if (!m_pDS->query(strSQL.c_str())) return false;
int iRowsFound = m_pDS->num_rows();
@@ -674,7 +674,24 @@ bool CMusicDatabase::GetSong(int idSong, CSong& song)
m_pDS->close();
return false;
}
- song = GetSongFromDataset();
+
+ int songArtistOffset = song_enumCount;
+
+ set<int> artistcredits;
+ song = GetSongFromDataset(m_pDS.get()->get_sql_record());
+ while (!m_pDS->eof())
+ {
+ const dbiplus::sql_record* const record = m_pDS.get()->get_sql_record();
+
+ int idSongArtist = record->at(songArtistOffset + artistCredit_idArtist).get_asInt();
+ if (artistcredits.find(idSongArtist) == artistcredits.end())
+ {
+ song.artistCredits.push_back(GetArtistCreditFromDataset(record, songArtistOffset));
+ artistcredits.insert(idSongArtist);
+ }
+
+ m_pDS->next();
+ }
m_pDS->close(); // cleanup recordset data
return true;
}