smysql.h
scratch/src/smysql.h · 1.5 KB
From the archive scratch.tgz
Download the archive « Back to the archive contents
///////////////////////////////////////////////////////////
///////////////// Have an itch? Scratch it! ///////////////
///////////////////////// SCRATCH /////////////////////////
///////////////////// A MUD Server ////////////////////
///////////////////// By: Jared Devall ////////////////////
///////////////////// Thanks: ////////////////////
///////////////////// DIKU/Merc/ROM ////////////////////
///////////////////// Aetas/Deus Gang ////////////////////
///////////////////// Beej ////////////////////
///////////////////////////////////////////////////////////
#ifndef __SMYSQL_H_
#define __SMYSQL_H_
#include <string>
#include <map>
#include <vector>
#include <mysql/mysql.h>
class Mysql {
public:
typedef struct st_mysql MYSQL;
typedef std::map< std::string, std::string > LMAP;
typedef std::vector< LMAP > RESULT;
private:
MYSQL * _dbinstance;
public:
Mysql ( const char * hostname, const char * username, const char * password, const char * dbname );
~Mysql( );
bool Query( const char * query );
int QueryRows( const char * query );
bool RealQuery( const char * query );
std::string EscapeString( const std::string & );
bool Load( const char * query );
RESULT< LMAP > _info;
static Mysql &Instance();
};
// Our singleton instance
inline Mysql &Mysql::Instance() {
static Mysql instance( "localhost", "rendelven", "rendelven", "rendelven" );;
return instance;
}
#endif // _SMYSQL_H