mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 04:46:48 +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> dbc;
|
||||
//dbc.instance();
|
||||
//dbc->set_owner(this); //if needed
|
||||
//return dbc;
|
||||
|
||||
return Ref<DatabaseConnection>();
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,16 @@ String DatabaseConnection::escape(const String &str) {
|
||||
void DatabaseConnection::escape_to(const String &str, String *to) {
|
||||
}
|
||||
|
||||
Ref<Database> DatabaseConnection::get_owner() {
|
||||
return Ref<Database>(_owner);
|
||||
}
|
||||
|
||||
DatabaseConnection::DatabaseConnection() {
|
||||
_owner = nullptr;
|
||||
}
|
||||
|
||||
DatabaseConnection::~DatabaseConnection() {
|
||||
_owner = nullptr;
|
||||
}
|
||||
|
||||
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_table_builder"), &DatabaseConnection::get_table_builder);
|
||||
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 TableBuilder;
|
||||
class QueryResult;
|
||||
class Database;
|
||||
|
||||
class DatabaseConnection : public Reference {
|
||||
GDCLASS(DatabaseConnection, Reference);
|
||||
@ -23,11 +24,18 @@ public:
|
||||
virtual String escape(const String &str);
|
||||
virtual void escape_to(const String &str, String *to);
|
||||
|
||||
Ref<Database> get_owner();
|
||||
void set_owner(Database *owner);
|
||||
|
||||
DatabaseConnection();
|
||||
~DatabaseConnection();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//"WeakRef"
|
||||
//Note: Set this to null if the owner Database gets destroyed!
|
||||
Database *_owner;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user