mirror of
https://github.com/mangosfour/server.git
synced 2025-12-24 19:37:07 +00:00
Apply style fix
This commit is contained in:
parent
5531a0087d
commit
35405dd549
155 changed files with 10968 additions and 3660 deletions
|
|
@ -72,18 +72,30 @@ bool PostgreSQLConnection::Initialize(const char* infoString)
|
|||
iter = tokens.begin();
|
||||
|
||||
if (iter != tokens.end())
|
||||
{ host = *iter++; }
|
||||
{
|
||||
host = *iter++;
|
||||
}
|
||||
if (iter != tokens.end())
|
||||
{ port_or_socket_dir = *iter++; }
|
||||
{
|
||||
port_or_socket_dir = *iter++;
|
||||
}
|
||||
if (iter != tokens.end())
|
||||
{ user = *iter++; }
|
||||
{
|
||||
user = *iter++;
|
||||
}
|
||||
if (iter != tokens.end())
|
||||
{ password = *iter++; }
|
||||
{
|
||||
password = *iter++;
|
||||
}
|
||||
if (iter != tokens.end())
|
||||
{ database = *iter++; }
|
||||
{
|
||||
database = *iter++;
|
||||
}
|
||||
|
||||
if (host == ".")
|
||||
{ mPGconn = PQsetdbLogin(NULL, port_or_socket_dir == "." ? NULL : port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str()); }
|
||||
{
|
||||
mPGconn = PQsetdbLogin(NULL, port_or_socket_dir == "." ? NULL : port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
|
||||
}
|
||||
else
|
||||
{ mPGconn = PQsetdbLogin(host.c_str(), port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str()); }
|
||||
|
||||
|
|
@ -105,13 +117,17 @@ bool PostgreSQLConnection::Initialize(const char* infoString)
|
|||
bool PostgreSQLConnection::_Query(const char* sql, PGresult** pResult, uint64* pRowCount, uint32* pFieldCount)
|
||||
{
|
||||
if (!mPGconn)
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 _s = WorldTimer::getMSTime();
|
||||
// Send the query
|
||||
*pResult = PQexec(mPGconn, sql);
|
||||
if (!*pResult)
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PQresultStatus(*pResult) != PGRES_TUPLES_OK)
|
||||
{
|
||||
|
|
@ -141,14 +157,18 @@ bool PostgreSQLConnection::_Query(const char* sql, PGresult** pResult, uint64* p
|
|||
QueryResult* PostgreSQLConnection::Query(const char* sql)
|
||||
{
|
||||
if (!mPGconn)
|
||||
{ return NULL; }
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PGresult* result = NULL;
|
||||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(sql, &result, &rowCount, &fieldCount))
|
||||
{ return NULL; }
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
|
||||
|
||||
|
|
@ -159,14 +179,18 @@ QueryResult* PostgreSQLConnection::Query(const char* sql)
|
|||
QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql)
|
||||
{
|
||||
if (!mPGconn)
|
||||
{ return NULL; }
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PGresult* result = NULL;
|
||||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(sql, &result, &rowCount, &fieldCount))
|
||||
{ return NULL; }
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QueryFieldNames names(fieldCount);
|
||||
for (uint32 i = 0; i < fieldCount; ++i)
|
||||
|
|
@ -181,7 +205,9 @@ QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql)
|
|||
bool PostgreSQLConnection::Execute(const char* sql)
|
||||
{
|
||||
if (!mPGconn)
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 _s = WorldTimer::getMSTime();
|
||||
|
||||
|
|
@ -204,7 +230,9 @@ bool PostgreSQLConnection::Execute(const char* sql)
|
|||
bool PostgreSQLConnection::_TransactionCmd(const char* sql)
|
||||
{
|
||||
if (!mPGconn)
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PGresult* res = PQexec(mPGconn, sql);
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
|
|
@ -238,7 +266,9 @@ bool PostgreSQLConnection::RollbackTransaction()
|
|||
unsigned long PostgreSQLConnection::escape_string(char* to, const char* from, unsigned long length)
|
||||
{
|
||||
if (!mPGconn || !to || !from || !length)
|
||||
{ return 0; }
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return PQescapeString(to, from, length);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue