15#include "private/qsqldriver_p.h"
35 return u -
'a' < 26 || u -
'A' < 26 || u -
'0' < 10 || u ==
'_';
50 if (!closingQuote.
isNull()) {
51 if (
ch == closingQuote) {
52 if (closingQuote == u
']'
53 &&
i + 1 <
n &&
query.at(
i + 1) == closingQuote) {
58 closingQuote =
QChar();
66 if (
ch == u
'\'' ||
ch == u
'"' ||
ch == u
'`')
68 else if (!ignoreBraces &&
ch == u
'[')
98 if (!closingQuote.
isNull()) {
99 if (
ch == closingQuote) {
100 if (closingQuote == u
']'
101 &&
i + 1 <
n &&
query.at(
i + 1) == closingQuote) {
106 closingQuote =
QChar();
113 && (
i == 0 ||
query.at(
i - 1) != u
':')
124 if (
ch == u
'\'' ||
ch == u
'"' ||
ch == u
'`')
126 else if (!ignoreBraces &&
ch == u
'[')
347 d->executedQuery =
d->sql;
508 return d->forwardOnly;
538 d->forwardOnly = forward;
561 d->executedQuery =
d->namedToPositionalBinding(
query);
564 d->executedQuery =
d->positionalToNamedBinding(
query);
580 if (
d->holders.isEmpty()) {
582 d->namedToPositionalBinding(
query);
593 case qMetaTypeId<QString>():
595 case qMetaTypeId<QByteArray>():
597 case qMetaTypeId<QDateTime>():
600 case qMetaTypeId<QDate>():
602 case qMetaTypeId<QTime>():
605 case qMetaTypeId<QUuid>():
628 const QString &holder =
d->holders.at(
i).holderName;
629 const QVariant val =
d->values.value(
d->indexes.value(holder).value(0,-1));
636 holder.size(),
driver()->formatValue(
f));
677 if (
d->values.size() <=
index)
678 d->values.resize(
index + 1);
680 if (paramType !=
QSql::In || !
d->types.isEmpty())
681 d->types[
index] = paramType;
695 QSql::ParamType paramType)
701 const QList<int> indexes =
d->indexes.value(placeholder);
702 for (
int idx : indexes) {
703 if (
d->values.size() <= idx)
704 d->values.resize(idx + 1);
705 d->values[idx] =
val;
706 if (paramType !=
QSql::In || !
d->types.isEmpty())
707 d->types[idx] = paramType;
734 return d->values.value(
index);
748 const QList<int> indexes =
d->indexes.value(placeholder);
749 return d->values.value(indexes.
value(0,-1));
772 return d->types.value(
d->indexes.value(placeholder).value(0,-1),
QSql::In);
783 return d->values.size();
843 return d->executedQuery;
864 for (
const QHolder &holder : std::as_const(
d->holders))
865 ret.push_back(holder.holderName);
878 return d->holderAt(
index);
890 if (
d->types.isEmpty())
893 for (
it =
d->types.constBegin();
it !=
d->types.constEnd(); ++
it) {
1004 return d->precisionPolicy;
constexpr bool isNull() const noexcept
Returns true if the character is the Unicode character 0x0000 ('\0'); otherwise returns false.
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
void append(parameter_type t)
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
DbmsType dbmsType() const
The QSqlError class provides SQL database error information.
The QSqlField class manipulates the fields in SQL database tables and views.
The QSqlRecord class encapsulates a database record.
QString holderAt(int index) const
QString namedToPositionalBinding(const QString &query)
QString positionalToNamedBinding(const QString &query) const
static bool isVariantNull(const QVariant &variant)
QPointer< QSqlDriver > sqldriver
virtual QString fieldSerial(qsizetype) const
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
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 execBatch(bool arrayBind=false)
virtual void virtual_hook(int id, void *data)
virtual void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy)
virtual void detachFromResultSet()
int at() const
Returns the current (zero-based) row position of 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...
BindingSyntax
This enum type specifies the different syntaxes for specifying placeholders in prepared queries.
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 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 ~QSqlResult()
Destroys the object and frees any allocated resources.
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
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 void setActive(bool a)
This function is provided for derived classes to set the internal active state to active.
virtual bool fetchPrevious()
Positions the result to the previous record (row) in the result.
virtual bool nextResult()
virtual bool fetch(int i)=0
Positions the result to an arbitrary (zero-based) row index.
QVariantList & boundValues(QT6_DECL_NEW_OVERLOAD)
virtual QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
virtual bool fetchNext()
Positions the result to the next available record (row) in the result.
void resetBindCount()
Resets the number of bind parameters.
QSqlResult(const QSqlDriver *db)
Creates a QSqlResult using database driver db.
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
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
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.
const QSqlDriver * driver() const
Returns the driver associated with the result.
QString boundValueName(int pos) const
Returns the name of the bound value at position index in the current record (row).
bool isValid() const
Returns true if the result is positioned on a valid record (that is, the result is not positioned bef...
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).
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
QSqlResultPrivate * d_ptr
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
\inmodule QtCore \reentrant
int typeId() const
Returns the storage type of the value stored in the variant.
bool isNull() const
Returns true if this is a null variant, false otherwise.
QMetaType metaType() const
const void * constData() const
QSet< QString >::iterator it
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
GLenum GLsizei GLsizei GLint * values
[15]
GLenum GLenum GLsizei count
static bool qIsAlnum(QChar ch)
#define QT6_IMPL_NEW_OVERLOAD
selection select(topLeft, bottomRight)
bool contains(const AT &t) const noexcept