
const int DefaultBufferSize = 1024 * 1024* 4;

struct MySqlTools
{
	static MYSQL mysql;
	int minId, maxId, count;
	static FILE* log;
	static char* buffer;
	static int bufferSize;
	static int succeedCounter, failureCounter;
	static void assembleEscapeStr(const char* src, int srcSize, int& firstLength);
	bool init(char* ipAddress = NULL);
	bool initDataRange(int& minId, int& maxId, int& count);
	bool foreach(int offset = 0);
	bool doforeach(int id, const LPBYTE imagePtr, DWORD imageSize);
	bool fetchData(int id, LPBYTE& imagePtr, DWORD& imageSize);
	bool doFetchResult(const char* statement, MYSQL_RES*& res);
	void freeResult(); 
	bool updateInt(int id, int data, char* field, char* table="mypicture");
	bool updateBinary(int id, LPBYTE data, int size, char* field, char* table="mypicture");
	bool saveToFile(int id);
	bool saveToFile(TCHAR* fileName);
	static bool batchInsert(TCHAR* dir, char* ipAddress = NULL);
	bool doSaveToFile(LPBYTE imagePtr, DWORD imageSize);
	bool remakePicture(int id);
	~MySqlTools();

};

