mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 21:31:10 +01:00
Added owner support for the DatabaseConnection.
This commit is contained in:
parent
be6ec3ee61
commit
42501c339f
@ -17,6 +17,11 @@ Ref<DatabaseConnection> Database::get_connection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref<DatabaseConnection> Database::_allocate_connection() {
|
Ref<DatabaseConnection> Database::_allocate_connection() {
|
||||||
|
//Ref<DatabaseConnection> dbc;
|
||||||
|
//dbc.instance();
|
||||||
|
//dbc->set_owner(this); //if needed
|
||||||
|
//return dbc;
|
||||||
|
|
||||||
return Ref<DatabaseConnection>();
|
return Ref<DatabaseConnection>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,16 @@ String DatabaseConnection::escape(const String &str) {
|
|||||||
void DatabaseConnection::escape_to(const String &str, String *to) {
|
void DatabaseConnection::escape_to(const String &str, String *to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<Database> DatabaseConnection::get_owner() {
|
||||||
|
return Ref<Database>(_owner);
|
||||||
|
}
|
||||||
|
|
||||||
DatabaseConnection::DatabaseConnection() {
|
DatabaseConnection::DatabaseConnection() {
|
||||||
|
_owner = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseConnection::~DatabaseConnection() {
|
DatabaseConnection::~DatabaseConnection() {
|
||||||
|
_owner = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseConnection::_bind_methods() {
|
void DatabaseConnection::_bind_methods() {
|
||||||
@ -42,4 +48,5 @@ void DatabaseConnection::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_query_builder"), &DatabaseConnection::get_query_builder);
|
ClassDB::bind_method(D_METHOD("get_query_builder"), &DatabaseConnection::get_query_builder);
|
||||||
ClassDB::bind_method(D_METHOD("get_table_builder"), &DatabaseConnection::get_table_builder);
|
ClassDB::bind_method(D_METHOD("get_table_builder"), &DatabaseConnection::get_table_builder);
|
||||||
ClassDB::bind_method(D_METHOD("escape", "str"), &DatabaseConnection::escape);
|
ClassDB::bind_method(D_METHOD("escape", "str"), &DatabaseConnection::escape);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_owner"), &DatabaseConnection::get_owner);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
class QueryBuilder;
|
class QueryBuilder;
|
||||||
class TableBuilder;
|
class TableBuilder;
|
||||||
class QueryResult;
|
class QueryResult;
|
||||||
|
class Database;
|
||||||
|
|
||||||
class DatabaseConnection : public Reference {
|
class DatabaseConnection : public Reference {
|
||||||
GDCLASS(DatabaseConnection, Reference);
|
GDCLASS(DatabaseConnection, Reference);
|
||||||
@ -23,11 +24,18 @@ public:
|
|||||||
virtual String escape(const String &str);
|
virtual String escape(const String &str);
|
||||||
virtual void escape_to(const String &str, String *to);
|
virtual void escape_to(const String &str, String *to);
|
||||||
|
|
||||||
|
Ref<Database> get_owner();
|
||||||
|
void set_owner(Database *owner);
|
||||||
|
|
||||||
DatabaseConnection();
|
DatabaseConnection();
|
||||||
~DatabaseConnection();
|
~DatabaseConnection();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
//"WeakRef"
|
||||||
|
//Note: Set this to null if the owner Database gets destroyed!
|
||||||
|
Database *_owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user