Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
resittimtable/select1_db.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
105 lines (84 sloc)
2.18 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef SELECT1_DB_H | |
#define SELECT1_DB_H | |
#include <iostream> | |
#include <string> | |
#include <cstring> | |
#include <vector> | |
#include <list> | |
#include "libsqlite.hpp" | |
#include "insert1_db.h" | |
using namespace std; | |
class select1_db | |
{ | |
protected: | |
std::vector<string> modules, classes, lecturers, rooms; | |
std::vector<int> studentID; | |
std::vector<string> name, surname, username, email, password, startTiming, endTiming; | |
public: | |
select1_db(){ | |
try | |
{ | |
sqlite::sqlite db("Timetable.db"); | |
auto cur = db.get_statement(); | |
cur->set_sql("SELECT * FROM WORK"); | |
cur->prepare(); | |
while (cur->step()){ | |
modules.push_back(cur->get_text(1)); | |
classes.push_back(cur->get_text(2)); | |
lecturers.push_back(cur->get_text(3)); | |
rooms.push_back(cur->get_text(4)); | |
startTiming.push_back(cur->get_text(5)); | |
endTiming.push_back(cur->get_text(6)); | |
} | |
} | |
catch( sqlite::exception e ){ | |
cerr << e.what() << endl; | |
} | |
} | |
std::vector<std::string> get_modules(){ | |
select1_db(); | |
return modules; | |
} | |
std::vector<std::string> get_classes(){ | |
select1_db(); | |
return classes; | |
} | |
std::vector<std::string> get_lecturers(){ | |
select1_db(); | |
return lecturers; | |
} | |
std::vector<std::string> get_rooms(){ | |
select1_db(); | |
return rooms; | |
} | |
std::vector<std::string> get_startTiming(){ | |
select1_db(); | |
return startTiming; | |
} | |
std::vector<std::string> get_endTiming(){ | |
select1_db(); | |
return endTiming; | |
} | |
//this part doesn’t work so my lessons don’t come and i remove it do it doesn't stop the program | |
/*string printingeverything(){ | |
try | |
{ | |
sqlite::sqlite db("Timetable.db"); | |
auto cur = db.get_statement(); | |
cur->set_sql("SELECT * FROM Work;"); | |
cur->prepare(); | |
cur->step(); | |
string return_statement = cur->get_int(0); | |
if(return_statement.empty()){ | |
return "NULL"; | |
}else{ | |
return return_statement; | |
} | |
} | |
catch( sqlite::exception e ){ | |
cerr << e.what() << endl; | |
return "Not In Database"; | |
} | |
}*/ | |
}; | |
#endif |