This is some example code from my app:
int page_id;
string page_name;
enum COLUMNS {
PAGE_ID,
PAGE_NAME
};
if (mysql_query(conn, "SELECT page_id, page_name FROM pages")) {
exit_mysql_error(conn);
}
MYSQL_RES *res = mysql_use_result(conn);
while (MYSQL_ROW row = mysql_fetch_row(res)) {
page_id = *(int *)res[PAGE_ID];
page_name = res[PAGE_NAME];
// do some stuff where I need the page_id and page_name int/string
}
So imho this isn't the right way to obtain the integer value from the result (yet it works) but I couldn't find good example on how to do it. Also I'm quite new to programming in C++, so any feedback on the code sample is welcome.
page_id = atoi(row[0]);
page_name = row[1]; // not really sure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With