// todo: create the connection here

// Construct the query string.  You were already doing this in your code
std::ostringstream query_builder;
query_builder << "select pipe_id from pipe where version_id='" << id << "'";

// Convert the ostringstream to a string
std::string query_string = query_builder.str();

// Construct a query object with the query string
mysqlpp::Query query = connection.query(query_string);

// Perform the query
mysqlpp::StoreQueryResult result = query.store();
for(size_t i = 0; i < result.num_rows(); i++)
   std::cout << result[i]["version_id"] << result[i]["pipe_id"] << std::endl;


我遇到错误

error: request for the member 'query' in connection which is non-class type '
MYSQL*'

at line
**mysqlpp::Query query = connection.query(query_string);**

最佳答案

connection是一个指针;您需要使用->运算符:

connection->query(query_string)

关于c++ - 错误:请求连接中非类类型“MYSQL *”的成员“查询”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3783907/

10-10 14:17
查看更多