bool Database::storeQuery(DBQuery &q, DBResult &dbres) { MYSQL_ROW row; MYSQL_FIELD *fields; MYSQL_RES *r; unsigned int num_fields; // Execute the query if(!this->executeQuery(q)) return false; // Getting results from the query r = mysql_store_result(&m_handle); if(!r) { //throw DBError( mysql_error(&m_handle), DB_ERROR_STORE ); std::cout << "MYSQL ERROR mysql_store_result: " << q.getText() << " " << mysql_error(&m_handle) << std::endl; return false; } // Getting the rows of the result num_fields = mysql_num_fields(r); dbres.clear(); // Getting the field names //dbres.clearFieldNames(); fields = mysql_fetch_fields(r); for(int i=0; i < num_fields; ++i) { dbres.setFieldName(std::string(fields[i].name), i); } // Adding the rows to a list //dbres.clearRows(); while(row = mysql_fetch_row(r)) { dbres.addRow(row, num_fields); } // Free query result mysql_free_result(r); r = NULL; // Check if there are rows in the query if(dbres.getNumRows() > 0) return true; else return false; }