BPS C++ API  2.24.4
bpsquery.h
Go to the documentation of this file.
1 
4 #ifndef BPSQUERY_H
5 #define BPSQUERY_H
6 
7 #include "bpscore_global.h"
8 #include <QObject>
9 #include <QScriptable>
10 #include <QVariant>
11 
12 class BpsDatastore;
13 class BpsSqlValues;
14 class QSqlQuery;
15 class QSqlRecord;
16 
22 class BPSCORE_EXPORT BpsQuery : public QObject, protected QScriptable
23 {
24  Q_OBJECT
26 
27 public:
28 
33  BpsQuery(BpsDatastore* aDatastore);
34 
35  virtual ~BpsQuery();
36 
40  bool isValid() const;
41 
45  bool isActive() const;
46 
50  bool isSelect() const;
51 
56  bool isForwardOnly() const;
57 
67  void setForwardOnly(bool aForward = true);
68 
76  void prepare(const QString& aSql);
77 
82  void bind(const QVariant& aValue);
83 
88  void bind(const QVariantList& aValues);
89 
94  void execute(const QString& aSql = QString());
95 
102  void execute(const QVariant& aValue);
103 
110  void execute(const QVariantList& aValues);
111 
116 
120  void clear();
121 
129  bool first();
130 
138  bool last();
139 
155  bool next();
156 
171  bool previous();
172 
196  bool seek(int aIndex, bool aRelative = false);
197 
203  bool isNull(int aField) const;
204 
210  int numRowsAffected() const;
211 
218  int size() const;
219 
226  int at() const;
227 
233  QVariant value(int aField) const;
234 
240 
246 
251  QVariantMap valuesAsMap() const;
252 
256  QVariantList valuesAsList() const;
257 
261  QString sql() const;
262 
266  QSqlQuery* query() const;
267 
268 }; // BpsQuery
269 
270 #endif // BPSQUERY_H
Public include file for BPS CORE library macros.
#define BPSCORE_EXPORT
Declare class to be an import from the shared library.
Definition: bpscore_global.h:22
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
BPS datastore class.
Definition: bpsdatastore.h:61
BPS query class.
Definition: bpsquery.h:23
QSqlRecord record() const
int size() const
QVariantMap valuesAsMap() const
QVariantList valuesAsList() const
void bind(const QVariantList &aValues)
Bind a list of value to a SQL parameter.
void execute(const QVariantList &aValues)
Execute a query.
BpsQuery(BpsDatastore *aDatastore)
Constructor for BpsQuery objects.
bool isNull(int aField) const
Check if a value of the current cursor row is NULL.
bool previous()
Retrieves the previous record in the result, if available, and positions the query on the retrieved r...
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
QSqlQuery * query() const
QString sql() const
bool last()
Retrieves the last record in the result, if available, and positions the query on the retrieved recor...
int at() const
bool isValid() const
bool isActive() const
bool seek(int aIndex, bool aRelative=false)
Retrieves the record at position index, if available, and positions the query on the retrieved record...
void execute(const QString &aSql=QString())
Execute a query.
bool isForwardOnly() const
int numRowsAffected() const
QVariant value(int aField) const
Get a field value from the current cursor row.
void execute(const QVariant &aValue)
Execute a query.
BpsSqlValues values() const
void bind(const QVariant &aValue)
Bind a value to a SQL parameter.
void setForwardOnly(bool aForward=true)
Enable or disable forward only mode.
BpsDatastore * datastore() const
void clear()
Clears the result set and releases any local or database resources held by the query.
void prepare(const QString &aSql)
Prepare a SQL statement.
bool isSelect() const
bool first()
Retrieves the first record in the result, if available, and positions the query on the retrieved reco...
Convenience class to help composing select, insert and update statements.
Definition: bpssqlvalues.h:54