Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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