2022-06-30 13:23:48 +02:00
|
|
|
#ifndef DATABASE_H
|
|
|
|
#define DATABASE_H
|
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
#include "core/ustring.h"
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
#include "core/reference.h"
|
|
|
|
|
|
|
|
class QueryBuilder;
|
|
|
|
class TableBuilder;
|
|
|
|
class QueryResult;
|
|
|
|
|
2022-07-06 09:30:50 +02:00
|
|
|
class DatabaseConnection : public Reference {
|
|
|
|
GDCLASS(DatabaseConnection, Reference);
|
2022-07-06 09:17:49 +02:00
|
|
|
|
2022-06-30 13:23:48 +02:00
|
|
|
public:
|
|
|
|
virtual void connect(const String &connection_str);
|
|
|
|
virtual Ref<QueryResult> query(const String &query);
|
|
|
|
virtual void query_run(const String &query);
|
|
|
|
|
|
|
|
virtual Ref<QueryBuilder> get_query_builder();
|
|
|
|
virtual Ref<TableBuilder> get_table_builder();
|
|
|
|
|
2022-07-06 09:17:49 +02:00
|
|
|
virtual String escape(const String &str);
|
|
|
|
virtual void escape_to(const String &str, String *to);
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-06 09:30:50 +02:00
|
|
|
DatabaseConnection();
|
|
|
|
~DatabaseConnection();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
};
|
|
|
|
|
|
|
|
class Database : public Reference {
|
|
|
|
GDCLASS(Database, Reference);
|
|
|
|
|
|
|
|
public:
|
|
|
|
String get_connection_string();
|
|
|
|
void set_connection_string(const String &val);
|
|
|
|
|
|
|
|
virtual Ref<DatabaseConnection> get_connection();
|
|
|
|
|
2022-06-30 13:23:48 +02:00
|
|
|
Database();
|
|
|
|
~Database();
|
2022-07-06 09:17:49 +02:00
|
|
|
|
|
|
|
protected:
|
2022-07-06 09:30:50 +02:00
|
|
|
virtual Ref<DatabaseConnection> _allocate_connection();
|
|
|
|
|
2022-07-06 09:17:49 +02:00
|
|
|
static void _bind_methods();
|
2022-07-06 09:30:50 +02:00
|
|
|
|
|
|
|
String _connection_string;
|
2022-06-30 13:23:48 +02:00
|
|
|
};
|
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
#endif
|