Add missing keepOpen in run
This commit is contained in:
parent
4c171a5c99
commit
b132aa9fff
15
src/sql3.cpp
15
src/sql3.cpp
@ -7,6 +7,7 @@ sql3::sql3(const string _path, bool _keepOpen) {
|
|||||||
if (keepOpen) {
|
if (keepOpen) {
|
||||||
if (open()) {
|
if (open()) {
|
||||||
printf("[ERROR] Ne mogu otvoriti bazu podataka!");
|
printf("[ERROR] Ne mogu otvoriti bazu podataka!");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +25,14 @@ bool sql3::close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool sql3::run(const string sql_command) {
|
bool sql3::run(const string sql_command) {
|
||||||
|
|
||||||
|
if (!keepOpen) {
|
||||||
|
if (open()) {
|
||||||
|
printf("[ERROR] Ne mogu otvoriti bazu podataka!");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool r = true;
|
bool r = true;
|
||||||
char *messaggeError;
|
char *messaggeError;
|
||||||
uint exec_stuts;
|
uint exec_stuts;
|
||||||
@ -38,6 +47,12 @@ bool sql3::run(const string sql_command) {
|
|||||||
Answer = responseDatabase;
|
Answer = responseDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!keepOpen) {
|
||||||
|
if(close()) {
|
||||||
|
printf ("ERROR Zatvaranja baze podataka!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ using namespace std;
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
sql3 mydb("../example/example.db", true);
|
sql3 mydb("../example/example.db", false);
|
||||||
|
|
||||||
//cout << mydb.ask("Select * from Tab1");
|
//cout << mydb.ask("Select * from Tab1");
|
||||||
// cout << mydb.ask("INSERT INTO Tab1 VALUES(3,'Pakora', 'marijanab@bitelex.ml');");
|
// cout << mydb.ask("INSERT INTO Tab1 VALUES(3,'Pakora', 'marijanab@bitelex.ml');");
|
||||||
|
BIN
test/test.o
BIN
test/test.o
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user