a8/a8/mysql.h
aozhiwei c9d4c5699c 1
2018-11-24 17:14:48 +08:00

67 lines
1.7 KiB
C++

#ifndef A8_MYSQL_H
#define A8_MYSQL_H
namespace a8
{
namespace mysql
{
class Query;
struct ConnectionImpl;
class Connection
{
public:
Connection();
~Connection();
bool Connected();
bool Connect(const std::string& host,
int port,
const std::string& userName,
const std::string& pwd,
const std::string& dataBase);
void Close();
std::string GetError();
a8::mysql::Query* CreateQuery();
std::string GetHost();
int GetPort();
std::string GetUser();
std::string GetPasswd();
std::string GetDataBase();
private:
a8::mysql::ConnectionImpl* impl_ = nullptr;
};
struct QueryImpl;
class Query
{
public:
~Query();
int ExecQuery(const char* querystr, std::vector<a8::XValue> args);
bool ExecScript(const char* scriptstr, std::vector<a8::XValue> args);
std::string FormatSqlEx(const char* fmt, std::vector<a8::XValue> args);
std::string FormatSql(const char* fmt, std::vector<a8::XValue>& args);
int RowsNum();
int FieldsNum();
bool Eof();
void First();
void Prev();
void Next();
void Last();
a8::XValue GetValue(short idx);
std::string GetError();
private:
Query(a8::mysql::ConnectionImpl* conn_impl);
private:
a8::mysql::QueryImpl* impl_ = nullptr;
friend class Connection;
};
}
}
#endif