Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsqlresult.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QSQLRESULT_H
6#define QSQLRESULT_H
7
8#include <QtSql/qtsqlglobal.h>
9#include <QtCore/qvariant.h>
10#include <QtCore/qcontainerfwd.h>
11
13
14
15class QString;
16class QSqlRecord;
17class QVariant;
18class QSqlDriver;
19class QSqlError;
20class QSqlResultPrivate;
21
22class Q_SQL_EXPORT QSqlResult
23{
24 Q_DECLARE_PRIVATE(QSqlResult)
25 friend class QSqlQuery;
27
28public:
29 virtual ~QSqlResult();
30 virtual QVariant handle() const;
31
32protected:
33 enum BindingSyntax {
34 PositionalBinding,
35 NamedBinding
36 };
37
38 explicit QSqlResult(const QSqlDriver * db);
39 QSqlResult(QSqlResultPrivate &dd);
40 int at() const;
41 QString lastQuery() const;
42 QSqlError lastError() const;
43 bool isValid() const;
44 bool isActive() const;
45 bool isSelect() const;
46 bool isForwardOnly() const;
47 const QSqlDriver* driver() const;
48 virtual void setAt(int at);
49 virtual void setActive(bool a);
50 virtual void setLastError(const QSqlError& e);
51 virtual void setQuery(const QString& query);
52 virtual void setSelect(bool s);
53 virtual void setForwardOnly(bool forward);
54
55 // prepared query support
56 virtual bool exec();
57 virtual bool prepare(const QString& query);
58 virtual bool savePrepare(const QString& sqlquery);
59 virtual void bindValue(int pos, const QVariant& val, QSql::ParamType type);
60 virtual void bindValue(const QString& placeholder, const QVariant& val,
61 QSql::ParamType type);
62 void addBindValue(const QVariant& val, QSql::ParamType type);
63 QVariant boundValue(const QString& placeholder) const;
64 QVariant boundValue(int pos) const;
65 QSql::ParamType bindValueType(const QString& placeholder) const;
66 QSql::ParamType bindValueType(int pos) const;
67 int boundValueCount() const;
68#if QT_SQL_REMOVED_SINCE(6, 6)
69 QList<QVariant> &boundValues() const;
70#endif
73
74 QString executedQuery() const;
76 QString boundValueName(int pos) const;
77 void clear();
78 bool hasOutValues() const;
79
81
82 virtual QVariant data(int i) = 0;
83 virtual bool isNull(int i) = 0;
84 virtual bool reset(const QString& sqlquery) = 0;
85 virtual bool fetch(int i) = 0;
86 virtual bool fetchNext();
87 virtual bool fetchPrevious();
88 virtual bool fetchFirst() = 0;
89 virtual bool fetchLast() = 0;
90 virtual int size() = 0;
91 virtual int numRowsAffected() = 0;
92 virtual QSqlRecord record() const;
93 virtual QVariant lastInsertId() const;
94
96 virtual void virtual_hook(int id, void *data);
97 virtual bool execBatch(bool arrayBind = false);
98 virtual void detachFromResultSet();
99 virtual void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy);
101 void setPositionalBindingEnabled(bool enable);
102 bool isPositionalBindingEnabled() const;
103 virtual bool nextResult();
104 void resetBindCount(); // HACK
105
106 QSqlResultPrivate *d_ptr;
107
108private:
109 Q_DISABLE_COPY(QSqlResult)
110};
111
112QT_END_NAMESPACE
113
114#endif // QSQLRESULT_H
\inmodule QtCore
Definition qatomic.h:113
QSize size() const
Returns the size of the image, without actually reading the image contents.
GLuint handle() const
Returns the OpenGL framebuffer object handle for this framebuffer object (returned by the {glGenFrame...
void setActive(bool newState)
Sets the active state of the paint engine to state.
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
virtual bool isValid() const
QSqlQueryPrivate(QSqlResult *result)
Definition qsqlquery.cpp:51
QAtomicInt ref
Definition qsqlquery.cpp:31
QSqlResult * sqlResult
Definition qsqlquery.cpp:32
static QSqlQueryPrivate * shared_null()
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
Definition qsqlresult.h:23
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false.
virtual QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
QString executedQuery() const
Returns the query that was actually executed.
QSql::ParamType bindValueType(const QString &placeholder) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clear()
Clears the entire result set and releases any associated resources.
virtual bool isNull(int i)=0
Returns true if the field at position index in the current row is null; otherwise returns false.
virtual bool execBatch(bool arrayBind=false)
virtual void virtual_hook(int id, void *data)
virtual void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy)
virtual void detachFromResultSet()
bool isPositionalBindingEnabled() const
int at() const
Returns the current (zero-based) row position of the result.
virtual bool fetchLast()=0
Positions the result to the last record (last row) in the result.
virtual bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QVariant boundValue(const QString &placeholder) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual bool exec()
Executes the query, returning true if successful; otherwise returns false.
void setPositionalBindingEnabled(bool enable)
void addBindValue(const QVariant &val, QSql::ParamType type)
Binds the value val of parameter type paramType to the next available position in the current record ...
virtual QVariant data(int i)=0
Returns the data for field index in the current row as a QVariant.
friend class QSqlTableModelPrivate
Definition qsqlresult.h:26
virtual int numRowsAffected()=0
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
virtual bool fetch(int i)=0
Positions the result to an arbitrary (zero-based) row index.
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index.
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
QString lastQuery() const
Returns the current SQL query text, or an empty string if there isn't one.
bool hasOutValues() const
Returns true if at least one of the query's bound values is a QSql::Out or a QSql::InOut; otherwise r...
virtual bool fetchPrevious()
Positions the result to the previous record (row) in the result.
virtual bool nextResult()
virtual bool reset(const QString &sqlquery)=0
Sets the result to use the SQL statement query for subsequent data retrieval.
QVariantList & boundValues(QT6_DECL_NEW_OVERLOAD)
virtual void bindValue(const QString &placeholder, const QVariant &val, QSql::ParamType type)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual bool fetchNext()
Positions the result to the next available record (row) in the result.
void resetBindCount()
Resets the number of bind parameters.
virtual bool savePrepare(const QString &sqlquery)
Prepares the given query, using the underlying database functionality where possible.
QSqlError lastError() const
Returns the last error associated with the result.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
QSql::ParamType bindValueType(int pos) const
Returns the parameter type for the value bound at position index.
virtual bool fetchFirst()=0
Positions the result to the first record (row 0) in the result.
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
QVariant boundValue(int pos) const
Returns the value bound at position index in the current record (row).
virtual QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
BindingSyntax bindingSyntax() const
Returns the binding syntax used by prepared queries.
int boundValueCount() const
Returns the number of bound values in the result.
virtual void setQuery(const QString &query)
Sets the current query for the result to query.
QString boundValueName(int pos) const
Returns the name of the bound value at position index in the current record (row).
QStringList boundValueNames() const
Returns the names of all bound values.
virtual void setForwardOnly(bool forward)
Sets forward only mode to forward.
virtual void bindValue(int pos, const QVariant &val, QSql::ParamType type)
Binds the value val of parameter type paramType to position index in the current record (row).
#define qCWarning(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
DummyDriver * driver()