mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Add print functionality to SQLite
This commit is contained in:
parent
46b0ff354e
commit
88dc1c1a9c
|
@ -58,6 +58,8 @@ public:
|
|||
virtual void BindInt(int Idx, int Value) = 0;
|
||||
virtual void BindFloat(int Idx, float Value) = 0;
|
||||
|
||||
// Print expanded sql statement
|
||||
virtual void Print() = 0;
|
||||
// executes the query and returns if a result row exists and selects it
|
||||
// when called multiple times the next row is selected
|
||||
virtual bool Step() = 0;
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
virtual void BindInt(int Idx, int Value);
|
||||
virtual void BindFloat(int Idx, float Value);
|
||||
|
||||
virtual void Print() {}
|
||||
virtual bool Step();
|
||||
|
||||
virtual bool IsNull(int Col) const;
|
||||
|
|
|
@ -26,7 +26,6 @@ CSqliteConnection::~CSqliteConnection()
|
|||
m_pDb = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void CSqliteConnection::Print(IConsole *pConsole, const char *Mode)
|
||||
{
|
||||
char aBuf[512];
|
||||
|
@ -36,7 +35,6 @@ void CSqliteConnection::Print(IConsole *pConsole, const char *Mode)
|
|||
pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||
}
|
||||
|
||||
|
||||
void CSqliteConnection::ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize)
|
||||
{
|
||||
str_format(aBuf, BufferSize, "strftime('%%s', %s)", pTimestamp);
|
||||
|
@ -156,6 +154,12 @@ void CSqliteConnection::BindFloat(int Idx, float Value)
|
|||
m_Done = false;
|
||||
}
|
||||
|
||||
void CSqliteConnection::Print()
|
||||
{
|
||||
if(m_pStmt != nullptr)
|
||||
dbg_msg("sql", "SQLite statement: %s", sqlite3_expanded_sql(m_pStmt));
|
||||
}
|
||||
|
||||
bool CSqliteConnection::Step()
|
||||
{
|
||||
if(m_Done)
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
virtual void BindInt(int Idx, int Value);
|
||||
virtual void BindFloat(int Idx, float Value);
|
||||
|
||||
virtual void Print();
|
||||
virtual bool Step();
|
||||
|
||||
virtual bool IsNull(int Col) const;
|
||||
|
|
|
@ -535,6 +535,7 @@ bool CScore::SaveScoreThread(IDbConnection *pSqlServer, const ISqlData *pGameDat
|
|||
pSqlServer->BindString(3, pData->m_aTimestamp);
|
||||
pSqlServer->BindString(4, g_Config.m_SvSqlServerName);
|
||||
pSqlServer->BindString(5, pData->m_GameUuid);
|
||||
pSqlServer->Print();
|
||||
pSqlServer->Step();
|
||||
|
||||
pData->m_pResult->m_Done = true;
|
||||
|
@ -617,6 +618,7 @@ bool CScore::SaveTeamScoreThread(IDbConnection *pSqlServer, const ISqlData *pGam
|
|||
pSqlServer->BindString(1, pData->m_aTimestamp);
|
||||
pSqlServer->BindString(2, pData->m_GameUuid);
|
||||
pSqlServer->BindBlob(3, Teamrank.m_TeamID.m_aData, sizeof(Teamrank.m_TeamID.m_aData));
|
||||
pSqlServer->Print();
|
||||
pSqlServer->Step();
|
||||
}
|
||||
}
|
||||
|
@ -637,6 +639,7 @@ bool CScore::SaveTeamScoreThread(IDbConnection *pSqlServer, const ISqlData *pGam
|
|||
pSqlServer->BindString(3, pData->m_aTimestamp);
|
||||
pSqlServer->BindBlob(4, GameID.m_aData, sizeof(GameID.m_aData));
|
||||
pSqlServer->BindString(5, pData->m_GameUuid);
|
||||
pSqlServer->Print();
|
||||
pSqlServer->Step();
|
||||
}
|
||||
}
|
||||
|
@ -1324,6 +1327,7 @@ bool CScore::SaveTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData
|
|||
pSqlServer->BindString(3, Code);
|
||||
pSqlServer->BindString(4, pData->m_Server);
|
||||
pSqlServer->BindString(5, aSaveID);
|
||||
pSqlServer->Print();
|
||||
pSqlServer->Step();
|
||||
|
||||
if(!Failure)
|
||||
|
@ -1498,6 +1502,7 @@ bool CScore::LoadTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData
|
|||
pSqlServer->PrepareStatement(aBuf);
|
||||
pSqlServer->BindString(1, pData->m_Code);
|
||||
pSqlServer->BindString(2, pData->m_Map);
|
||||
pSqlServer->Print();
|
||||
pSqlServer->Step();
|
||||
|
||||
pData->m_pResult->m_Status = CScoreSaveResult::LOAD_SUCCESS;
|
||||
|
|
Loading…
Reference in a new issue