Class for handling database queries.
More...
#include <DatabaseManager.hpp>
Class for handling database queries.
◆ DatabaseManager()
| DatabaseManager::DatabaseManager |
( |
| ) |
|
◆ ~DatabaseManager()
| DatabaseManager::~DatabaseManager |
( |
| ) |
|
|
default |
◆ createConnection()
| int DatabaseManager::createConnection |
( |
| ) |
|
Create connection to the database.
- Returns
- 1 if successful, 0 if not
◆ getTransaction()
| pqxx::work DatabaseManager::getTransaction |
( |
| ) |
|
|
private |
Get a transaction object.
- Returns
- pqxx::work
◆ loadEquipmentDataFromDb()
| std::vector< int > DatabaseManager::loadEquipmentDataFromDb |
( |
int |
playerId | ) |
|
Load player's equipment items from the database.
- Parameters
-
- Returns
- Player's equipment items in a vector
◆ loadInventoryDataFromDb()
| std::vector< int > DatabaseManager::loadInventoryDataFromDb |
( |
int |
playerId | ) |
|
Load player's inventory items from the database.
- Parameters
-
- Returns
- Player's inventory items in a vector
◆ loadPlayerDataFromDb()
| PlayerTable DatabaseManager::loadPlayerDataFromDb |
( |
std::string |
username, |
|
|
std::string |
password, |
|
|
Coordinates |
spawnCoordinate |
|
) |
| |
Fetches player basic data from the database (table player) by username. Creates a new player with given username to the database if it does not yet exist.
- Parameters
-
| username | |
| spawnCoordinate | The coordinate on which player is spawned. Used if the player is not found from the db. |
- Returns
- Player basic data as PlayerTable
◆ loadSkillDataFromDb()
| std::vector< std::pair< int, int > > DatabaseManager::loadSkillDataFromDb |
( |
int |
playerId | ) |
|
Load player's skill data from the database.
- Parameters
-
- Returns
- Player's skill data in a vector
◆ savePlayerToDb()
| bool DatabaseManager::savePlayerToDb |
( |
std::shared_ptr< PlayerCharacter > |
player | ) |
|
Save player's basic data, items and skills to the database.
- Parameters
-
- Returns
- True if succesful, else false
◆ pConnectionM
| std::unique_ptr<pqxx::connection> DatabaseManager::pConnectionM |
|
private |
The documentation for this class was generated from the following files: