2020-12-01 14:00:49 +01:00
|
|
|
#ifndef DATABASE_H
|
|
|
|
#define DATABASE_H
|
|
|
|
|
|
|
|
#include <string>
|
2020-12-01 21:48:13 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2020-12-01 14:00:49 +01:00
|
|
|
enum QueryErrorCode {
|
|
|
|
OK,
|
|
|
|
ERROR
|
|
|
|
};
|
|
|
|
|
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
|
2020-12-01 14:46:08 +01:00
|
|
|
//virtual QueryResult *query(const std::string &sql);
|
|
|
|
//virtual QueryResult *query_async(const std::string &sql);
|
2020-12-01 14:00:49 +01:00
|
|
|
//or
|
2020-12-01 14:46:08 +01:00
|
|
|
//virtual QueryErrorCode query(QueryResult *result, const std::string &sql);
|
|
|
|
//virtual QueryErrorCode query_async(QueryResult *result, const std::string &sql);
|
2020-12-01 14:00:49 +01:00
|
|
|
|
|
|
|
//also
|
|
|
|
//virtual QueryResult *query_prepared(const std::string &sql, param1, param2, ...);
|
|
|
|
|
2020-12-01 14:46:08 +01:00
|
|
|
//query interface (codeigniter 3 style)
|
|
|
|
//virtual void where(""); etc
|
|
|
|
|
2020-12-01 18:29:41 +01:00
|
|
|
virtual void connect(const std::string &connection_str);
|
2020-12-02 00:43:46 +01:00
|
|
|
virtual QueryResult *query(const std::string &query);
|
|
|
|
virtual void query_run(const std::string &query);
|
2020-12-01 18:29:41 +01:00
|
|
|
|
2020-12-01 23:37:10 +01:00
|
|
|
virtual QueryBuilder *get_query_builder();
|
|
|
|
virtual TableBuilder *get_table_builder();
|
2020-12-01 21:48:13 +01: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
|