-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSqlTable.h
73 lines (59 loc) · 1.68 KB
/
SqlTable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// Copyright (C) 2010 Piotr Zagawa
//
// Released under BSD License
//
#pragma once
#include "sqlite3.h"
#include "SqlCommon.h"
#include "SqlFieldSet.h"
#include "SqlRecordSet.h"
#include "sql_macro.h"
NS_SQL_BEGIN
class Table {
public:
Table(sqlite3* db, string tableName, Field* definition);
Table(sqlite3* db, string tableName, FieldSet* fields);
public:
string name() const;
string getDefinition();
string toString();
string errMsg();
FieldSet* fields();
sqlite3* getHandle();
public:
bool create();
bool exists();
bool remove();
bool truncate();
public:
bool open();
bool open(string whereCondition);
bool open(string whereCondition, string sortBy);
bool open(string whereCondition, string sortBy, bool asc);
bool query(string queryStr);
int totalRecordCount();
public:
int recordCount();
Record* getRecord(int record_index);
Record* getTopRecord();
Record* getRecordByKeyId(integer keyId);
public:
bool addRecord(Record* record);
bool updateRecord(Record* record);
bool deleteRecords(string whereCondition);
bool copyRecords(Table& source);
bool backup(Table& source);
// sakura extension --------------------------------------------------------
bool addRecordIfNotExists(Record* record, string key, string value);
bool updateRecord(Record* record, string where_condition);
bool addOrReplaceRecord(Record *record);
bool createIndex(const std::string& index_name, const std::string& column_name);
public:
static Table* createFromDefinition(sqlite3* db, string tableName, string fieldsDefinition);
private:
sqlite3* _db;
string _tableName;
RecordSet _recordset;
};
NS_SQL_END