Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector<string> database::retRow(string query)
- {
- vector<string> rRow;
- MYSQL_RES *res_set; //Result set object to store output table from the query
- MYSQL_ROW row; // row variable to process each row from the result set.
- bool t = mysql_query(connect, query.c_str()); // execute the query, returns Zero for success. Nonzero if an error occurred. details at https://dev.mysql.com/doc/refman/5.7/en/mysql-query.html
- if (t == false)
- {
- res_set = mysql_store_result(connect); //reads the entire result of a query, allocates a MYSQL_RES structure, details at: https://dev.mysql.com/doc/refman/5.7/en/mysql-store-result.html
- int num_col = mysql_num_fields(res_set); // get number of columns
- rRow.push_back(to_string(num_col));
- if (((row = mysql_fetch_row(res_set)) != NULL))
- {
- for (int i = 0; i < num_col; i++)
- {
- rRow.push_back(row[i]);
- }
- }
- return rRow;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement