added amb281 - multiple result sets for MySQL

This commit is contained in:
David Anderson
2007-10-22 21:31:02 +00:00
parent 2d737970d0
commit a86b1c5097
16 changed files with 150 additions and 5 deletions

View File

@ -489,6 +489,34 @@ static cell AMX_NATIVE_CALL SQL_Rewind(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL SQL_NextResultSet(AMX *amx, cell *params)
{
AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query);
if (!qInfo)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]);
return 0;
}
IResultSet *rs = qInfo->info.rs;
if (!rs)
{
MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
return 0;
}
if (rs->NextResultSet())
{
return 1;
}
else
{
qInfo->info.rs = NULL;
return 0;
}
}
static cell AMX_NATIVE_CALL SQL_QuoteString(AMX *amx, cell *params)
{
IDatabase *pDb = (IDatabase *)GetHandle(params[1], Handle_Database);
@ -559,6 +587,7 @@ AMX_NATIVE_INFO g_BaseSqlNatives[] =
{"SQL_Rewind", SQL_Rewind},
{"SQL_QuoteString", SQL_QuoteString},
{"SQL_QuoteStringFmt", SQL_QuoteStringFmt},
{"SQL_NextResultSet", SQL_NextResultSet},
{NULL, NULL},
};

View File

@ -61,6 +61,9 @@ namespace SourceMod
* Resets back to the first row.
*/
virtual void Rewind() =0;
/* Always returns false in Sqlite */
virtual bool NextResultSet() =0;
};
struct QueryInfo

View File

@ -164,3 +164,8 @@ void SqliteResultSet::Rewind()
m_CurRow = 1;
m_CurIndex = (m_CurRow * m_Columns);
}
bool SqliteResultSet::NextResultSet()
{
return false;
}

View File

@ -39,6 +39,7 @@ namespace SourceMod
int GetInt(unsigned int columnId);
bool IsNull(unsigned int columnId);
const char *GetRaw(unsigned int columnId, size_t *length);
bool NextResultSet();
private:
const char *GetStringSafe(unsigned int columnId);
private:

View File

@ -560,6 +560,11 @@ void AtomicResult::Rewind()
m_CurRow = 1;
}
bool AtomicResult::NextResultSet()
{
return false;
}
AMX_NATIVE_INFO g_ThreadSqlNatives[] =
{
{"SQL_ThreadQuery", SQL_ThreadQuery},

View File

@ -42,6 +42,7 @@ public:
virtual int GetInt(unsigned int columnId);
virtual bool IsNull(unsigned int columnId);
virtual const char *GetRaw(unsigned int columnId, size_t *length);
virtual bool NextResultSet();
public:
void CopyFrom(IResultSet *rs);
private: