第三个工具类,QueryOperatorUpdate
负责处理:直接执行sql方式下的,增、删、改的需求。
用到了之前的DBOperator,主要是封装其ExecQuery接口。
代码很简单
QueryOperatorUpdate.h
#ifndef __QueryOperatorUpdate_H__
#define __QueryOperatorUpdate_H__
struct st_mysql;
typedef struct st_mysql MYSQL;
namespace common{
namespace db{
class QueryOperatorUpdate
{
public:
QueryOperatorUpdate();
~QueryOperatorUpdate();
void Release();
// 执行sql
bool DoOperator(MYSQL *connect, const char *sql);
};
}
}
#endif
QueryOperatorUpdate.cpp
#include "QueryOperatorUpdate.h"
#ifdef WIN32
#include <winsock2.h>
#endif
#include <stdio.h>
#include <mysql.h>
#include <string.h>
#include <stdarg.h>
#include "DBOperator.h"
namespace common{
namespace db{
QueryOperatorUpdate::QueryOperatorUpdate()
{
}
QueryOperatorUpdate::~QueryOperatorUpdate()
{
Release();
}
void QueryOperatorUpdate::Release()
{
}
bool QueryOperatorUpdate::DoOperator(MYSQL *connect, const char *sql)
{
if (NULL != connect && NULL != sql)
{
return DBOperator::ExecQuery(connect, sql);
}
else
{
return false;
}
}
}
}