48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#ifndef MYSQL_H
|
|
#define MYSQL_H
|
|
|
|
#include <QObject>
|
|
|
|
#include <QMap>
|
|
#include <QStringList>
|
|
#include <QVariantList>
|
|
|
|
class MySQL : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MySQL(QObject *parent = nullptr);
|
|
|
|
bool open(const QString &host,
|
|
int port,
|
|
const QString &user,
|
|
const QString &pwd,
|
|
const QString &dbName);
|
|
|
|
void close();
|
|
|
|
bool createTable(const QString &tableName,
|
|
const QMap<QString, QString> &otherFields);
|
|
bool insertPartialV(const QString &tableName,
|
|
const QStringList &fieldNames,
|
|
const QVariantList &values);
|
|
|
|
bool insertPartial(const QString &tableName,
|
|
const QStringList &fieldNames,
|
|
const QStringList &values);
|
|
|
|
bool insertFull(const QString &tableName,
|
|
const QVariantList &values);
|
|
QList<QVariantList> selectLatest(const QString &tableName,
|
|
int maxRows);
|
|
/* 读取最新 maxRows 条,只拿指定字段 */
|
|
QList<QVariantList> selectLatest(const QString &tableName,
|
|
const QStringList &fieldNames,
|
|
int maxRows);
|
|
bool isConnectOK = false;
|
|
private:
|
|
|
|
};
|
|
|
|
#endif // MYSQL_H
|