2020-12-01 14:00:49 +01:00
|
|
|
#ifndef DATABASE_H
|
|
|
|
#define DATABASE_H
|
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
#include "core/string.h"
|
2020-12-01 21:48:13 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2021-11-01 16:57:22 +01:00
|
|
|
#include "core/reference.h"
|
|
|
|
|
2020-12-02 00:43:46 +01:00
|
|
|
class QueryBuilder;
|
|
|
|
class TableBuilder;
|
|
|
|
class QueryResult;
|
2020-12-01 14:00:49 +01:00
|
|
|
|
|
|
|
class Database {
|
|
|
|
public:
|
|
|
|
//probably needs refcount, depending on what db engines do, todo
|
2021-11-01 17:49:10 +01:00
|
|
|
//virtual QueryResult *query(const String &sql);
|
|
|
|
//virtual QueryResult *query_async(const String &sql);
|
2020-12-01 14:00:49 +01:00
|
|
|
//or
|
2021-11-01 17:49:10 +01:00
|
|
|
//virtual QueryErrorCode query(QueryResult *result, const String &sql);
|
|
|
|
//virtual QueryErrorCode query_async(QueryResult *result, const String &sql);
|
2020-12-01 14:00:49 +01:00
|
|
|
|
|
|
|
//also
|
2021-11-01 17:49:10 +01:00
|
|
|
//virtual QueryResult *query_prepared(const String &sql, param1, param2, ...);
|
2020-12-01 14:00:49 +01:00
|
|
|
|
2020-12-01 14:46:08 +01:00
|
|
|
//query interface (codeigniter 3 style)
|
|
|
|
//virtual void where(""); etc
|
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual void connect(const String &connection_str);
|
|
|
|
virtual Ref<QueryResult> query(const String &query);
|
|
|
|
virtual void query_run(const String &query);
|
2020-12-01 18:29:41 +01:00
|
|
|
|
2021-11-01 16:57:22 +01:00
|
|
|
virtual Ref<QueryBuilder> get_query_builder();
|
|
|
|
virtual Ref<TableBuilder> get_table_builder();
|
2020-12-01 21:48:13 +01:00
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual String escape(const String str);
|
|
|
|
virtual void escape(const String str, String *to);
|
2021-07-08 18:52:59 +02:00
|
|
|
|
2020-12-01 14:00:49 +01:00
|
|
|
Database();
|
|
|
|
~Database();
|
2020-12-01 21:48:13 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
//std::vector<QueryBuilder *> _builders;
|
2020-12-01 14:00:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|