Otclient  14/8/2020
DatabaseMySQL Class Reference

#include <mysql.h>

Inheritance diagram for DatabaseMySQL:
Collaboration diagram for DatabaseMySQL:

Public Member Functions

 DatabaseMySQL ()
 
virtual ~DatabaseMySQL ()
 
virtual void connect (const std::string &host, const std::string &user, const std::string &pass, const std::string &db, uint16 port, const std::string &unix_socket="")
 
virtual bool beginTransaction ()
 
virtual bool rollback ()
 
virtual bool commit ()
 
virtual bool executeQuery (const std::string &query)
 
virtual DBResultPtr storeQuery (const std::string &query)
 
virtual std::string escapeString (const std::string &s)
 
virtual std::string escapeBlob (const char *s, uint32 length)
 
virtual uint64 getLastInsertedRowID ()
 
virtual Fw::DatabaseEngine getDatabaseEngine ()
 
- Public Member Functions inherited from Database
 Database ()
 
virtual ~Database ()
 
virtual std::string getStringComparer ()
 
virtual std::string getUpdateLimiter ()
 
bool isConnected ()
 
- Public Member Functions inherited from LuaObject
 LuaObject ()
 
virtual ~LuaObject ()
 
template<typename T >
void connectLuaField (const std::string &field, const std::function< T > &f, bool pushFront=false)
 
template<typename... T>
int luaCallLuaField (const std::string &field, const T &... args)
 
template<typename R , typename... T>
callLuaField (const std::string &field, const T &... args)
 
template<typename... T>
void callLuaField (const std::string &field, const T &... args)
 
bool hasLuaField (const std::string &field)
 Returns true if the lua field exists. More...
 
template<typename T >
void setLuaField (const std::string &key, const T &value)
 Sets a field in this lua object. More...
 
template<typename T >
getLuaField (const std::string &key)
 Gets a field from this lua object. More...
 
void releaseLuaFieldsTable ()
 Release fields table reference. More...
 
void luaSetField (const std::string &key)
 Sets a field from this lua object, the value must be on the stack. More...
 
void luaGetField (const std::string &key)
 Gets a field from this lua object, the result is pushed onto the stack. More...
 
void luaGetMetatable ()
 Get object's metatable. More...
 
void luaGetFieldsTable ()
 Gets the table containing all stored fields of this lua object, the result is pushed onto the stack. More...
 
int getUseCount ()
 
std::string getClassName ()
 Returns the derived class name, its the same name used in Lua. More...
 
LuaObjectPtr asLuaObject ()
 
void operator= (const LuaObject &)
 
- Public Member Functions inherited from stdext::shared_object
 shared_object ()
 
virtual ~shared_object ()
 
void add_ref ()
 
void dec_ref ()
 
refcount_t ref_count ()
 
template<typename T >
stdext::shared_object_ptr< T > static_self_cast ()
 
template<typename T >
stdext::shared_object_ptr< T > dynamic_self_cast ()
 
template<typename T >
stdext::shared_object_ptr< T > const_self_cast ()
 

Protected Member Functions

bool handleError ()
 
bool internalExecuteQuery (const std::string &query)
 
- Protected Member Functions inherited from Database
void setConnected (bool connected)
 
DBResultPtr verifyResult (DBResultPtr result)
 

Protected Attributes

MYSQL * m_handle
 
- Protected Attributes inherited from Database
ticks_t m_use
 
bool m_connected
 

Detailed Description

Definition at line 36 of file mysql.h.

Constructor & Destructor Documentation

◆ DatabaseMySQL()

DatabaseMySQL::DatabaseMySQL ( )

Definition at line 29 of file mysql.cpp.

Here is the call graph for this function:

◆ ~DatabaseMySQL()

DatabaseMySQL::~DatabaseMySQL ( )
virtual

Definition at line 40 of file mysql.cpp.

Member Function Documentation

◆ beginTransaction()

bool DatabaseMySQL::beginTransaction ( )
virtual

Transaction related methods.

Methods for starting, commiting and rolling back transaction. Each of the returns boolean value.

Returns
true on success, false on error
Note
#include <ctime> If your database system doesn't support transactions you should return true - it's not feature test, code should work without transaction, just will lack integrity.

Reimplemented from Database.

Definition at line 95 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ commit()

bool DatabaseMySQL::commit ( )
virtual

Reimplemented from Database.

Definition at line 110 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect()

void DatabaseMySQL::connect ( const std::string &  host,
const std::string &  user,
const std::string &  pass,
const std::string &  db,
uint16  port,
const std::string &  unix_socket = "" 
)
virtual

Database connector.

Connects the database to the source host.

Reimplemented from Database.

Definition at line 46 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ escapeBlob()

std::string DatabaseMySQL::escapeBlob ( const char *  ,
uint32   
)
virtual

Escapes binary stream for query.

Prepares binary stream to fit SQL queries.

Parameters
char*binary stream
longstream length
Returns
quoted string

Reimplemented from Database.

Definition at line 181 of file mysql.cpp.

Here is the caller graph for this function:

◆ escapeString()

std::string DatabaseMySQL::escapeString ( const std::string &  )
virtual

Escapes string for query.

Prepares string to fit SQL queries including quoting it.

Parameters
std::stringstring to be escaped
Returns
quoted string

Reimplemented from Database.

Definition at line 176 of file mysql.cpp.

Here is the call graph for this function:

◆ executeQuery()

bool DatabaseMySQL::executeQuery ( const std::string &  query)
virtual

Executes command.

Executes query which doesn't generates results (eg. INSERT, UPDATE, DELETE...).

Parameters
std::stringquery command
Returns
true on success, false on error

Reimplemented from Database.

Definition at line 131 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDatabaseEngine()

virtual Fw::DatabaseEngine DatabaseMySQL::getDatabaseEngine ( )
inlinevirtual

Get database engine

Returns
the database engine type

Reimplemented from Database.

Definition at line 56 of file mysql.h.

◆ getLastInsertedRowID()

uint64 DatabaseMySQL::getLastInsertedRowID ( )
virtual

Retrieve id of last inserted row

Returns
id on success, 0 if last query did not result on any rows with auto_increment keys

Reimplemented from Database.

Definition at line 171 of file mysql.cpp.

◆ handleError()

bool DatabaseMySQL::handleError ( )
protectedvirtual

Reimplemented from Database.

Definition at line 63 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ internalExecuteQuery()

bool DatabaseMySQL::internalExecuteQuery ( const std::string &  query)
protectedvirtual

Reimplemented from Database.

Definition at line 120 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rollback()

bool DatabaseMySQL::rollback ( )
virtual

Reimplemented from Database.

Definition at line 100 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storeQuery()

DBResultPtr DatabaseMySQL::storeQuery ( const std::string &  query)
virtual

Queries database.

Executes query which generates results (mostly SELECT).

Parameters
std::stringquery
Returns
results object (null on error)

Reimplemented from Database.

Definition at line 148 of file mysql.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_handle

MYSQL* DatabaseMySQL::m_handle
protected

Definition at line 62 of file mysql.h.


The documentation for this class was generated from the following files: