mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
Add ExecuteUpdate to database interface reporting affected rows
This commit is contained in:
parent
aebe11568a
commit
bad2d71d77
|
@ -67,6 +67,9 @@ public:
|
|||
// 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;
|
||||
// executes the query and returns the number of rows affected by the update/insert/delete
|
||||
// FIXME(2020-01-20): change function to AffectedRows() when moved to c-api of MySQL
|
||||
virtual int ExecuteUpdate() = 0;
|
||||
|
||||
virtual bool IsNull(int Col) const = 0;
|
||||
virtual float GetFloat(int Col) const = 0;
|
||||
|
|
|
@ -261,6 +261,18 @@ bool CMysqlConnection::Step()
|
|||
#endif
|
||||
}
|
||||
|
||||
int CMysqlConnection::ExecuteUpdate()
|
||||
{
|
||||
#if defined(CONF_SQL)
|
||||
if(m_NewQuery)
|
||||
{
|
||||
m_NewQuery = false;
|
||||
return m_pPreparedStmt->executeUpdate();
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CMysqlConnection::IsNull(int Col) const
|
||||
{
|
||||
#if defined(CONF_SQL)
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
|
||||
virtual void Print() {}
|
||||
virtual bool Step();
|
||||
virtual int ExecuteUpdate();
|
||||
|
||||
virtual bool IsNull(int Col) const;
|
||||
virtual float GetFloat(int Col) const;
|
||||
|
|
|
@ -190,6 +190,12 @@ bool CSqliteConnection::Step()
|
|||
return false;
|
||||
}
|
||||
|
||||
int CSqliteConnection::ExecuteUpdate()
|
||||
{
|
||||
Step();
|
||||
return sqlite3_changes(m_pDb);
|
||||
}
|
||||
|
||||
bool CSqliteConnection::IsNull(int Col) const
|
||||
{
|
||||
return sqlite3_column_type(m_pStmt, Col - 1) == SQLITE_NULL;
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
virtual void Print();
|
||||
virtual bool Step();
|
||||
virtual int ExecuteUpdate();
|
||||
|
||||
virtual bool IsNull(int Col) const;
|
||||
virtual float GetFloat(int Col) const;
|
||||
|
@ -58,7 +59,7 @@ private:
|
|||
sqlite3_stmt *m_pStmt;
|
||||
bool m_Done; // no more rows available for Step
|
||||
bool m_Locked;
|
||||
// returns true, if the query succeded
|
||||
// returns true, if the query succeeded
|
||||
bool Execute(const char *pQuery);
|
||||
|
||||
void ExceptionOnError(int Result);
|
||||
|
|
Loading…
Reference in a new issue