~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/sql/drivers/mysql/qsql_mysql.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the sql module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QSQL_MYSQL_H
 
30
#define QSQL_MYSQL_H
 
31
 
 
32
#include <QtSql/qsqldriver.h>
 
33
#include <QtSql/qsqlresult.h>
 
34
 
 
35
#if defined (Q_OS_WIN32)
 
36
#include <QtCore/qt_windows.h>
 
37
#endif
 
38
 
 
39
#include <mysql.h>
 
40
 
 
41
#ifdef QT_PLUGIN
 
42
#define Q_EXPORT_SQLDRIVER_MYSQL
 
43
#else
 
44
#define Q_EXPORT_SQLDRIVER_MYSQL Q_SQL_EXPORT
 
45
#endif
 
46
 
 
47
class QMYSQLDriverPrivate;
 
48
class QMYSQLResultPrivate;
 
49
class QMYSQLDriver;
 
50
class QSqlRecordInfo;
 
51
 
 
52
class QMYSQLResult : public QSqlResult
 
53
{
 
54
    friend class QMYSQLDriver;
 
55
public:
 
56
    explicit QMYSQLResult(const QMYSQLDriver* db);
 
57
    ~QMYSQLResult();
 
58
 
 
59
    QVariant handle() const;
 
60
protected:
 
61
    void cleanup();
 
62
    bool fetch(int i);
 
63
    bool fetchNext();
 
64
    bool fetchLast();
 
65
    bool fetchFirst();
 
66
    QVariant data(int field);
 
67
    bool isNull(int field);
 
68
    bool reset (const QString& query);
 
69
    int size();
 
70
    int numRowsAffected();
 
71
    QVariant lastInsertId() const;
 
72
    QSqlRecord record() const;
 
73
 
 
74
#if MYSQL_VERSION_ID >= 40108
 
75
    bool prepare(const QString& stmt);
 
76
    bool exec();
 
77
#endif
 
78
private:
 
79
    QMYSQLResultPrivate* d;
 
80
};
 
81
 
 
82
class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver
 
83
{
 
84
    friend class QMYSQLResult;
 
85
public:
 
86
    explicit QMYSQLDriver(QObject *parent=0);
 
87
    explicit QMYSQLDriver(MYSQL *con, QObject * parent=0);
 
88
    ~QMYSQLDriver();
 
89
    bool hasFeature(DriverFeature f) const;
 
90
    bool open(const QString & db,
 
91
               const QString & user,
 
92
               const QString & password,
 
93
               const QString & host,
 
94
               int port,
 
95
               const QString& connOpts);
 
96
    void close();
 
97
    QSqlResult *createResult() const;
 
98
    QStringList tables(QSql::TableType) const;
 
99
    QSqlIndex primaryIndex(const QString& tablename) const;
 
100
    QSqlRecord record(const QString& tablename) const;
 
101
    QString formatValue(const QSqlField &field,
 
102
                                     bool trimStrings) const;
 
103
    QVariant handle() const;
 
104
 
 
105
protected:
 
106
    bool beginTransaction();
 
107
    bool commitTransaction();
 
108
    bool rollbackTransaction();
 
109
private:
 
110
    void init();
 
111
    QMYSQLDriverPrivate* d;
 
112
};
 
113
 
 
114
#endif // QSQL_MYSQL_H