mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
0545adfac3
Have fun!
29 lines
823 B
C++
29 lines
823 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <mysql_connection.h>
|
|
#include <cppconn/driver.h>
|
|
#include <cppconn/exception.h>
|
|
#include <cppconn/resultset.h>
|
|
#include <cppconn/statement.h>
|
|
#include <cppconn/prepared_statement.h>
|
|
#include <cppconn/sqlstring.h>
|
|
|
|
class MySqlException : public std::runtime_error {
|
|
public:
|
|
MySqlException() : std::runtime_error("MySQL error!") {}
|
|
MySqlException(const std::string& msg) : std::runtime_error(msg.c_str()) {}
|
|
};
|
|
|
|
class Database {
|
|
private:
|
|
static sql::Driver *driver;
|
|
static sql::Connection *con;
|
|
|
|
public:
|
|
static void Connect(const std::string& host, const std::string& database, const std::string& username, const std::string& password);
|
|
static void Destroy();
|
|
static sql::Statement* CreateStmt();
|
|
static sql::PreparedStatement* CreatePreppedStmt(const std::string& query);
|
|
};
|