Judy
Judy

Reputation: 1553

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

// 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;

I am getting error

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

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

Upvotes: 0

Views: 117

Answers (1)

James McNellis
James McNellis

Reputation: 355367

connection is a pointer; you need to use the -> operator:

connection->query(query_string)

Upvotes: 1

Related Questions