![]() |
Banking_System_Server
1.0.0
Qt-based banking app for user/admin account management, transactions, secure server communication via PostgreSQL/Supabase.
|
Manages database connections and SQL operations. More...
#include <db.h>

Public Member Functions | |
| ~DatabaseManager () | |
| Destructor for DatabaseManager. | |
| DatabaseManager * | reset () |
| Resets the query settings. More... | |
| DatabaseManager * | select (const QString &value) |
| Selects columns for the query. More... | |
| DatabaseManager * | table (const QString &value) |
| Sets the table for the query. More... | |
| DatabaseManager * | where (const QString &value, const QVariant &val=QVariant()) |
| Adds a WHERE clause to the query. More... | |
| DatabaseManager * | like (const QString &value, const QString &val) |
| Adds a LIKE clause to the query. More... | |
| DatabaseManager * | likePost (const QString &value, const QString &val) |
| Adds a LIKE clause with a postfix wildcard to the query. More... | |
| DatabaseManager * | likeNative (const QString &value, const QString &val) |
| Adds a native LIKE clause to the query. More... | |
| DatabaseManager * | whereOr (const QString &value) |
| Adds an OR condition to the WHERE clause. More... | |
| DatabaseManager * | join (const QString &value) |
| Adds a JOIN clause to the query. More... | |
| DatabaseManager * | limit (int limit) |
| Adds a LIMIT clause to the query. More... | |
| DatabaseManager * | start (int start) |
| Adds an OFFSET clause to the query. More... | |
| DatabaseManager * | sort (const QString &sort) |
| Adds an ORDER BY clause to the query. More... | |
| DatabaseManager * | group (const QString &group) |
| Adds a GROUP BY clause to the query. More... | |
| QString | getSelectQuery (const QString &select=QString()) |
| Gets the SQL SELECT query. More... | |
| QSqlError | lastError () |
| Gets the last error occurred. More... | |
| QVariant | lastInsertedId () |
| Gets the ID of the last inserted record. More... | |
| QString | lastQuery () |
| Gets the last executed query. More... | |
| DbResult | exec () |
| Executes the built query. More... | |
| DbResult | execResult (const QString &sql) |
| Executes a SQL query. More... | |
| DbResult | get (const QString &tableName) |
| Executes a SELECT query on a specified table. More... | |
| bool | exec (const QString &sqlcommand) |
| Executes a SQL command. More... | |
| bool | insert (const QString &table, const QVariantMap &data) |
| Inserts data into a specified table. More... | |
| bool | update (const QString &table, const QVariantMap &data) |
| Updates data in a specified table. More... | |
| bool | del (const QString &table) |
| Deletes data from a specified table. More... | |
| int | count () |
| Gets the count of records matching the query criteria. More... | |
| DatabaseManager * | clone () |
| Clones the current DatabaseManager instance. More... | |
| bool | beginTransaction () |
| Begins a transaction. More... | |
| bool | commit () |
| Commits a transaction. More... | |
| bool | rollback () |
| Rolls back a transaction. More... | |
| bool | isSupportTransaction () |
| Checks if transactions are supported. More... | |
| DatabaseManager * | clearSelect () |
| Clears the SELECT clause. More... | |
| bool | truncateTable (const QString &table) |
| Truncates a specified table. More... | |
Static Public Member Functions | |
| static DatabaseManager * | createInstance (bool checkDBName=false, bool newConnection=false, QString *err=nullptr) |
| Creates an instance of DatabaseManager. More... | |
| static bool | setDbSetting (const QString &host, int port, const QString &username, const QString &password, const QString &dbname) |
| Sets the database settings. More... | |
| static bool | checkConnection (QString &error) |
| Checks the database connection. More... | |
Manages database connections and SQL operations.
This class provides methods for managing database connections, executing SQL queries, and handling transactions.
| bool DatabaseManager::beginTransaction | ( | ) |
Begins a transaction.
|
static |
Checks the database connection.
| error | Reference to store error message. |
Referenced by Request::isDBConnectionValid().


|
inline |
Clears the SELECT clause.
| DatabaseManager * DatabaseManager::clone | ( | ) |
Clones the current DatabaseManager instance.
Referenced by count().

| bool DatabaseManager::commit | ( | ) |
Commits a transaction.
| int DatabaseManager::count | ( | ) |
Gets the count of records matching the query criteria.

|
static |
Creates an instance of DatabaseManager.
| checkDBName | Flag to check database name. |
| newConnection | Flag to create a new connection. |
| err | Pointer to store error message. |
Referenced by checkConnection().


| bool DatabaseManager::del | ( | const QString & | table | ) |
Deletes data from a specified table.
| table | Name of the table. |
Referenced by DeleteUserRequest::execute(), and UpdateUserRequest::execute().


| DbResult DatabaseManager::exec | ( | ) |
Executes the built query.
Referenced by CreateNewUserRequest::execute(), DeleteUserRequest::execute(), GetAccountNumberRequest::execute(), GetBalanceRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), LoginRequest::execute(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), UpdateUserRequest::execute(), UserInitRequest::execute(), get(), and truncateTable().


