This class is responsible for handling the database connections as well as executing queries and handling any results. More...
#include <dbconn.hpp>
Public Member Functions | |
| dbconn (const config &c) | |
| Initializes the synchronous query connection as well as the account object that has the connection settings. More... | |
| int | async_test_query (int limit) |
| std::string | get_uuid () |
| std::string | get_tournaments () |
| std::unique_ptr< simple_wml::document > | get_game_history (int player_id, int offset, std::string search_game_name, int search_content_type, std::string search_content) |
| This is an asynchronous query that is executed on a separate connection to retrieve the game history for the provided player. More... | |
| bool | user_exists (const std::string &name) |
| long | get_forum_id (const std::string &name) |
| bool | extra_row_exists (const std::string &name) |
| bool | is_user_in_groups (const std::string &name, const std::vector< int > &group_ids) |
| std::string | get_user_string (const std::string &table, const std::string &column, const std::string &name) |
| int | get_user_int (const std::string &table, const std::string &column, const std::string &name) |
| void | write_user_int (const std::string &column, const std::string &name, int value) |
| The provided value is updated if a row exists or a new row inserted otherwise. More... | |
| config | get_ban_info (const std::string &name, const std::string &ip) |
| void | insert_game_info (const std::string &uuid, int game_id, const std::string &version, const std::string &name, int reload, int observers, int is_public, int has_password) |
| void | update_game_end (const std::string &uuid, int game_id, const std::string &replay_location) |
| void | insert_game_player_info (const std::string &uuid, int game_id, const std::string &username, int side_number, int is_host, const std::string &faction, const std::string &version, const std::string &source, const std::string ¤t_user, const std::string &leaders) |
| unsigned long long | insert_game_content_info (const std::string &uuid, int game_id, const std::string &type, const std::string &name, const std::string &id, const std::string &addon_id, const std::string &addon_version) |
| void | set_oos_flag (const std::string &uuid, int game_id) |
| bool | topic_id_exists (int topic_id) |
| void | insert_addon_info (const std::string &instance_version, const std::string &id, const std::string &name, const std::string &type, const std::string &version, bool forum_auth, int topic_id, const std::string &uploader) |
| unsigned long long | insert_login (const std::string &username, const std::string &ip, const std::string &version) |
| void | update_logout (unsigned long long login_id) |
| void | get_users_for_ip (const std::string &ip, std::ostringstream *out) |
| void | get_ips_for_user (const std::string &username, std::ostringstream *out) |
| void | update_addon_download_count (const std::string &instance_version, const std::string &id, const std::string &version) |
| bool | is_user_author (const std::string &instance_version, const std::string &id, const std::string &username, int is_primary) |
| void | delete_addon_authors (const std::string &instance_version, const std::string &id) |
| void | insert_addon_author (const std::string &instance_version, const std::string &id, const std::string &author, int is_primary) |
| bool | do_any_authors_exist (const std::string &instance_version, const std::string &id) |
| config | get_addon_downloads_info (const std::string &instance_version, const std::string &id) |
| config | get_forum_auth_usage (const std::string &instance_version) |
| config | get_addon_admins (int site_admin_group, int forum_admin_group) |
Private Member Functions | |
| void | log_sql_exception (const std::string &text, const mariadb::exception::base &e) |
| This is used to write out error text when an SQL-related exception occurs. More... | |
| mariadb::connection_ref | create_connection () |
| Creates a new connection object from the account. More... | |
| template<typename F > | |
| config | get_complex_results (const mariadb::connection_ref &connection, F *handler, const std::string &sql, const sql_parameters ¶ms) |
| std::string | get_single_string (const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms) |
| long | get_single_long (const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms) |
| bool | exists (const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms) |
| mariadb::result_set_ref | select (const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms) |
| Executes a select statement. More... | |
| unsigned long long | modify (const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms) |
| Executes non-select statements (ie: insert, update, delete). More... | |
| unsigned long long | modify_get_id (const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms) |
| Executes non-select statements (ie: insert, update, delete), but primarily intended for inserts that return a generated ID. More... | |
| mariadb::statement_ref | query (const mariadb::connection_ref &connection, const std::string &sql, const sql_parameters ¶ms) |
| For a given connection, set the provided SQL and parameters on a statement. More... | |
Private Attributes | |
| mariadb::account_ref | account_ |
| The account used to connect to the database. More... | |
| mariadb::connection_ref | connection_ |
| The actual connection to the database. More... | |
| std::string | db_users_table_ |
| The name of the table that contains forum user information. More... | |
| std::string | db_banlist_table_ |
| The name of the table that contains forum ban information. More... | |
| std::string | db_extra_table_ |
| The name of the table that contains additional user information. More... | |
| std::string | db_game_info_table_ |
| The name of the table that contains game-level information. More... | |
| std::string | db_game_player_info_table_ |
| The name of the table that contains player-level information per game. More... | |
| std::string | db_game_content_info_table_ |
| The name of the table that contains game content information. More... | |
| std::string | db_user_group_table_ |
| The name of the table that contains forum group information. More... | |
| std::string | db_tournament_query_ |
| The text of the SQL query to use to retrieve any currently active tournaments. More... | |
| std::string | db_topics_table_ |
| The name of the table that contains phpbb forum thread information. More... | |
| std::string | db_addon_info_table_ |
| The name of the table that contains add-on information. More... | |
| std::string | db_connection_history_table_ |
| The name of the table that contains user connection history. More... | |
| std::string | db_addon_authors_table_ |
| The name of the table that contains the add-on authors information. More... | |
This class is responsible for handling the database connections as well as executing queries and handling any results.
Definition at line 38 of file dbconn.hpp.
| dbconn::dbconn | ( | const config & | c | ) |
Initializes the synchronous query connection as well as the account object that has the connection settings.
| c | The config object to read information from. |
| int dbconn::async_test_query | ( | int | limit | ) |
|
private |
Creates a new connection object from the account.
| void dbconn::delete_addon_authors | ( | const std::string & | instance_version, |
| const std::string & | id | ||
| ) |
| bool dbconn::do_any_authors_exist | ( | const std::string & | instance_version, |
| const std::string & | id | ||
| ) |
|
private |
| connection | The database connection that will be used to execute the query. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
| bool dbconn::extra_row_exists | ( | const std::string & | name | ) |
| name | The player's username. |
| config dbconn::get_addon_admins | ( | int | site_admin_group, |
| int | forum_admin_group | ||
| ) |
| config dbconn::get_addon_downloads_info | ( | const std::string & | instance_version, |
| const std::string & | id | ||
| ) |
| config dbconn::get_ban_info | ( | const std::string & | name, |
| const std::string & | ip | ||
| ) |
|
private |
| connection | The database connection that will be used to execute the query. |
| handler | The lambda that will handle reading the results into a config. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
| config dbconn::get_forum_auth_usage | ( | const std::string & | instance_version | ) |
| long dbconn::get_forum_id | ( | const std::string & | name | ) |
| std::unique_ptr<simple_wml::document> dbconn::get_game_history | ( | int | player_id, |
| int | offset, | ||
| std::string | search_game_name, | ||
| int | search_content_type, | ||
| std::string | search_content | ||
| ) |
This is an asynchronous query that is executed on a separate connection to retrieve the game history for the provided player.
| player_id | The forum ID of the player to get the game history for. |
| offset | The offset to provide to the database for where to start returning rows from. |
| search_game_name | Query for games matching this name. Supports leading and/or trailing wildcards. |
| search_content_type | The content type to query for (ie: scenario) |
| search_content | Query for games using this content ID. Supports leading and/or trailing wildcards. |
| void dbconn::get_ips_for_user | ( | const std::string & | username, |
| std::ostringstream * | out | ||
| ) |
|
private |
| connection | The database connection that will be used to execute the query. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
| mariadb::exception::base | when the query finds no value to be retrieved. |
|
private |
| connection | The database connection that will be used to execute the query. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
| mariadb::exception::base | when the query finds no value to be retrieved. |
| std::string dbconn::get_tournaments | ( | ) |
| int dbconn::get_user_int | ( | const std::string & | table, |
| const std::string & | column, | ||
| const std::string & | name | ||
| ) |
| table | The table that will be queried. |
| column | The column that will be selected. |
| name | The player's username. |
| std::string dbconn::get_user_string | ( | const std::string & | table, |
| const std::string & | column, | ||
| const std::string & | name | ||
| ) |
| table | The table that will be queried. |
| column | The column that will be selected. |
| name | The player's username. |
| void dbconn::get_users_for_ip | ( | const std::string & | ip, |
| std::ostringstream * | out | ||
| ) |
| std::string dbconn::get_uuid | ( | ) |
| void dbconn::insert_addon_author | ( | const std::string & | instance_version, |
| const std::string & | id, | ||
| const std::string & | author, | ||
| int | is_primary | ||
| ) |
| void dbconn::insert_addon_info | ( | const std::string & | instance_version, |
| const std::string & | id, | ||
| const std::string & | name, | ||
| const std::string & | type, | ||
| const std::string & | version, | ||
| bool | forum_auth, | ||
| int | topic_id, | ||
| const std::string & | uploader | ||
| ) |
| unsigned long long dbconn::insert_game_content_info | ( | const std::string & | uuid, |
| int | game_id, | ||
| const std::string & | type, | ||
| const std::string & | name, | ||
| const std::string & | id, | ||
| const std::string & | addon_id, | ||
| const std::string & | addon_version | ||
| ) |
| void dbconn::insert_game_info | ( | const std::string & | uuid, |
| int | game_id, | ||
| const std::string & | version, | ||
| const std::string & | name, | ||
| int | reload, | ||
| int | observers, | ||
| int | is_public, | ||
| int | has_password | ||
| ) |
| void dbconn::insert_game_player_info | ( | const std::string & | uuid, |
| int | game_id, | ||
| const std::string & | username, | ||
| int | side_number, | ||
| int | is_host, | ||
| const std::string & | faction, | ||
| const std::string & | version, | ||
| const std::string & | source, | ||
| const std::string & | current_user, | ||
| const std::string & | leaders | ||
| ) |
| unsigned long long dbconn::insert_login | ( | const std::string & | username, |
| const std::string & | ip, | ||
| const std::string & | version | ||
| ) |
| bool dbconn::is_user_author | ( | const std::string & | instance_version, |
| const std::string & | id, | ||
| const std::string & | username, | ||
| int | is_primary | ||
| ) |
| bool dbconn::is_user_in_groups | ( | const std::string & | name, |
| const std::vector< int > & | group_ids | ||
| ) |
| name | The player's username. |
| group_ids | The forum group IDs to check if the user is part of. |
|
private |
This is used to write out error text when an SQL-related exception occurs.
| text | Some custom text to log. |
| e | The exception that occurred which has information about what went wrong. |
|
private |
Executes non-select statements (ie: insert, update, delete).
| connection | The database connection that will be used to execute the query. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
|
private |
Executes non-select statements (ie: insert, update, delete), but primarily intended for inserts that return a generated ID.
| connection | The database connection that will be used to execute the query. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
|
private |
For a given connection, set the provided SQL and parameters on a statement.
| connection | The database connection that will be used to execute the query. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
|
private |
Executes a select statement.
| connection | The database connection that will be used to execute the query. |
| sql | The SQL text to be executed. |
| params | The parameterized values to be inserted into the query. |
| void dbconn::set_oos_flag | ( | const std::string & | uuid, |
| int | game_id | ||
| ) |
| bool dbconn::topic_id_exists | ( | int | topic_id | ) |
| void dbconn::update_addon_download_count | ( | const std::string & | instance_version, |
| const std::string & | id, | ||
| const std::string & | version | ||
| ) |
| void dbconn::update_game_end | ( | const std::string & | uuid, |
| int | game_id, | ||
| const std::string & | replay_location | ||
| ) |
| void dbconn::update_logout | ( | unsigned long long | login_id | ) |
| bool dbconn::user_exists | ( | const std::string & | name | ) |
| void dbconn::write_user_int | ( | const std::string & | column, |
| const std::string & | name, | ||
| int | value | ||
| ) |
The provided value is updated if a row exists or a new row inserted otherwise.
| column | The column that the value will be put into. |
| name | The player's username. |
| value | The value to be put into the column. |
|
private |
The account used to connect to the database.
Also contains the connection settings.
Definition at line 269 of file dbconn.hpp.
|
private |
The actual connection to the database.
Definition at line 271 of file dbconn.hpp.
|
private |
The name of the table that contains the add-on authors information.
Definition at line 296 of file dbconn.hpp.
|
private |
The name of the table that contains add-on information.
Definition at line 292 of file dbconn.hpp.
|
private |
The name of the table that contains forum ban information.
Definition at line 276 of file dbconn.hpp.
|
private |
The name of the table that contains user connection history.
Definition at line 294 of file dbconn.hpp.
|
private |
The name of the table that contains additional user information.
Definition at line 278 of file dbconn.hpp.
|
private |
The name of the table that contains game content information.
Definition at line 284 of file dbconn.hpp.
|
private |
The name of the table that contains game-level information.
Definition at line 280 of file dbconn.hpp.
|
private |
The name of the table that contains player-level information per game.
Definition at line 282 of file dbconn.hpp.
|
private |
The name of the table that contains phpbb forum thread information.
Definition at line 290 of file dbconn.hpp.
|
private |
The text of the SQL query to use to retrieve any currently active tournaments.
Definition at line 288 of file dbconn.hpp.
|
private |
The name of the table that contains forum group information.
Definition at line 286 of file dbconn.hpp.
|
private |
The name of the table that contains forum user information.
Definition at line 274 of file dbconn.hpp.