Add last_insert_rowid to sqlitepp and use it
This commit is contained in:
parent
1d00c5374e
commit
1ced65f632
@ -645,16 +645,14 @@ void addToDB( string &show, const string &path, const string &language,
|
||||
throw e;
|
||||
}
|
||||
auto url = getDefUrl( show, language, c );
|
||||
string season_id{};
|
||||
string show_id{};
|
||||
string pattern{};
|
||||
db.exec( TEXT( "INSERT OR IGNORE INTO SHOWS ( URL, SHOW, PATH, LANGUAGE ) "
|
||||
"VALUES ( '" ) +
|
||||
sanitize( url ) + TEXT( "', '" ) + sanitize( show ) +
|
||||
TEXT( "', '" ) + sanitize( absolute ) + TEXT( "', '" ) +
|
||||
sanitize( language ) + TEXT( "' );" ) );
|
||||
db.exec( TEXT( "SELECT ID FROM SHOWS WHERE PATH == '" ) +
|
||||
sanitize( absolute ) + TEXT( "';" ),
|
||||
season_id );
|
||||
show_id = std::to_string( db.lastRowID() );
|
||||
db.exec( TEXT( "SELECT PATH FROM SHOWS WHERE URL == 'pattern';" ),
|
||||
pattern );
|
||||
|
||||
@ -689,7 +687,7 @@ void addToDB( string &show, const string &path, const string &language,
|
||||
for ( auto &episode : season.second ) {
|
||||
db.exec( TEXT( "INSERT OR IGNORE INTO EPISODES ( SHOWID, PATH ) "
|
||||
"VALUES ( " ) +
|
||||
season_id + TEXT( ", '" ) + sanitize( episode ) +
|
||||
show_id + TEXT( ", '" ) + sanitize( episode ) +
|
||||
TEXT( "' );" ) );
|
||||
}
|
||||
i++;
|
||||
|
@ -176,6 +176,10 @@ public:
|
||||
sqlite3_close( db );
|
||||
}
|
||||
|
||||
int64_t lastRowID() {
|
||||
return sqlite3_last_insert_rowid(db);
|
||||
}
|
||||
|
||||
private:
|
||||
sqlite3 *db;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user