I am using the SqliteModernCpp library. I have a data access object pattern, including the following function:
void movie_data_access_object::update_movie(movie to_update)
{
// connect to the database
sqlite::database db(this->connection_string);
// execute the query
std::string query = "UPDATE movies SET title = " + to_update.get_title() + " WHERE rowid = " + std::to_string(to_update.get_id());
db << query;
}
Essentially, I want to update the record in the database whose rowid
(the PK) has the value that the object to_update
has in its parameter (which is returned by get_id()
).
This code yields an SQL logic error. What is the cause of this?
Aucun commentaire:
Enregistrer un commentaire