#ifndef SAPPHIRE_CONNECTION_H #define SAPPHIRE_CONNECTION_H #include #include #include #include namespace Core { namespace Db { typedef std::map< enum mysql_option, std::string > optionMap; class MySqlBase; class Statement; class Connection { public: Connection( MySqlBase * pBase, const std::string& hostName, const std::string& userName, const std::string& password, uint16_t port = 3306); Connection( MySqlBase * pBase, const std::string& hostName, const std::string& userName, const std::string& password, const optionMap& options, uint16_t port = 3306 ); virtual ~Connection(); void close(); bool isClosed() const; 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() const; void setAutoCommit( bool autoCommit ); bool getAutoCommit(); std::string escapeString( const std::string& inData ); void setSchema( const std::string& catalog ); Statement * createStatement(); void beginTransaction(); void commitTransaction(); void rollbackTransaction(); std::string getSchema(); //DatabaseMetaData * getMetaData(); std::string getError(); 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(); MYSQL* getRawCon(); private: MySqlBase* m_pBase; MYSQL* m_pRawCon; bool m_bConnected; Connection( const Connection& ); void operator=( Connection& ); }; } } #endif //SAPPHIRE_CONNECTION_H