diff options
| author | Sadie Powell <sadie@witchery.services> | 2024-11-11 10:42:57 +0000 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2024-11-11 10:44:20 +0000 |
| commit | 9411dac991de7361669621167ebc2968969ab24f (patch) | |
| tree | ed7248a1495310bbe84f23dd7f5d73a0b5b12a97 /modules/database/db_sql.cpp | |
| parent | aa32f7c9266368f1d669e646e40f4b7b3fd53bb5 (diff) | |
Add a helper function to db_sql(_live) for getting a table name.
Diffstat (limited to 'modules/database/db_sql.cpp')
| -rw-r--r-- | modules/database/db_sql.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index d8fe89972..22b617d9f 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -72,6 +72,11 @@ class DBSQL final bool loaded = false; bool imported = false; + Anope::string GetTableName(Serialize::Type *s_type) + { + return this->prefix + s_type->GetName(); + } + void RunBackground(const Query &q, Interface *iface = NULL) { if (!this->sql) @@ -124,8 +129,8 @@ public: if (!s_type) continue; - std::vector<Query> create = this->sql->CreateTable(this->prefix + s_type->GetName(), data); - Query insert = this->sql->BuildInsert(this->prefix + s_type->GetName(), obj->id, data); + auto create = this->sql->CreateTable(GetTableName(s_type), data); + auto insert = this->sql->BuildInsert(GetTableName(s_type), obj->id, data); if (this->imported) { @@ -209,7 +214,7 @@ public: return; Serialize::Type *s_type = obj->GetSerializableType(); if (s_type && obj->id > 0) - this->RunBackground("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + Anope::ToString(obj->id)); + this->RunBackground("DELETE FROM `" + GetTableName(s_type) + "` WHERE `id` = " + Anope::ToString(obj->id)); this->updated_items.erase(obj); } @@ -229,7 +234,7 @@ public: if (!this->loading_databases && !this->loaded) return; - Query query("SELECT * FROM `" + this->prefix + sb->GetName() + "`"); + Query query("SELECT * FROM `" + GetTableName(sb) + "`"); Result res = this->sql->RunQuery(query); for (int j = 0; j < res.Rows(); ++j) |
