src/sql/kernel/qsqlquery.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtSql module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QSQLQUERY_H
       
    43 #define QSQLQUERY_H
       
    44 
       
    45 #include <QtSql/qsql.h>
       
    46 #include <QtSql/qsqldatabase.h>
       
    47 #include <QtCore/qstring.h>
       
    48 
       
    49 QT_BEGIN_HEADER
       
    50 
       
    51 QT_BEGIN_NAMESPACE
       
    52 
       
    53 QT_MODULE(Sql)
       
    54 
       
    55 class QVariant;
       
    56 class QSqlDriver;
       
    57 class QSqlError;
       
    58 class QSqlResult;
       
    59 class QSqlRecord;
       
    60 template <class Key, class T> class QMap;
       
    61 class QSqlQueryPrivate;
       
    62 
       
    63 class Q_SQL_EXPORT QSqlQuery
       
    64 {
       
    65 public:
       
    66     QSqlQuery(QSqlResult *r);
       
    67     QSqlQuery(const QString& query = QString(), QSqlDatabase db = QSqlDatabase());
       
    68     explicit QSqlQuery(QSqlDatabase db);
       
    69     QSqlQuery(const QSqlQuery& other);
       
    70     QSqlQuery& operator=(const QSqlQuery& other);
       
    71     ~QSqlQuery();
       
    72 
       
    73     bool isValid() const;
       
    74     bool isActive() const;
       
    75     bool isNull(int field) const;
       
    76     int at() const;
       
    77     QString lastQuery() const;
       
    78     int numRowsAffected() const;
       
    79     QSqlError lastError() const;
       
    80     bool isSelect() const;
       
    81     int size() const;
       
    82     const QSqlDriver* driver() const;
       
    83     const QSqlResult* result() const;
       
    84     bool isForwardOnly() const;
       
    85     QSqlRecord record() const;
       
    86 
       
    87     void setForwardOnly(bool forward);
       
    88     bool exec(const QString& query);
       
    89     QVariant value(int i) const;
       
    90 
       
    91     void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
       
    92     QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
       
    93 
       
    94     bool seek(int i, bool relative = false);
       
    95     bool next();
       
    96     bool previous();
       
    97 #ifdef QT3_SUPPORT
       
    98     inline QT3_SUPPORT bool prev() { return previous(); }
       
    99 #endif
       
   100     bool first();
       
   101     bool last();
       
   102 
       
   103     void clear();
       
   104 
       
   105     // prepared query support
       
   106     bool exec();
       
   107     enum BatchExecutionMode { ValuesAsRows, ValuesAsColumns };
       
   108     bool execBatch(BatchExecutionMode mode = ValuesAsRows);
       
   109     bool prepare(const QString& query);
       
   110     void bindValue(const QString& placeholder, const QVariant& val,
       
   111                    QSql::ParamType type = QSql::In);
       
   112     void bindValue(int pos, const QVariant& val, QSql::ParamType type = QSql::In);
       
   113     void addBindValue(const QVariant& val, QSql::ParamType type = QSql::In);
       
   114     QVariant boundValue(const QString& placeholder) const;
       
   115     QVariant boundValue(int pos) const;
       
   116     QMap<QString, QVariant> boundValues() const;
       
   117     QString executedQuery() const;
       
   118     QVariant lastInsertId() const;
       
   119     void finish();
       
   120     bool nextResult();
       
   121 
       
   122 private:
       
   123     QSqlQueryPrivate* d;
       
   124 };
       
   125 
       
   126 QT_END_NAMESPACE
       
   127 
       
   128 QT_END_HEADER
       
   129 
       
   130 #endif // QSQLQUERY_H