// 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;
我正在錯誤錯誤:請求用於連接的構件「查詢」,這是無級類型「MYSQL *」
error: request for the member 'query' in connection which is non-class type '
MYSQL*'
at line
**mysqlpp::Query query = connection.query(query_string);**
如果你沒有[一個很好的入門C++的書(http://stackoverflow.com/questions/388242/the-definitive-c++-book-guide-和列表),那麼你應該確保獲得一個;有一本好書從中學習C++是非常重要的。 – 2010-09-24 03:01:44