mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
* Add database quest API API functions are named to be similar to LuaSQL and perl DBI New connections are made for Database objects. These can either use credentials from the server eqemu_config or manual connections. * Add option to use zone db connections
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#ifdef LUA_EQEMU
|
|
|
|
#include "quest_db.h"
|
|
#include "../common/mysql_stmt.h"
|
|
#include <luabind/object.hpp>
|
|
|
|
namespace luabind { struct scope; }
|
|
luabind::scope lua_register_database();
|
|
|
|
class Lua_MySQLPreparedStmt;
|
|
|
|
class Lua_Database : public QuestDB
|
|
{
|
|
public:
|
|
using QuestDB::QuestDB;
|
|
|
|
void Close();
|
|
Lua_MySQLPreparedStmt* Prepare(lua_State*, std::string query);
|
|
};
|
|
|
|
class Lua_MySQLPreparedStmt
|
|
{
|
|
public:
|
|
Lua_MySQLPreparedStmt(lua_State* L, mysql::PreparedStmt&& stmt)
|
|
: m_stmt(std::make_unique<mysql::PreparedStmt>(std::move(stmt)))
|
|
, m_row_array(luabind::newtable(L))
|
|
, m_row_hash(luabind::newtable(L)) {}
|
|
|
|
void Close();
|
|
void Execute(lua_State*);
|
|
void Execute(lua_State*, luabind::object args);
|
|
void SetOptions(luabind::object table_opts);
|
|
luabind::object FetchArray(lua_State*);
|
|
luabind::object FetchHash(lua_State*);
|
|
|
|
// StmtResult functions accessible through this class to simplify api
|
|
int ColumnCount();
|
|
uint64_t LastInsertID();
|
|
uint64_t RowCount();
|
|
uint64_t RowsAffected();
|
|
|
|
private:
|
|
std::unique_ptr<mysql::PreparedStmt> m_stmt;
|
|
mysql::StmtResult m_res = {};
|
|
luabind::object m_row_array; // perf: table cache for fetches
|
|
luabind::object m_row_hash;
|
|
};
|
|
|
|
#endif // LUA_EQEMU
|