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;
|
throw e;
|
||||||
}
|
}
|
||||||
auto url = getDefUrl( show, language, c );
|
auto url = getDefUrl( show, language, c );
|
||||||
string season_id{};
|
string show_id{};
|
||||||
string pattern{};
|
string pattern{};
|
||||||
db.exec( TEXT( "INSERT OR IGNORE INTO SHOWS ( URL, SHOW, PATH, LANGUAGE ) "
|
db.exec( TEXT( "INSERT OR IGNORE INTO SHOWS ( URL, SHOW, PATH, LANGUAGE ) "
|
||||||
"VALUES ( '" ) +
|
"VALUES ( '" ) +
|
||||||
sanitize( url ) + TEXT( "', '" ) + sanitize( show ) +
|
sanitize( url ) + TEXT( "', '" ) + sanitize( show ) +
|
||||||
TEXT( "', '" ) + sanitize( absolute ) + TEXT( "', '" ) +
|
TEXT( "', '" ) + sanitize( absolute ) + TEXT( "', '" ) +
|
||||||
sanitize( language ) + TEXT( "' );" ) );
|
sanitize( language ) + TEXT( "' );" ) );
|
||||||
db.exec( TEXT( "SELECT ID FROM SHOWS WHERE PATH == '" ) +
|
show_id = std::to_string( db.lastRowID() );
|
||||||
sanitize( absolute ) + TEXT( "';" ),
|
|
||||||
season_id );
|
|
||||||
db.exec( TEXT( "SELECT PATH FROM SHOWS WHERE URL == 'pattern';" ),
|
db.exec( TEXT( "SELECT PATH FROM SHOWS WHERE URL == 'pattern';" ),
|
||||||
pattern );
|
pattern );
|
||||||
|
|
||||||
@ -689,7 +687,7 @@ void addToDB( string &show, const string &path, const string &language,
|
|||||||
for ( auto &episode : season.second ) {
|
for ( auto &episode : season.second ) {
|
||||||
db.exec( TEXT( "INSERT OR IGNORE INTO EPISODES ( SHOWID, PATH ) "
|
db.exec( TEXT( "INSERT OR IGNORE INTO EPISODES ( SHOWID, PATH ) "
|
||||||
"VALUES ( " ) +
|
"VALUES ( " ) +
|
||||||
season_id + TEXT( ", '" ) + sanitize( episode ) +
|
show_id + TEXT( ", '" ) + sanitize( episode ) +
|
||||||
TEXT( "' );" ) );
|
TEXT( "' );" ) );
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -176,6 +176,10 @@ public:
|
|||||||
sqlite3_close( db );
|
sqlite3_close( db );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t lastRowID() {
|
||||||
|
return sqlite3_last_insert_rowid(db);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user