1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSQL_MYSQL_H
5#define QSQL_MYSQL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtSql/qsqldriver.h>
19
20#if defined (Q_OS_WIN32)
21#include <QtCore/qt_windows.h>
22#endif
23
24#include <mysql.h>
25
26#ifdef QT_PLUGIN
27#define Q_EXPORT_SQLDRIVER_MYSQL
28#else
29#define Q_EXPORT_SQLDRIVER_MYSQL Q_SQL_EXPORT
30#endif
31
32QT_BEGIN_NAMESPACE
33
34class QMYSQLDriverPrivate;
35
36class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver
37{
38 friend class QMYSQLResultPrivate;
39 Q_DECLARE_PRIVATE(QMYSQLDriver)
40 Q_OBJECT
41public:
42 explicit QMYSQLDriver(QObject *parent=nullptr);
43 explicit QMYSQLDriver(MYSQL *con, QObject * parent=nullptr);
44 ~QMYSQLDriver();
45 bool hasFeature(DriverFeature f) const override;
46 bool open(const QString & db,
47 const QString & user,
48 const QString & password,
49 const QString & host,
50 int port,
51 const QString& connOpts) override;
52 void close() override;
53 QSqlResult *createResult() const override;
54 QStringList tables(QSql::TableType) const override;
55 QSqlIndex primaryIndex(const QString& tablename) const override;
56 QSqlRecord record(const QString& tablename) const override;
57 QString formatValue(const QSqlField &field,
58 bool trimStrings) const override;
59 QVariant handle() const override;
60 QString escapeIdentifier(const QString &identifier, IdentifierType type) const override;
61
62 bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const override;
63
64protected:
65 bool beginTransaction() override;
66 bool commitTransaction() override;
67 bool rollbackTransaction() override;
68private:
69 void init();
70};
71
72QT_END_NAMESPACE
73
74#endif // QSQL_MYSQL_H
75

source code of qtbase/src/plugins/sqldrivers/mysql/qsql_mysql_p.h