mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
110 lines
2.7 KiB
C
110 lines
2.7 KiB
C
![]() |
#ifndef SAPPHIRE_CONNECTION_H
|
||
|
#define SAPPHIRE_CONNECTION_H
|
||
|
|
||
|
#include <boost/shared_ptr.hpp>
|
||
|
#include <boost/scoped_ptr.hpp>
|
||
|
#include <mysql.h>
|
||
|
#include <map>
|
||
|
|
||
|
namespace Core
|
||
|
{
|
||
|
namespace Db
|
||
|
{
|
||
|
|
||
|
typedef std::map< enum mysql_option, std::string > optionMap;
|
||
|
class MySqlBase;
|
||
|
|
||
|
class Connection
|
||
|
{
|
||
|
//Statement * createServiceStmt();
|
||
|
|
||
|
public:
|
||
|
|
||
|
Connection( MySqlBase * pBase,
|
||
|
const std::string& hostName,
|
||
|
const std::string& userName,
|
||
|
const std::string& password );
|
||
|
|
||
|
Connection( MySqlBase * pBase,
|
||
|
const std::string& hostName,
|
||
|
const std::string& userName,
|
||
|
const std::string& password,
|
||
|
const optionMap& options );
|
||
|
|
||
|
virtual ~Connection();
|
||
|
|
||
|
void close();
|
||
|
bool isClosed();
|
||
|
|
||
|
void setOption( enum mysql_option option, const void *arg );
|
||
|
void setOption( enum mysql_option option, uint32_t arg );
|
||
|
void setOption( enum mysql_option option, const std::string& arg );
|
||
|
|
||
|
MySqlBase *getMySqlBase();
|
||
|
|
||
|
void setAutoCommit( bool autoCommit );
|
||
|
|
||
|
//// implemented up to this point
|
||
|
|
||
|
bool getAutoCommit();
|
||
|
|
||
|
|
||
|
void beginTransaction();
|
||
|
void commitTransaction();
|
||
|
void rollbackTransaction();
|
||
|
|
||
|
//Statement * createStatement();
|
||
|
|
||
|
std::string escapeString( const std::string& );
|
||
|
|
||
|
|
||
|
|
||
|
std::string getSchema();
|
||
|
void setSchema( const std::string& catalog );
|
||
|
|
||
|
void getOption( enum mysql_option option, void * optionValue );
|
||
|
|
||
|
std::string getOption( enum mysql_option option );
|
||
|
|
||
|
//DatabaseMetaData * getMetaData();
|
||
|
|
||
|
//enum_transaction_isolation getTransactionIsolation();
|
||
|
|
||
|
//const SQLWarning * getWarnings();
|
||
|
|
||
|
bool isReadOnly();
|
||
|
void setReadOnly( bool readOnly );
|
||
|
|
||
|
bool isValid();
|
||
|
|
||
|
bool reconnect();
|
||
|
|
||
|
//sql::PreparedStatement * prepareStatement(const sql::SQLString& sql);
|
||
|
|
||
|
//sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys);
|
||
|
|
||
|
//sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int columnIndexes[]);
|
||
|
|
||
|
//sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency);
|
||
|
|
||
|
//sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]);
|
||
|
|
||
|
//void setTransactionIsolation(enum_transaction_isolation level);
|
||
|
|
||
|
std::string getLastStatementInfo();
|
||
|
|
||
|
private:
|
||
|
MySqlBase * m_pBase;
|
||
|
MYSQL * m_pRawCon;
|
||
|
bool m_bConnected;
|
||
|
|
||
|
Connection( const Connection& );
|
||
|
void operator=( Connection& );
|
||
|
};
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif //SAPPHIRE_CONNECTION_H
|