WIP: remove the old database abstraction layer
remove such classes: - DbBase - DbConn - DbTextStream - Db while here: - remove: TextStream, SLog, TexTextStream
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016, Tomasz Sowa
|
||||
* Copyright (c) 2016-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "mdb.h"
|
||||
#include "core/log.h"
|
||||
#include "morm.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -43,79 +43,27 @@ namespace MailRegister
|
||||
|
||||
|
||||
|
||||
bool MDb::AddMail(int list_id, const std::wstring & mail)
|
||||
bool MDb::AddMail(morm::ModelConnector * model_connector, int list_id, const std::wstring & mail)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
RegisterMail r;
|
||||
r.set_connector(model_connector);
|
||||
r.clear();
|
||||
r.list_id = list_id;
|
||||
r.mail = mail;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("insert into plugins.registermail (list_id, mail) values (")
|
||||
<< list_id
|
||||
<< mail
|
||||
<< R(");");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
|
||||
//.id = AssertCurrval("core.user_id_seq");
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return status == WINIX_ERR_OK;
|
||||
return r.insert();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MDb::GetUsers(std::vector<std::wstring> & container, bool clear_container)
|
||||
void MDb::GetUsers(morm::ModelConnector * model_connector, std::vector<RegisterMail> & container)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
container.clear();
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("select * from plugins.registermail")
|
||||
<< R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
int rows = Rows(r);
|
||||
|
||||
for(int i=0 ; i < rows ; ++i)
|
||||
{
|
||||
AssertValueWide(r, i, 0, mail);
|
||||
container.push_back(mail);
|
||||
}
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
result = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return result == WINIX_ERR_OK;
|
||||
morm::Finder<RegisterMail> finder(model_connector);
|
||||
finder.select().get_vector(container);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
Reference in New Issue
Block a user