/*
	mysql C++ wrapper library

	Author: Roland Haenel <rh@ginster.net>

	This program is in the public domain.
	Distribute and use it freely.
*/

This is a small C++ wrapper I have written around the basic mysql
client library. My primary intention was the build a unified interface
for the following database engines:

           * mysql by Michael Widenius
           * msql by David Hughes
           * postgres95 by the Postgres Group

But because mysql is by far the best of all those, the scope
of this implementation has changed a bit. The goal is now to
provide an easy-to-use, secure interface to mysql.

An example program can be found in example.cc. There is no real 
'documentation' (any one volunteering?!). Just some words about 
the classes:

'Database' provides the communication interface to the mysqld
database backend. Following methods are implemented:

int Database::init()

	Actually, this does nothing at the moment, but be sure to
	call it before doing anything else. This might be important
	for future releases.

int Database::status();

	To be called at any time. Returns the connection status:
	DB_CONNECTION_NONE, DB_CONNECTION_OK, DB_CONNECTION_BAD

char Database::*errorMessage();

	If an error occured, returns a text describing the error
	
int Database::connect(char *host, char *port, char *db);

	Connect to 'db' at 'host'. Note that 'port' is currently
	not used.

void Database::disconnect();

	Cancel a connection

int Database::reset();

	No implemented right now

DBResult *Database::exec(char *sqlFormat, ...);
void      Database::exec(DBResult *res, char *sqlFormat, ...);

	Execute arbitrary SQL command. The first form returns an 
	instance of class DBResult (even if there was a failure). 
	The latter form re-uses an already created instance of
	class DBResult.

int DBResult::status();

	Returns the transaction status associated with the
	instance. Values may be the following:

	#define DB_COMMAND_OK           0       // OK - command executed
	#define DB_EMPTY_QUERY          1       // Query didn't return tuples
	#define DB_TUPLES_OK            2       // Query returned tuples 
	#define DB_ERROR                5	// Error on command
	#define DB_BAD_RESPONSE         6
	#define DB_UNEXPECTED           7       // This shouldn't ever happen

int DBResult::nrTuples();

	Returns the number of fetched tuples (if status() == DB_TUPLES_OK)

int DBResult::nrFields();

	Returns the number of fields per tuple (if status() == DB_TUPLES_OK)

char *DBResult::fieldName(int n);

	Returns the name of the nth tuple field

int DBResult::fieldSize(int n);

	Returns the size of the nth tuple field (in bytes)

int DBResult::fieldSize(char *name);

	Returns the size of the nth tuple field (in bytes)

void DBResult::seekTuple(int tuple);

	Sets internal cursor to a tuple. This tuple will be retrieved
	by the next getTuple() call.

char **DBResult::getTuple();

	Fetch one tuple. getTuple()[0] is the first field value,
	and so on.

char **DBResult::getTuple(int tuple);

	Access tuple directly. For sequential access please don't
	use this method. Use seekTuple()/getTuple() instead.

