summaryrefslogtreecommitdiff
path: root/modules/database/db_sql.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-10-01 18:50:29 -0400
committerAdam <Adam@anope.org>2012-10-01 18:50:29 -0400
commita434baed9154d90ad0dfd31c71a463fb8300bfd8 (patch)
tree587b81c85c8abd676bb6fe1897415017a6d3f85a /modules/database/db_sql.cpp
parentf14a3dfb8a4cc9da7b5066ac8320265d54dba177 (diff)
Allow modules to store data in their own databases.
Diffstat (limited to 'modules/database/db_sql.cpp')
-rw-r--r--modules/database/db_sql.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp
index c07bdaa59..acc59b668 100644
--- a/modules/database/db_sql.cpp
+++ b/modules/database/db_sql.cpp
@@ -105,13 +105,17 @@ class DBSQL : public Module, public Pipe
continue;
obj->UpdateCache();
+ SerializeType *s_type = obj->GetSerializableType();
+ if (!s_type)
+ continue;
+
Serialize::Data data = obj->serialize();
- std::vector<SQLQuery> create = this->sql->CreateTable(this->prefix + obj->serialize_name(), data);
+ std::vector<SQLQuery> create = this->sql->CreateTable(this->prefix + s_type->GetName(), data);
for (unsigned i = 0; i < create.size(); ++i)
this->RunBackground(create[i]);
- SQLQuery insert = this->sql->BuildInsert(this->prefix + obj->serialize_name(), obj->id, data);
+ SQLQuery insert = this->sql->BuildInsert(this->prefix + s_type->GetName(), obj->id, data);
this->RunBackground(insert, new ResultSQLSQLInterface(this, obj));
}
}
@@ -188,7 +192,9 @@ class DBSQL : public Module, public Pipe
void OnSerializableDestruct(Serializable *obj) anope_override
{
- this->RunBackground("DELETE FROM `" + this->prefix + obj->serialize_name() + "` WHERE `id` = " + stringify(obj->id));
+ SerializeType *s_type = obj->GetSerializableType();
+ if (s_type)
+ this->RunBackground("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
}
void OnSerializableUpdate(Serializable *obj) anope_override