Qt 4.8
qt-4.8.6
src
sql
kernel
qsqlresult.h
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
5
**
6
** This file is part of the QtSql module of the Qt Toolkit.
7
**
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
16
**
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
**
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
36
**
37
**
38
** $QT_END_LICENSE$
39
**
40
****************************************************************************/
41
42
#ifndef QSQLRESULT_H
43
#define QSQLRESULT_H
44
45
#include <QtCore/qvariant.h>
46
#include <QtCore/qvector.h>
47
#include <QtSql/qsql.h>
48
49
QT_BEGIN_HEADER
50
51
QT_BEGIN_NAMESPACE
52
53
QT_MODULE
(Sql)
54
55
class
QString
;
56
class
QSqlRecord
;
57
template
<
typename
T>
class
QVector
;
58
class
QVariant
;
59
class
QSqlDriver
;
60
class
QSqlError
;
61
class
QSqlResultPrivate
;
62
63
class
Q_SQL_EXPORT
QSqlResult
64
{
65
friend
class
QSqlQuery
;
66
friend
class
QSqlTableModelPrivate
;
67
friend
class
QSqlResultPrivate
;
68
69
public
:
70
virtual
~
QSqlResult
();
71
virtual
QVariant
handle()
const
;
72
73
protected
:
74
enum
BindingSyntax
{
75
PositionalBinding
,
76
NamedBinding
77
#ifdef QT3_SUPPORT
78
, BindByPosition = PositionalBinding,
79
BindByName = NamedBinding
80
#endif
81
};
82
83
explicit
QSqlResult
(
const
QSqlDriver
* db);
84
int
at
()
const
;
85
QString
lastQuery()
const
;
86
QSqlError
lastError()
const
;
87
bool
isValid()
const
;
88
bool
isActive()
const
;
89
bool
isSelect()
const
;
90
bool
isForwardOnly()
const
;
91
const
QSqlDriver
* driver()
const
;
92
virtual
void
setAt(
int
at
);
93
virtual
void
setActive(
bool
a
);
94
virtual
void
setLastError(
const
QSqlError
& e);
95
virtual
void
setQuery(
const
QString
& query);
96
virtual
void
setSelect(
bool
s);
97
virtual
void
setForwardOnly(
bool
forward);
98
99
// prepared query support
100
virtual
bool
exec();
101
virtual
bool
prepare(
const
QString
& query);
102
virtual
bool
savePrepare(
const
QString
& sqlquery);
103
virtual
void
bindValue(
int
pos,
const
QVariant
& val, QSql::ParamType
type
);
104
virtual
void
bindValue(
const
QString
& placeholder,
const
QVariant
& val,
105
QSql::ParamType
type
);
106
void
addBindValue(
const
QVariant
& val, QSql::ParamType
type
);
107
QVariant
boundValue(
const
QString
& placeholder)
const
;
108
QVariant
boundValue(
int
pos)
const
;
109
QSql::ParamType bindValueType(
const
QString
& placeholder)
const
;
110
QSql::ParamType bindValueType(
int
pos)
const
;
111
int
boundValueCount()
const
;
112
QVector<QVariant>
& boundValues()
const
;
113
QString
executedQuery
()
const
;
114
QString
boundValueName(
int
pos)
const
;
115
void
clear
();
116
bool
hasOutValues()
const
;
117
118
BindingSyntax
bindingSyntax()
const
;
119
120
virtual
QVariant
data
(
int
i) = 0;
121
virtual
bool
isNull
(
int
i) = 0;
122
virtual
bool
reset
(
const
QString
& sqlquery) = 0;
123
virtual
bool
fetch(
int
i) = 0;
124
virtual
bool
fetchNext();
125
virtual
bool
fetchPrevious();
126
virtual
bool
fetchFirst() = 0;
127
virtual
bool
fetchLast() = 0;
128
virtual
int
size() = 0;
129
virtual
int
numRowsAffected() = 0;
130
virtual
QSqlRecord
record()
const
;
131
virtual
QVariant
lastInsertId()
const
;
132
133
enum
VirtualHookOperation
{ BatchOperation, DetachFromResultSet, SetNumericalPrecision, NextResult };
134
virtual
void
virtual_hook(
int
id
,
void
*
data
);
135
bool
execBatch(
bool
arrayBind =
false
);
136
void
detachFromResultSet();
137
void
setNumericalPrecisionPolicy(
QSql::NumericalPrecisionPolicy
policy);
138
QSql::NumericalPrecisionPolicy
numericalPrecisionPolicy()
const
;
139
bool
nextResult();
140
141
private
:
142
QSqlResultPrivate
*
d
;
143
void
resetBindCount
();
// HACK
144
145
private
:
146
Q_DISABLE_COPY
(
QSqlResult
)
147
};
148
149
QT_END_NAMESPACE
150
151
QT_END_HEADER
152
153
#endif // QSQLRESULT_H
QVariant
The QVariant class acts like a union for the most common Qt data types.
Definition:
qvariant.h:92
QSqlError
The QSqlError class provides SQL database error information.
Definition:
qsqlerror.h:53
QSqlResultPrivate::resetBindCount
void resetBindCount()
Definition:
qsqlresult.cpp:78
QSql::NumericalPrecisionPolicy
NumericalPrecisionPolicy
Definition:
qsql.h:82
type
int type
Definition:
qmetatype.cpp:239
QT_END_NAMESPACE
#define QT_END_NAMESPACE
This macro expands to.
Definition:
qglobal.h:90
QT_MODULE
#define QT_MODULE(x)
Definition:
qglobal.h:2783
QT_BEGIN_HEADER
#define QT_BEGIN_HEADER
Definition:
qglobal.h:136
QSqlTableModelPrivate
Definition:
qsqltablemodel_p.h:61
at
#define at(className, varName)
Definition:
qbuiltintypes.cpp:73
reset
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
QSqlQuery
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition:
qsqlquery.h:63
clear
static void clear(QVariant::Private *d)
Definition:
qvariant.cpp:197
QSqlResult::PositionalBinding
Definition:
qsqlresult.h:75
QSqlResult::VirtualHookOperation
VirtualHookOperation
Definition:
qsqlresult.h:133
Q_DISABLE_COPY
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition:
qglobal.h:2523
a
long ASN1_INTEGER_get ASN1_INTEGER * a
Definition:
qsslsocket_openssl_symbols.cpp:104
QSqlRecord
The QSqlRecord class encapsulates a database record.
Definition:
qsqlrecord.h:58
QSqlDriver
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
Definition:
qsqldriver.h:68
QString
The QString class provides a Unicode character string.
Definition:
qstring.h:83
QVector
The QVector class is a template class that provides a dynamic array.
Definition:
qdatastream.h:64
QSqlResultPrivate::executedQuery
QString executedQuery
Definition:
qsqlresult.cpp:114
Q_SQL_EXPORT
#define Q_SQL_EXPORT
Definition:
qglobal.h:1451
QSqlResult::d
QSqlResultPrivate * d
Definition:
qsqlresult.h:142
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition:
qglobal.h:89
data
static const char * data(const QByteArray &arr)
Definition:
qdbusmessage.cpp:60
QSqlResult::BindingSyntax
BindingSyntax
This enum type specifies the different syntaxes for specifying placeholders in prepared queries...
Definition:
qsqlresult.h:74
QSqlResultPrivate
Definition:
qsqlresult.cpp:64
QT_END_HEADER
#define QT_END_HEADER
Definition:
qglobal.h:137
QSqlResult
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
Definition:
qsqlresult.h:63
isNull
static bool isNull(const QVariant::Private *d)
Definition:
qvariant.cpp:300
Qt 4.8 Source Code Browser