source: trunk/src/sql/drivers/mysql/qsql_mysql.h@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 4.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtSql module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QSQL_MYSQL_H
43#define QSQL_MYSQL_H
44
45#include <QtSql/qsqldriver.h>
46#include <QtSql/qsqlresult.h>
47
48#if defined (Q_OS_WIN32)
49#include <QtCore/qt_windows.h>
50#endif
51
52#include <mysql.h>
53
54#ifdef QT_PLUGIN
55#define Q_EXPORT_SQLDRIVER_MYSQL
56#else
57#define Q_EXPORT_SQLDRIVER_MYSQL Q_SQL_EXPORT
58#endif
59
60QT_BEGIN_HEADER
61
62QT_BEGIN_NAMESPACE
63
64class QMYSQLDriverPrivate;
65class QMYSQLResultPrivate;
66class QMYSQLDriver;
67class QSqlRecordInfo;
68
69class QMYSQLResult : public QSqlResult
70{
71 friend class QMYSQLDriver;
72public:
73 explicit QMYSQLResult(const QMYSQLDriver* db);
74 ~QMYSQLResult();
75
76 QVariant handle() const;
77protected:
78 void cleanup();
79 bool fetch(int i);
80 bool fetchNext();
81 bool fetchLast();
82 bool fetchFirst();
83 QVariant data(int field);
84 bool isNull(int field);
85 bool reset (const QString& query);
86 int size();
87 int numRowsAffected();
88 QVariant lastInsertId() const;
89 QSqlRecord record() const;
90 void virtual_hook(int id, void *data);
91 bool nextResult();
92
93#if MYSQL_VERSION_ID >= 40108
94 bool prepare(const QString& stmt);
95 bool exec();
96#endif
97private:
98 QMYSQLResultPrivate* d;
99};
100
101class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver
102{
103 Q_OBJECT
104 friend class QMYSQLResult;
105public:
106 explicit QMYSQLDriver(QObject *parent=0);
107 explicit QMYSQLDriver(MYSQL *con, QObject * parent=0);
108 ~QMYSQLDriver();
109 bool hasFeature(DriverFeature f) const;
110 bool open(const QString & db,
111 const QString & user,
112 const QString & password,
113 const QString & host,
114 int port,
115 const QString& connOpts);
116 void close();
117 QSqlResult *createResult() const;
118 QStringList tables(QSql::TableType) const;
119 QSqlIndex primaryIndex(const QString& tablename) const;
120 QSqlRecord record(const QString& tablename) const;
121 QString formatValue(const QSqlField &field,
122 bool trimStrings) const;
123 QVariant handle() const;
124 QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
125
126protected:
127 bool beginTransaction();
128 bool commitTransaction();
129 bool rollbackTransaction();
130private:
131 void init();
132 QMYSQLDriverPrivate* d;
133};
134
135QT_END_NAMESPACE
136
137QT_END_HEADER
138
139#endif // QSQL_MYSQL_H
Note: See TracBrowser for help on using the repository browser.