Eneboo - Documentación para desarrolladores
src/qt/include/qsqlquery.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 **
00003 ** Definition of QSqlQuery class
00004 **
00005 ** Created : 2000-11-03
00006 **
00007 ** Copyright (C) 2005-2007 Trolltech ASA.  All rights reserved.
00008 **
00009 ** This file is part of the sql module of the Qt GUI Toolkit.
00010 **
00011 ** This file may be distributed under the terms of the Q Public License
00012 ** as defined by Trolltech ASA of Norway and appearing in the file
00013 ** LICENSE.QPL included in the packaging of this file.
00014 **
00015 ** This file may be distributed and/or modified under the terms of the
00016 ** GNU General Public License version 2 as published by the Free Software
00017 ** Foundation and appearing in the file LICENSE.GPL included in the
00018 ** packaging of this file.
00019 **
00020 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00021 ** file in accordance with the Qt Commercial License Agreement provided
00022 ** with the Software.
00023 **
00024 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00025 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00026 **
00027 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00028 **   information about Qt Commercial License Agreements.
00029 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00030 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00031 **
00032 ** Contact info@trolltech.com if any conditions of this licensing are
00033 ** not clear to you.
00034 **
00035 **********************************************************************/
00036 
00037 #ifndef QSQLQUERY_H
00038 #define QSQLQUERY_H
00039 
00040 #ifndef QT_H
00041 #include "qobject.h"
00042 #include "qstring.h"
00043 #include "qvariant.h"
00044 #include "qvaluelist.h"
00045 #include "qsqlerror.h"
00046 #include "qsqlfield.h"
00047 #include "qsql.h"
00048 #endif // QT_H
00049 
00050 #ifndef QT_NO_SQL
00051 
00052 class QSqlDriver;
00053 class QSqlResult;
00054 class QSqlDatabase;
00055 
00056 class Q_EXPORT QSqlResultShared : public QObject, public QShared
00057 {
00058     Q_OBJECT
00059 public:
00060     QSqlResultShared( QSqlResult* result );
00061     virtual ~QSqlResultShared();
00062     QSqlResult* sqlResult;
00063     QString executedQuery;
00064 private slots:
00065     void slotResultDestroyed();
00066 };
00067 
00068 class Q_EXPORT QSqlQuery
00069 {
00070 public:
00071     QSqlQuery( QSqlResult * r );
00072     QSqlQuery( const QString& query = QString::null, QSqlDatabase* db = 0 );
00073     Q_EXPLICIT QSqlQuery( QSqlDatabase* db );
00074     QSqlQuery( const QSqlQuery& other );
00075     QSqlQuery& operator=( const QSqlQuery& other );
00076     virtual ~QSqlQuery();
00077 
00078     bool                isValid() const;
00079     bool                isActive() const;
00080     bool                isNull( int field ) const;
00081     int                 at() const;
00082     QString             lastQuery() const;
00083     int                 numRowsAffected() const;
00084 //### AbanQ
00085     //QSqlError         lastError() const;
00086     virtual QSqlError   lastError() const;
00087     bool                isSelect() const;
00088     int                 size() const;
00089     const QSqlDriver*   driver() const;
00090     const QSqlResult*   result() const;
00091     bool                isForwardOnly() const;
00092     void                setForwardOnly( bool forward );
00093 
00094     virtual bool        exec ( const QString& query );
00095     virtual QVariant    value( int i ) const;
00096 
00097     virtual bool        seek( int i, bool relative = FALSE );
00098     virtual bool        next();
00099     virtual bool        prev();
00100     virtual bool        first();
00101     virtual bool        last();
00102 
00103     // prepared query support
00104     bool                exec();
00105     bool                prepare( const QString& query );
00106     void                bindValue( const QString& placeholder, const QVariant& val );
00107     void                bindValue( int pos, const QVariant& val );
00108     void                addBindValue( const QVariant& val );
00109     // remove these overloads in 4.0
00110     void                bindValue( const QString& placeholder, const QVariant& val, QSql::ParameterType type );
00111     void                bindValue( int pos, const QVariant& val, QSql::ParameterType type );
00112     void                addBindValue( const QVariant& val, QSql::ParameterType type );
00113     QVariant            boundValue( const QString& placeholder ) const;
00114     QVariant            boundValue( int pos ) const;
00115     QMap<QString, QVariant> boundValues() const;
00116     QString             executedQuery() const;
00117     
00118 protected:
00119     virtual void        beforeSeek();
00120     virtual void        afterSeek();
00121 
00122 private:
00123     void                init( const QString& query, QSqlDatabase* db );
00124     void                deref();
00125     bool                checkDetach();
00126     QSqlResultShared*   d;
00127 };
00128 
00129 
00130 #endif // QT_NO_SQL
00131 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'