Database handler check if email exists in freelancer table

This commit is contained in:
Tina_Azure
2023-04-19 02:16:18 +02:00
parent fcff2f5906
commit c4a5256489

View File

@ -49,6 +49,12 @@ namespace Database {
const static std::string PREPARED_STATEMENT_SELECT_FREELANCER_EMAIL = "selectFreelancerEmailAddress";
const static std::string SQL_STATEMENT_SELECT_FREELANCER_EMAIL = "select emailaddress from freelancers where id = $1;";
/*
* Name and Statement for prepared statement to check if an email is already registered with a freelancer
*/
const static std::string PREPARED_STATEMENT_SELECT_CHECK_EMAIL_EXISTS = "selectCheckEmailExists";
const static std::string SQL_STATEMENT_SELECT_CHECK_EMAIL_EXISTS = "select count(*) from freelancers where emailaddress = $1;";
/*
* Name and Statement for prepared statement to select a freelancer based on a given id
*/
@ -307,6 +313,19 @@ namespace Database {
return result;
}
/*
* Executes the prepared statement SELECT_CHECK_EMAIL_EXISTS
* Takes an open pqxx::connection and the emailAddress to check
* Delivers count of emailaddress occurence 0 for none 1+ for more
*/
pqxx::result executePreparedStatement_SELECT_CHECK_EMAIL_EXISTS(pqxx::connection &connection, std::string freelancerEmail) {
connection.prepare(PREPARED_STATEMENT_SELECT_CHECK_EMAIL_EXISTS, SQL_STATEMENT_SELECT_CHECK_EMAIL_EXISTS);
pqxx::work work(connection);
pqxx::result result = work.exec_prepared(PREPARED_STATEMENT_SELECT_CHECK_EMAIL_EXISTS, freelancerEmail);
work.commit();
return result;
}
/*
* Executes the prepared statement SELECT_TEMPLATE
* Takes an open pqxx::connection and the id to select by