2006-04-07 11:18:17 +00:00
|
|
|
|
|
|
|
|
2005-02-15 14:11:01 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#ifndef __linux__
|
|
|
|
#define WINDOWS_LEAN_AND_MEAN
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
2006-04-07 11:18:17 +00:00
|
|
|
#include "amxxmodule.h"
|
2005-02-15 14:11:01 +00:00
|
|
|
#include "CVector.h"
|
|
|
|
#include "CString.h"
|
|
|
|
#include "sqlite3.h"
|
|
|
|
|
|
|
|
#define MEM_ALLOC_FAILED -20
|
|
|
|
#define CONNECT_FAILED -10
|
|
|
|
#define QUERY_FAILED -5
|
|
|
|
|
|
|
|
class SQL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SQL();
|
|
|
|
~SQL();
|
|
|
|
int Connect(/*const char *host, const char *user, const char *pass,*/ const char *base);
|
2005-02-15 20:46:58 +00:00
|
|
|
int Query(const char *query);
|
2005-02-15 14:11:01 +00:00
|
|
|
void Disconnect();
|
|
|
|
int Error();
|
|
|
|
|
|
|
|
sqlite3 *sqlite;
|
|
|
|
|
|
|
|
String ErrorStr;
|
|
|
|
int ErrorCode;
|
|
|
|
|
|
|
|
String Database;
|
|
|
|
|
|
|
|
bool isFree;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SQLResult
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SQLResult();
|
|
|
|
~SQLResult();
|
|
|
|
int Query(SQL *cn, const char *query);
|
|
|
|
bool Nextrow();
|
|
|
|
void FreeResult();
|
|
|
|
const char *GetField(unsigned int field);
|
|
|
|
const char *GetField(const char *field);
|
|
|
|
unsigned int NumRows();
|
|
|
|
|
|
|
|
String *m_fieldNames;
|
|
|
|
bool isFree;
|
|
|
|
int m_currentRow;
|
|
|
|
bool m_hasData;
|
|
|
|
|
|
|
|
char **m_data;
|
|
|
|
char *m_errorMsg;
|
|
|
|
unsigned int m_rowCount, m_columnCount;
|
|
|
|
#if defined _DEBUG
|
|
|
|
static unsigned int latestStoredResultId;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
char *amx_string(AMX *amx, cell ¶m, int &len);
|
|
|
|
|
|
|
|
extern CVector<SQLResult*> Results;
|
|
|
|
extern CVector<SQL*> DBList;
|
|
|
|
|