#include <libpq-fe.h>
#include "postgresql_store.h"
-#include "stg_locker.h"
+#include "stg/locker.h"
//-----------------------------------------------------------------------------
-int POSTGRESQL_STORE::GetServicesList(vector<string> * servicesList) const
+int POSTGRESQL_STORE::GetServicesList(std::vector<std::string> * servicesList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::SaveService(const SERVICE_CONF & sc) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
return -1;
}
-std::stringstream query;
+std::ostringstream query;
query << "UPDATE tb_services SET "
<< "comment = '" << ecomment << "', "
<< "cost = " << sc.cost << ", "
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::RestoreService(SERVICE_CONF * sc,
- const string & name) const
+ const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
return -1;
}
-std::stringstream query;
+std::ostringstream query;
query << "SELECT comment, cost, pay_day FROM tb_services WHERE name = '" << ename << "'";
result = PQexec(connection, query.str().c_str());
}
//-----------------------------------------------------------------------------
-int POSTGRESQL_STORE::AddService(const string & name) const
+int POSTGRESQL_STORE::AddService(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
return -1;
}
-std::stringstream query;
+std::ostringstream query;
query << "INSERT INTO tb_services \
(name, comment, cost, pay_day) \
VALUES \
}
//-----------------------------------------------------------------------------
-int POSTGRESQL_STORE::DelService(const string & name) const
+int POSTGRESQL_STORE::DelService(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
return -1;
}
-std::stringstream query;
+std::ostringstream query;
query << "DELETE FROM tb_services WHERE name = '" << ename << "'";
result = PQexec(connection, query.str().c_str());