Working on downloading the song

This commit is contained in:
kdeng00
2019-08-25 16:47:52 -04:00
parent 540d665a7e
commit fb03354189
5 changed files with 92 additions and 8 deletions
+16 -5
View File
@@ -65,11 +65,11 @@ void songRepository::saveRecord(const Song& song)
MYSQL_STMT *stmt = mysql_stmt_init(conn);
std::string query = "INSERT INTO Song(Title, Artist, Album, Genre, ";
query.append("Year, Duration, CoverArtId) VALUES(?, ?, ?, ?, ?, ?, ?)");
query.append("Year, Duration, SongPath, CoverArtId) VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
status = mysql_stmt_prepare(stmt, query.c_str(), query.size());
MYSQL_BIND params[7];
MYSQL_BIND params[8];
memset(params, 0, sizeof(params));
params[0].buffer_type = MYSQL_TYPE_STRING;
@@ -106,10 +106,16 @@ void songRepository::saveRecord(const Song& song)
params[5].length = 0;
params[5].is_null = 0;
params[6].buffer_type = MYSQL_TYPE_LONG;
params[6].buffer = (char*)&song.coverArtId;
params[6].length = 0;
params[6].buffer_type = MYSQL_TYPE_STRING;
params[6].buffer = (char*)song.songPath.c_str();
auto pathLength = song.songPath.size();
params[6].length = &pathLength;
params[6].is_null = 0;
params[7].buffer_type = MYSQL_TYPE_LONG;
params[7].buffer = (char*)&song.coverArtId;
params[7].length = 0;
params[7].is_null = 0;
status = mysql_stmt_bind_param(stmt, params);
status = mysql_stmt_execute(stmt);
@@ -155,6 +161,8 @@ std::vector<Song> songRepository::parseRecords(MYSQL_RES* results)
song.duration = std::stoi(row[i]);
break;
case 7:
song.songPath = row[i];
case 8:
song.coverArtId = std::stoi(row[i]);
break;
}
@@ -197,6 +205,9 @@ Song songRepository::parseRecord(MYSQL_RES* results)
song.duration = std::stoi(row[i]);
break;
case 7:
song.songPath = row[i];
break;
case 8:
song.coverArtId = std::stoi(row[i]);
}
}