Database operation to select a specific template
This commit is contained in:
@ -36,6 +36,12 @@ namespace Database {
|
|||||||
const static std::string PREPARED_STATEMENT_SELECT_FREELANCER = "selectFreelancer";
|
const static std::string PREPARED_STATEMENT_SELECT_FREELANCER = "selectFreelancer";
|
||||||
const static std::string SQL_STATEMENT_SELECT_FREELANCER = "select id, name, generalinformation, basicinformation from freelancers WHERE id=$1;";
|
const static std::string SQL_STATEMENT_SELECT_FREELANCER = "select id, name, generalinformation, basicinformation from freelancers WHERE id=$1;";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name and Statement for prepared statement to select a freelancer based on a given id
|
||||||
|
*/
|
||||||
|
const static std::string PREPARED_STATEMENT_SELECT_TEMPLATE = "selectTemplate";
|
||||||
|
const static std::string SQL_STATEMENT_SELECT_TEMPLATE = "select templates.id as templateid, templates.name as templatename, freelancers.id as freelancerid, freelancers.name as freelancername, contactdata, contactinformation, currencypreference, (coalesce(priceupfront ,0) + coalesce(priceondeliver ,0)) as pricetotal, priceupfront, priceondeliver, content from templates inner join freelancers on freelancers.id=templates.freelancerid where templates.id = $1;";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name and Statement for prepared statement to select a freelancers templates based on a given freelancer id
|
* Name and Statement for prepared statement to select a freelancers templates based on a given freelancer id
|
||||||
*/
|
*/
|
||||||
@ -150,6 +156,18 @@ namespace Database {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Executes the prepared statement SELECT_TEMPLATE
|
||||||
|
* Takes an open pqxx::connection and the id to select by
|
||||||
|
*/
|
||||||
|
pqxx::result executePreparedStatement_SELECT_TEMPLATE(pqxx::connection &connection, int templateID) {
|
||||||
|
connection.prepare(PREPARED_STATEMENT_SELECT_TEMPLATE, SQL_STATEMENT_SELECT_TEMPLATE);
|
||||||
|
pqxx::work work(connection);
|
||||||
|
pqxx::result result = work.exec_prepared(PREPARED_STATEMENT_SELECT_TEMPLATE, templateID);
|
||||||
|
work.commit();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Executes the prepared statement SELECT_FREELANCER_TEMPLATES
|
* Executes the prepared statement SELECT_FREELANCER_TEMPLATES
|
||||||
* Takes an open pqxx::connection and the id to select by
|
* Takes an open pqxx::connection and the id to select by
|
||||||
|
Reference in New Issue
Block a user