Handle the case of no rows returned in fuh::db_query_to_string

This commit is contained in:
loonycyborg 2017-01-17 04:09:21 +03:00
parent 8714ece259
commit 6883f73c0f

View File

@ -265,6 +265,8 @@ fuh::mysql_result fuh::db_query(const std::string& sql) {
std::string fuh::db_query_to_string(const std::string& sql) {
mysql_result res = db_query(sql);
MYSQL_ROW row = mysql_fetch_row(res.get());
if(row == NULL)
throw error("query returned no rows");
if(row[0] == NULL)
throw error("got null value from the database");
return std::string(row[0]);