How can I wrap the number of requests in a transaction in C ++? I am working on Ubuntu 10 using this file:
#include "/usr/include/mysql/mysql.h"
with C ++ to interact with the MySQL database.
EDIT: right now I am running queries through a small wrapper class, for example:
MYSQL_RES* PDB::query(string query)
{
int s = mysql_query(this->connection, query.c_str());
if( s != 0 )
{
cout << mysql_error(&this->mysql) << endl;
}
return mysql_store_result(this->connection);
}
MYSQL_ROW PDB::getarray(MYSQL_RES *res)
{
return mysql_fetch_row( res );
}
MYSQL_RES res = db->query( "SELECT * FROM `table` WHERE 1" );
while( MYSQL_ROW row = db->getarray( res ) )
{
cout << row[0] << endl;
}
source
share