aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marshall <jmarshall@xbmc.org>2014-08-07 21:12:59 +1200
committerJonathan Marshall <jmarshall@xbmc.org>2014-08-09 11:25:13 +1200
commitb6aa62b9abf37b069378d53d36c1b36b5e32793a (patch)
tree5917f3f23b41e8722038d4cc3fdfe49146ab2bc4
parent63b41ad9da29928edb7ee08fbdf6d952a60b8619 (diff)
[videodb] adds UpdateLinkTable/UpdateActorLinkTable to video database
-rw-r--r--xbmc/video/VideoDatabase.cpp32
-rw-r--r--xbmc/video/VideoDatabase.h2
2 files changed, 34 insertions, 0 deletions
diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp
index 796d8f368b..c792057ace 100644
--- a/xbmc/video/VideoDatabase.cpp
+++ b/xbmc/video/VideoDatabase.cpp
@@ -1604,6 +1604,38 @@ void CVideoDatabase::RemoveFromLinkTable(const char *table, const char *firstFie
}
}
+void CVideoDatabase::UpdateLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values)
+{
+ std::string sql = PrepareSQL("delete from %slink%s where id%s=%i", field.c_str(), mediaType.c_str(), mediaType.c_str(), mediaId);
+ m_pDS->exec(sql);
+
+ for (std::vector<std::string>::const_iterator i = values.begin(); i != values.end(); ++i)
+ {
+ if (!i->empty())
+ {
+ int idValue = AddToTable(field, "id" + field, "str" + field, *i);
+ if (idValue > -1)
+ AddToLinkTable((field + "link" + mediaType).c_str(), ("id" + field).c_str(), idValue, ("id" + mediaType).c_str(), mediaId);
+ }
+ }
+}
+
+void CVideoDatabase::UpdateActorLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values)
+{
+ std::string sql = PrepareSQL("delete from %slink%s where id%s=%i", field.c_str(), mediaType.c_str(), mediaType.c_str(), mediaId);
+ m_pDS->exec(sql);
+
+ for (std::vector<std::string>::const_iterator i = values.begin(); i != values.end(); ++i)
+ {
+ if (!i->empty())
+ {
+ int idValue = AddActor(*i, "");
+ if (idValue > -1)
+ AddToLinkTable((field + "link" + mediaType).c_str(), ("id" + field).c_str(), idValue, ("id" + mediaType).c_str(), mediaId);
+ }
+ }
+}
+
//****Tags****
void CVideoDatabase::AddTagToItem(int idMovie, int idTag, const std::string &type)
{
diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h
index 492eebbe99..1731abe8a9 100644
--- a/xbmc/video/VideoDatabase.h
+++ b/xbmc/video/VideoDatabase.h
@@ -805,6 +805,8 @@ protected:
void AddLinkToActor(const char *table, int actorID, const char *secondField, int secondID, const CStdString &role, int order);
void AddToLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField = NULL, const char *type = NULL);
void RemoveFromLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField = NULL, const char *type = NULL);
+ void UpdateLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values);
+ void UpdateActorLinkTable(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values);
void AddCast(int idMedia, const char *table, const char *field, const std::vector<SActorInfo> &cast);
void AddArtistToMusicVideo(int lMVideo, int idArtist);