| bool DatabaseManager::exec | ( | const QString & | sqlcommand | ) |
Executes a SQL command.
| sqlcommand | SQL command to execute. |

| DbResult DatabaseManager::execResult | ( | const QString & | sql | ) |
Executes a SQL query.
| sql | SQL query to execute. |

| DbResult DatabaseManager::get | ( | const QString & | tableName | ) |
Executes a SELECT query on a specified table.
| tableName | Name of the table. |

| QString DatabaseManager::getSelectQuery | ( | const QString & | select = QString() | ) |
| DatabaseManager * DatabaseManager::group | ( | const QString & | group | ) |
Adds a GROUP BY clause to the query.
| group | Grouping criteria. |
| bool DatabaseManager::insert | ( | const QString & | table, |
| const QVariantMap & | data | ||
| ) |
Inserts data into a specified table.
| table | Name of the table. |
| data | Data to insert. |
Referenced by CreateNewUserRequest::execute(), and MakeTransactionRequest::execute().


|
inline |
Checks if transactions are supported.
| DatabaseManager * DatabaseManager::join | ( | const QString & | value | ) |
Adds a JOIN clause to the query.
| value | JOIN clause. |
Referenced by GetAccountNumberRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), and MakeTransactionRequest::execute().

| QSqlError DatabaseManager::lastError | ( | ) |
Gets the last error occurred.
Referenced by createInstance().

| QVariant DatabaseManager::lastInsertedId | ( | ) |
Gets the ID of the last inserted record.
| QString DatabaseManager::lastQuery | ( | ) |
Gets the last executed query.
Referenced by exec().

| DatabaseManager * DatabaseManager::like | ( | const QString & | value, |
| const QString & | val | ||
| ) |
Adds a LIKE clause to the query.
| value | Column name. |
| val | Value for the LIKE clause. |
| DatabaseManager * DatabaseManager::likeNative | ( | const QString & | value, |
| const QString & | val | ||
| ) |
Adds a native LIKE clause to the query.
| value | Column name. |
| val | Value for the LIKE clause. |
| DatabaseManager * DatabaseManager::likePost | ( | const QString & | value, |
| const QString & | val | ||
| ) |
Adds a LIKE clause with a postfix wildcard to the query.
| value | Column name. |
| val | Value for the LIKE clause. |
| DatabaseManager * DatabaseManager::limit | ( | int | limit | ) |
Adds a LIMIT clause to the query.
| limit | Number of records to limit. |
| DatabaseManager * DatabaseManager::reset | ( | ) |
Resets the query settings.
Referenced by del(), exec(), execResult(), insert(), and update().

| bool DatabaseManager::rollback | ( | ) |
Rolls back a transaction.
| DatabaseManager * DatabaseManager::select | ( | const QString & | value | ) |
Selects columns for the query.
| value | Columns to select. |
Referenced by CreateNewUserRequest::execute(), DeleteUserRequest::execute(), GetAccountNumberRequest::execute(), GetBalanceRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), LoginRequest::execute(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), UpdateUserRequest::execute(), UserInitRequest::execute(), and getSelectQuery().

|
static |
Sets the database settings.
| host | Database host. |
| port | Database port. |
| username | Database username. |
| password | Database password. |
| dbname | Database name. |

| DatabaseManager * DatabaseManager::sort | ( | const QString & | sort | ) |
Adds an ORDER BY clause to the query.
| sort | Sorting criteria. |
| DatabaseManager * DatabaseManager::start | ( | int | start | ) |
Adds an OFFSET clause to the query.
| start | Offset value. |
| DatabaseManager * DatabaseManager::table | ( | const QString & | value | ) |
Sets the table for the query.
| value | Table name. |
Referenced by del(), CreateNewUserRequest::execute(), DeleteUserRequest::execute(), GetAccountNumberRequest::execute(), GetBalanceRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), LoginRequest::execute(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), UpdateUserRequest::execute(), UserInitRequest::execute(), get(), insert(), truncateTable(), and update().

| bool DatabaseManager::truncateTable | ( | const QString & | table | ) |
Truncates a specified table.
| table | Name of the table. |

| bool DatabaseManager::update | ( | const QString & | table, |
| const QVariantMap & | data | ||
| ) |
Updates data in a specified table.
| table | Name of the table. |
| data | Data to update. |
Referenced by del(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), and UpdateUserRequest::execute().


| DatabaseManager * DatabaseManager::where | ( | const QString & | value, |
| const QVariant & | val = QVariant() |
||
| ) |
Adds a WHERE clause to the query.
| value | Condition for the WHERE clause. |
| val | Value for the condition. |
Referenced by CreateNewUserRequest::execute(), DeleteUserRequest::execute(), GetAccountNumberRequest::execute(), GetBalanceRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), LoginRequest::execute(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), UpdateUserRequest::execute(), and UserInitRequest::execute().

| DatabaseManager * DatabaseManager::whereOr | ( | const QString & | value | ) |
Adds an OR condition to the WHERE clause.
| value | Condition for the OR clause. |
Referenced by GetTransactionsHistoryRequest::execute().
