2021-05-01 20:31:52 +02:00
|
|
|
#ifndef MYSQL_QUERY_RESULT_H
|
|
|
|
#define MYSQL_QUERY_RESULT_H
|
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
#include "core/string.h"
|
2021-05-01 21:53:01 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2022-02-05 15:57:40 +01:00
|
|
|
#include "database/query_result.h"
|
2021-05-01 20:31:52 +02:00
|
|
|
|
2021-05-01 23:35:37 +02:00
|
|
|
#include "./sqlite/sqlite3.h"
|
2021-05-01 20:31:52 +02:00
|
|
|
|
|
|
|
class Sqlite3QueryResult : public QueryResult {
|
2022-01-08 10:04:12 +01:00
|
|
|
RCPP_OBJECT(Sqlite3QueryResult, QueryResult);
|
|
|
|
|
2021-05-01 20:31:52 +02:00
|
|
|
public:
|
|
|
|
bool next_row();
|
|
|
|
const char* get_cell(const int index);
|
2021-08-20 12:58:37 +02:00
|
|
|
|
|
|
|
bool is_cell_null(const int index);
|
|
|
|
|
2021-08-20 01:32:43 +02:00
|
|
|
int get_last_insert_rowid();
|
2021-05-01 20:31:52 +02:00
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
void query(const String &query, sqlite3 *conn);
|
2021-05-01 21:53:01 +02:00
|
|
|
|
|
|
|
static int run_query_finished(void *data, int argc, char **argv, char **col_names);
|
|
|
|
|
2021-05-01 20:31:52 +02:00
|
|
|
Sqlite3QueryResult();
|
|
|
|
~Sqlite3QueryResult();
|
2021-05-01 21:53:01 +02:00
|
|
|
|
|
|
|
char* err_msg;
|
|
|
|
|
|
|
|
public:
|
2021-08-20 12:58:37 +02:00
|
|
|
struct Cell {
|
|
|
|
bool null;
|
2021-11-01 17:49:10 +01:00
|
|
|
String data;
|
2021-08-20 12:58:37 +02:00
|
|
|
|
|
|
|
Cell() {
|
|
|
|
null = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-01 21:53:01 +02:00
|
|
|
struct Sqlite3QueryResultRow {
|
2021-08-20 12:58:37 +02:00
|
|
|
std::vector<Cell> cells;
|
2021-05-01 21:53:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
char **col_names;
|
|
|
|
std::vector<Sqlite3QueryResultRow *> rows;
|
|
|
|
int current_row;
|
2021-08-20 01:32:43 +02:00
|
|
|
|
|
|
|
sqlite3 *_connection;
|
2021-05-01 20:31:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|