2016-06-03 20:33:21 +02:00
|
|
|
#ifndef _SQMYSQL_HANDLE_CONNECTION_HPP_
|
|
|
|
#define _SQMYSQL_HANDLE_CONNECTION_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Common.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
* The structure that holds the data associated with a certain connection.
|
2016-06-03 20:33:21 +02:00
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
struct ConnHnd
|
2016-06-03 20:33:21 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
typedef MYSQL Type; // The managed type.
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
typedef Type* Pointer; // Pointer to the managed type.
|
|
|
|
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
typedef Type& Reference; // Reference to the managed type.
|
|
|
|
typedef const Type& ConstRef; // Constant reference to the managed type.
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
typedef MYSQL_RES ResType; // Database result type.
|
|
|
|
|
2016-06-28 00:15:31 +02:00
|
|
|
public:
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
Pointer mPtr; // The connection handle resource.
|
2016-06-03 20:33:21 +02:00
|
|
|
|
2016-06-28 00:15:31 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Uint32 mErrNo; // Last received error string.
|
|
|
|
String mErrStr; // Last received error message.
|
2016-06-03 20:33:21 +02:00
|
|
|
|
2016-06-28 00:15:31 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Uint16 mPort; // Server port.
|
|
|
|
String mHost; // Host address.
|
|
|
|
String mUser; // User name user.
|
|
|
|
String mPass; // User password.
|
|
|
|
String mName; // Database name.
|
|
|
|
String mSocket; // Unix socket.
|
|
|
|
Ulong mFlags; // Client flags.
|
2016-06-03 20:33:21 +02:00
|
|
|
|
2016-06-28 00:15:31 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
String mSSL_Key; // SSL key.
|
|
|
|
String mSSL_Cert; // SSL certificate.
|
|
|
|
String mSSL_CA; // SSL certificate authority.
|
|
|
|
String mSSL_CA_Path; // SSL certificate authority path.
|
|
|
|
String mSSL_Cipher; // SSL Cipher.
|
2016-06-03 20:33:21 +02:00
|
|
|
|
2016-06-28 00:15:31 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
String mCharset; // Default connection character set.
|
2016-06-03 20:33:21 +02:00
|
|
|
|
2016-06-28 00:15:31 +02:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
bool mAutoCommit; // Whether autocommit is enabled on this connection.
|
|
|
|
bool mInTransaction; // Whether the connection is in the middle of a transaction.
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
* Default constructor.
|
2016-06-03 20:33:21 +02:00
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
ConnHnd();
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destructor.
|
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
~ConnHnd();
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
* Grab the current error in the connection handle.
|
2016-06-03 20:33:21 +02:00
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
void GrabCurrent();
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
* Grab the current error in the connection handle and throw it.
|
2016-06-03 20:33:21 +02:00
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
void ThrowCurrent(CCStr act, CCStr file, Int32 line);
|
|
|
|
#else
|
|
|
|
void ThrowCurrent(CCStr act);
|
|
|
|
#endif // _DEBUG
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
* Create the connection handle.
|
2016-06-03 20:33:21 +02:00
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
void Create(const Account & acc);
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
* Disconnect the managed connection handle.
|
2016-06-03 20:33:21 +02:00
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
void Disconnect();
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
* Execute a query on the server.
|
2016-06-03 20:33:21 +02:00
|
|
|
*/
|
2016-06-28 00:15:31 +02:00
|
|
|
Uint64 Execute(CSStr query, Ulong size = 0UL);
|
2016-06-03 20:33:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _SQMYSQL_HANDLE_CONNECTION_HPP_
|