- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qsql_mysql.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtSql module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QSQL_MYSQL_H
    00043 #define QSQL_MYSQL_H
    00044
    00045 #include <QtSql/qsqldriver.h>
    00046 #include <QtSql/qsqlresult.h>
    00047
    00048 #if defined (Q_OS_WIN32)
    00049 #include <QtCore/qt_windows.h>
    00050 #endif
    00051
    00052 #include <mysql.h>
    00053
    00054 #ifdef QT_PLUGIN
    00055 #define Q_EXPORT_SQLDRIVER_MYSQL
    00056 #else
    00057 #define Q_EXPORT_SQLDRIVER_MYSQL Q_SQL_EXPORT
    00058 #endif
    00059
    00060 QT_BEGIN_HEADER
    00061
    00062 QT_BEGIN_NAMESPACE
    00063
    00064 class QMYSQLDriverPrivate;
    00065 class QMYSQLResultPrivate;
    00066 class QMYSQLDriver;
    00067 class QSqlRecordInfo;
    00068
    00069 class QMYSQLResult : public QSqlResult
    00070 {
    00071     friend class QMYSQLDriver;
    00072     friend class QMYSQLResultPrivate;
    00073 public:
    00074     explicit QMYSQLResult(const QMYSQLDriver* db);
    00075     ~QMYSQLResult();
    00076
    00077     QVariant handle() const;
    00078 protected:
    00079     void cleanup();
    00080     bool fetch(int i);
    00081     bool fetchNext();
    00082     bool fetchLast();
    00083     bool fetchFirst();
    00084     QVariant data(int field);
    00085     bool isNull(int field);
    00086     bool reset (const QString& query);
    00087     int size();
    00088     int numRowsAffected();
    00089     QVariant lastInsertId() const;
    00090     QSqlRecord record() const;
    00091     void virtual_hook(int id, void *data);
    00092     bool nextResult();
    00093
    00094 #if MYSQL_VERSION_ID >= 40108
    00095     bool prepare(const QString& stmt);
    00096     bool exec();
    00097 #endif
    00098 private:
    00099     QMYSQLResultPrivate* d;
    00100 };
    00101
    00102 class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver
    00103 {
    00104     Q_OBJECT
    00105     friend class QMYSQLResult;
    00106 public:
    00107     explicit QMYSQLDriver(QObject *parent=0);
    00108     explicit QMYSQLDriver(MYSQL *con, QObject * parent=0);
    00109     ~QMYSQLDriver();
    00110     bool hasFeature(DriverFeature f) const;
    00111     bool open(const QString & db,
    00112                const QString & user,
    00113                const QString & password,
    00114                const QString & host,
    00115                int port,
    00116                const QString& connOpts);
    00117     void close();
    00118     QSqlResult *createResult() const;
    00119     QStringList tables(QSql::TableType) const;
    00120     QSqlIndex primaryIndex(const QString& tablename) const;
    00121     QSqlRecord record(const QString& tablename) const;
    00122     QString formatValue(const QSqlField &field,
    00123                                      bool trimStrings) const;
    00124     QVariant handle() const;
    00125     QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
    00126
    00127 protected Q_SLOTS:
    00128     bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
    00129
    00130 protected:
    00131     bool beginTransaction();
    00132     bool commitTransaction();
    00133     bool rollbackTransaction();
    00134 private:
    00135     void init();
    00136     QMYSQLDriverPrivate* d;
    00137 };
    00138
    00139 QT_END_NAMESPACE
    00140
    00141 QT_END_HEADER
    00142
    00143 #endif // QSQL_MYSQL_H