Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
#ifndef SELECT_DB_H
#define SELECT_DB_H
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include "libsqlite.hpp"
#include "insert_db.h"
using namespace std;
class select_db
{
protected:
std::vector<string> modules;
std::vector<string> classes;
std::vector<string> lecturers;
std::vector<string> rooms;
std::vector<int> startTiming;
std::vector<int> endTiming;
std::vector<int> studentID;
std::vector<string> name;
std::vector<string> surname;
std::vector<string> username;
std::vector<string> email;
std::vector<string> password;
public:
select_db(){
try
{
sqlite::sqlite db("School.db");
auto cur = db.get_statement();
cur->set_sql("SELECT * FROM STUDENTDETAILS;");
cur->prepare();
while (cur->step()){
username.push_back(cur->get_text(3));
password.push_back(cur->get_text(5));
studentID.push_back(cur->get_int(0));
}
}
catch( sqlite::exception e ){
cerr << e.what() << endl;
}
}
std::vector<std::string> get_username(){
select_db();
return username;
}
std::vector<std::string> get_password(){
select_db();
return password;
}
std::vector<int> get_studentID(){
select_db();
return studentID;
}
string matchingusername(string username){
try
{
sqlite::sqlite db("School.db");
auto cur = db.get_statement();
cur->set_sql("SELECT username FROM STUDENTDETAILS WHERE username = ?;");
cur->prepare();
cur->bind( 1, username );
cur->step();
string return_statement = cur->get_text(0);
if(return_statement.empty()){
return "NULL";
}else{
return return_statement;
}
}
catch( sqlite::exception e ){
cerr << e.what() << endl;
return "Not In Database";
}
}
string matchingpassword(string password){
try
{
sqlite::sqlite db("School.db");
auto cur = db.get_statement();
cur->set_sql("SELECT password FROM STUDENTDETAILS WHERE password = ?;");
cur->prepare();
cur->bind( 1, password );
cur->step();
string return_statement = cur->get_text(0);
if(return_statement.empty()){
return "NULL";
}else{
return return_statement;
}
}
catch( sqlite::exception e ){
cerr << e.what() << endl;
return "Not in Database";
}
}
};
#endif