implemented amb27 (SQL_Rewind)

fixed builds
This commit is contained in:
David Anderson
2007-04-24 15:46:33 +00:00
parent adfc2ab451
commit bfe1ff6e15
13 changed files with 81 additions and 2 deletions

View File

@ -467,6 +467,28 @@ static cell AMX_NATIVE_CALL SQL_SetAffinity(AMX *amx, cell *params)
return 0;
}
static cell AMX_NATIVE_CALL SQL_Rewind(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;
}
rs->Rewind();
return 1;
}
AMX_NATIVE_INFO g_BaseSqlNatives[] =
{
{"SQL_MakeDbTuple", SQL_MakeDbTuple},
@ -488,6 +510,7 @@ AMX_NATIVE_INFO g_BaseSqlNatives[] =
{"SQL_SetAffinity", SQL_SetAffinity},
{"SQL_GetInsertId", SQL_GetInsertId},
{"SQL_GetQueryString", SQL_GetQueryString},
{"SQL_Rewind", SQL_Rewind},
{NULL, NULL},
};

View File

@ -57,6 +57,10 @@ namespace SourceMod
* call IsDone() after each call to NextRow().
*/
virtual void NextRow() =0;
/**
* Rewinds to the first row.
*/
virtual void Rewind() =0;
};
struct QueryInfo

View File

@ -147,3 +147,9 @@ void MysqlResultSet::NextRow()
m_kRow.m_Lengths = lengths;
}
}
void MysqlResultSet::Rewind()
{
mysql_data_seek(m_pRes, 0);
NextRow();
}

View File

@ -43,6 +43,7 @@ namespace SourceMod
bool IsDone();
IResultRow *GetRow();
void NextRow();
void Rewind();
private:
MYSQL_RES *m_pRes;
MysqlResultRow m_kRow;

View File

@ -561,6 +561,10 @@ void AtomicResult::CopyFrom(IResultSet *rs)
}
}
void AtomicResult::Rewind()
{
m_CurRow = 1;
}
AMX_NATIVE_INFO g_ThreadSqlNatives[] =
{

View File

@ -33,6 +33,7 @@ public:
virtual bool IsDone();
virtual IResultRow *GetRow();
virtual void NextRow();
virtual void Rewind();
public:
virtual const char *GetString(unsigned int columnId);
virtual const char *GetStringSafe(unsigned int columnId);