Add sql BindInt64

This commit is contained in:
ChillerDragon 2021-11-19 12:29:24 +01:00
parent fb23d4637b
commit 097f718190
3 changed files with 27 additions and 0 deletions

View file

@ -54,6 +54,7 @@ public:
virtual void BindString(int Idx, const char *pString) = 0;
virtual void BindBlob(int Idx, unsigned char *pBlob, int Size) = 0;
virtual void BindInt(int Idx, int Value) = 0;
virtual void BindInt64(int Idx, int64_t Value) = 0;
virtual void BindFloat(int Idx, float Value) = 0;
// Print expanded sql statement

View file

@ -82,6 +82,7 @@ public:
virtual void BindString(int Idx, const char *pString);
virtual void BindBlob(int Idx, unsigned char *pBlob, int Size);
virtual void BindInt(int Idx, int Value);
virtual void BindInt64(int Idx, int64_t Value);
virtual void BindFloat(int Idx, float Value);
virtual void Print() {}
@ -400,6 +401,23 @@ void CMysqlConnection::BindInt(int Idx, int Value)
pParam->error = nullptr;
}
void CMysqlConnection::BindInt64(int Idx, int64_t Value)
{
m_NewQuery = true;
Idx -= 1;
dbg_assert(0 <= Idx && Idx < (int)m_aStmtParameters.size(), "index out of bounds");
m_aStmtParameterExtras[Idx].i = Value;
MYSQL_BIND *pParam = &m_aStmtParameters[Idx];
pParam->buffer_type = MYSQL_TYPE_LONGLONG;
pParam->buffer = &m_aStmtParameterExtras[Idx].i;
pParam->buffer_length = sizeof(m_aStmtParameterExtras[Idx].i);
pParam->length = nullptr;
pParam->is_null = nullptr;
pParam->is_unsigned = false;
pParam->error = nullptr;
}
void CMysqlConnection::BindFloat(int Idx, float Value)
{
m_NewQuery = true;

View file

@ -32,6 +32,7 @@ public:
virtual void BindString(int Idx, const char *pString);
virtual void BindBlob(int Idx, unsigned char *pBlob, int Size);
virtual void BindInt(int Idx, int Value);
virtual void BindInt64(int Idx, int64_t Value);
virtual void BindFloat(int Idx, float Value);
virtual void Print();
@ -197,6 +198,13 @@ void CSqliteConnection::BindInt(int Idx, int Value)
m_Done = false;
}
void CSqliteConnection::BindInt64(int Idx, int64_t Value)
{
int Result = sqlite3_bind_int64(m_pStmt, Idx, Value);
AssertNoError(Result);
m_Done = false;
}
void CSqliteConnection::BindFloat(int Idx, float Value)
{
int Result = sqlite3_bind_double(m_pStmt, Idx, (double)Value);