Qore DbDataProvider Module Reference  1.0
DbDataProvider.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
25 // minimum required Qore version
26 // assume local scope for variables, do not use "$" signs
27 // require type definitions everywhere
29 // enable all warnings
30 
32 namespace DbDataProvider {
34 class DbDataProvider : public AbstractDataProvider {
35 
36 public:
38  const ProviderInfo = <DataProviderInfo>{
39  "type": "DbDataProvider",
40  "supports_read": True,
41  "supports_bulk_read": True,
42  "supports_children": True,
43  "constructor_options": ConstructorOptions,
44  "search_options": SearchOptions,
45  "create_options": NOTHING,
46  "upsert_options": NOTHING,
47  "transaction_management": True,
48  "has_record": True,
49  "record_requires_search_options": True,
50  };
51 
53  const ConstructorOptions = {
54  "datasource": <DataProviderOptionInfo>{
55  "type": (
56  AbstractDataProviderType::get(StringType),
57  AbstractDataProviderType::get(new Type("AbstractDatasource")),
58  ),
59  "desc": "the datasource connection string or an abstract datasource object",
60  },
61  "database": <DataProviderOptionInfo>{
62  "type": AbstractDataProviderType::get(new Type("AbstractDatabase")),
63  "desc": "the database for the object",
64  },
65  };
66 
68  const SearchOptions = {
69  "sql": <DataProviderOptionInfo>{
70  "type": AbstractDataProviderType::get(StringType),
71  "desc": "the raw SQL for the select statement",
72  "required": True,
73  },
74  "args": <DataProviderOptionInfo>{
75  "type": AbstractDataProviderType::get(AutoListType),
76  "desc": "any bind arguments for the select statement",
77  },
78  };
79 
80 protected:
82  AbstractDatabase db;
83 
85  static *code datasource_lookup;
86 
88  static *code table_lookup;
89 
90 public:
91 
93  constructor(AbstractDatasource ds, *hash<auto> opts);
94 
95 
97  constructor(AbstractDatabase db);
98 
99 
101  constructor(*hash<auto> options);
102 
103 
105  string getName();
106 
107 
109 
111  commit();
112 
113 
115 
117  rollback();
118 
119 
121 
125 protected:
126  *hash<string, AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
127 public:
128 
129 
131 
138 protected:
139  AbstractDataProviderBulkRecordInterface searchRecordsBulkImpl(int block_size = 1000, *hash<auto> where_cond, *hash<auto> search_options);
140 public:
141 
142 
144 
149 protected:
150  AbstractDataProviderRecordIterator searchRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
151 public:
152 
153 
155 
157 protected:
158  *list<string> getChildProviderNamesImpl();
159 public:
160 
161 
163 
169 protected:
170  *AbstractDataProvider getChildProviderImpl(string name);
171 public:
172 
173 
175 protected:
176  hash<DataProviderInfo> getStaticInfoImpl();
177 public:
178 
179 
181  static setDatasourceLookup(code datasource_lookup);
182 
184  static setTableLookup(code table_lookup);
185 
187  static AbstractDatasource getDatasource(AbstractDatasource ds);
188 
190  static AbstractDatasource getDatasource(string ds_string);
191 
193  static AbstractTable getTable(string ds_string, string table_string);
194 
196  static AbstractTable getTable(AbstractDatasource ds, string table_string);
197 };
198 };
DbDataProvider::DbDataProvider::datasource_lookup
static *code datasource_lookup
Lookup to get an abstract datasource from a name.
Definition: DbDataProvider.qc.dox.h:85
True
const True
NOTHING
const NOTHING
DbDataProvider::DbDataProvider::table_lookup
static *code table_lookup
Lookup to get an abstract table from a datasource and a name.
Definition: DbDataProvider.qc.dox.h:88
DbDataProvider::DbDataProvider::db
AbstractDatabase db
The database object.
Definition: DbDataProvider.qc.dox.h:82
DbDataProvider
Qore AbstractDbRecordIterator class definition.
Definition: AbstractDbRecordIterator.qc.dox.h:32