database request to retrieve a freelancers id
This commit is contained in:
@ -64,6 +64,11 @@ namespace Database {
|
||||
*/
|
||||
const static std::string PREPARED_STATEMENT_SELECT_FREELANCER_SALT = "selectFreelancerSalt";
|
||||
const static std::string SQL_STATEMENT_SELECT_FREELANCER_SALT = "select salt from freelancers where emailaddress = $1;";
|
||||
/*
|
||||
* Name and Statement for prepared statement to get id using a given email
|
||||
*/
|
||||
const static std::string PREPARED_STATEMENT_SELECT_FREELANCER_ID = "selectFreelancerSalt";
|
||||
const static std::string SQL_STATEMENT_SELECT_FREELANCER_ID = "select id from freelancers where emailaddress = $1;";
|
||||
|
||||
/*
|
||||
* Name and Statement for prepared statement to check if hash is valid
|
||||
@ -353,6 +358,17 @@ namespace Database {
|
||||
connection.unprepare(PREPARED_STATEMENT_SELECT_FREELANCER_SALT);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_FREELANCER_ID
|
||||
* Takes an open pqxx::connection and the id to select by
|
||||
*/
|
||||
pqxx::result executePreparedStatement_SELECT_FREELANCER_ID(pqxx::connection &connection, const std::string& freelancerEmail) {
|
||||
connection.prepare(PREPARED_STATEMENT_SELECT_FREELANCER_ID, SQL_STATEMENT_SELECT_FREELANCER_ID);
|
||||
pqxx::work work(connection);
|
||||
pqxx::result result = work.exec_prepared(PREPARED_STATEMENT_SELECT_FREELANCER_ID, freelancerEmail);
|
||||
work.commit();
|
||||
connection.unprepare(PREPARED_STATEMENT_SELECT_FREELANCER_ID);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user