QString RomInfo::toString() { return QString ("Rom Info:\n" "ID: %1\n" "Game Name: %2\n" "Rom Name: %3\n" "Rom Path: %4") .arg(Id()).arg(Gamename()) .arg(Romname()).arg(Rompath()); }
void RomInfo::SaveToDatabase() { MSqlQuery query(MSqlQuery::InitCon()); bool inserting = false; if (m_id == 0) inserting = true; if (inserting) { LOG(VB_GENERAL, LOG_INFO, LOC + QString("Adding %1 - %2").arg(Rompath()) .arg(Romname())); query.prepare("INSERT INTO gamemetadata " "(system, romname, gamename, genre, year, gametype, " "rompath, country, crc_value, diskcount, display, plot, " "publisher, version, fanart, boxart, screenshot) " "VALUES (:SYSTEM, :ROMNAME, :GAMENAME, :GENRE, :YEAR, " ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PLOT, " ":PUBLISHER, :VERSION, :FANART, :BOXART, :SCREENSHOT)"); query.bindValue(":SYSTEM",System()); query.bindValue(":ROMNAME",Romname()); query.bindValue(":GAMENAME",Gamename()); query.bindValue(":GENRE",Genre()); query.bindValue(":YEAR",Year()); query.bindValue(":GAMETYPE",GameType()); query.bindValue(":ROMPATH",Rompath()); query.bindValue(":COUNTRY",Country()); query.bindValue(":CRC32", QString()); query.bindValue(":PLOT", Plot()); query.bindValue(":PUBLISHER", Publisher()); query.bindValue(":VERSION", Version()); query.bindValue(":FANART", Fanart()); query.bindValue(":BOXART", Boxart()); query.bindValue(":SCREENSHOT", Screenshot()); } else { query.prepare("UPDATE gamemetadata " "SET version = 'CUSTOM', " " gamename = :GAMENAME," " genre = :GENRE," " year = :YEAR," " country = :COUNTRY," " plot = :PLOT," " publisher = :PUBLISHER," " favorite = :FAVORITE," " screenshot = :SCREENSHOT," " fanart = :FANART," " boxart = :BOXART, " " inetref = :INETREF " "WHERE gametype = :GAMETYPE AND " " romname = :ROMNAME"); query.bindValue(":GAMENAME", Gamename()); query.bindValue(":GENRE", Genre()); query.bindValue(":YEAR", Year()); query.bindValue(":COUNTRY", Country()); query.bindValue(":PLOT", Plot()); query.bindValue(":PUBLISHER", Publisher()); query.bindValue(":FAVORITE", Favorite()); query.bindValue(":SCREENSHOT", Screenshot()); query.bindValue(":FANART", Fanart()); query.bindValue(":BOXART", Boxart()); query.bindValue(":INETREF", Inetref()); query.bindValue(":GAMETYPE", GameType()); query.bindValue(":ROMNAME", Romname()); } if (!query.exec()) { MythDB::DBError("RomInfo::SaveToDatabase", query); return; } }
void RomInfo::UpdateDatabase() { MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SELECT gamename,genre,year,country,plot,publisher, " "favorite,screenshot,fanart,boxart,inetref " "FROM gamemetadata " "WHERE gametype = :GAMETYPE " "AND romname = :ROMNAME"); query.bindValue(":GAMETYPE", GameType()); query.bindValue(":ROMNAME", Romname()); if (!query.exec()) { MythDB::DBError("RomInfo::UpdateDatabase", query); return; } if (!query.next()) return; QString t_gamename = query.value(0).toString(); QString t_genre = query.value(1).toString(); QString t_year = query.value(2).toString(); QString t_country = query.value(3).toString(); QString t_plot = query.value(4).toString(); QString t_publisher = query.value(5).toString(); bool t_favourite = query.value(6).toBool(); QString t_screenshot = query.value(7).toString(); QString t_fanart = query.value(8).toString(); QString t_boxart = query.value(9).toString(); QString t_inetref = query.value(10).toString(); if ((t_gamename != Gamename()) || (t_genre != Genre()) || (t_year != Year()) || (t_country != Country()) || (t_plot != Plot()) || (t_publisher != Publisher()) || (t_favourite != Favorite()) || (t_screenshot != Screenshot()) || (t_fanart != Fanart()) || (t_boxart != Boxart()) || (t_inetref != Inetref())) { query.prepare("UPDATE gamemetadata " "SET version = 'CUSTOM', " " gamename = :GAMENAME," " genre = :GENRE," " year = :YEAR," " country = :COUNTRY," " plot = :PLOT," " publisher = :PUBLISHER," " favorite = :FAVORITE," " screenshot = :SCREENSHOT," " fanart = :FANART," " boxart = :BOXART, " " inetref = :INETREF " "WHERE gametype = :GAMETYPE AND " " romname = :ROMNAME"); query.bindValue(":GAMENAME", Gamename()); query.bindValue(":GENRE", Genre()); query.bindValue(":YEAR", Year()); query.bindValue(":COUNTRY", Country()); query.bindValue(":PLOT", Plot()); query.bindValue(":PUBLISHER", Publisher()); query.bindValue(":FAVORITE", Favorite()); query.bindValue(":SCREENSHOT", Screenshot()); query.bindValue(":FANART", Fanart()); query.bindValue(":BOXART", Boxart()); query.bindValue(":INETREF", Inetref()); query.bindValue(":GAMETYPE", GameType()); query.bindValue(":ROMNAME", Romname()); if (!query.exec()) { MythDB::DBError("RomInfo::UpdateDatabase", query); return; } } }