14#include "private/qsqlnulldriver_p.h"
216#if QT_DEPRECATED_SINCE(6, 2)
280 if (!
query.isEmpty())
378 qWarning(
"QSqlQuery::exec: called before driver has been set up");
395 qWarning(
"QSqlQuery::exec: database not open");
398 if (
query.isEmpty()) {
399 qWarning(
"QSqlQuery::exec: empty query");
435 qWarning(
"QSqlQuery::value: not positioned on a valid record");
575 actualIdx =
index - 1;
599 qWarning(
"QSqlQuery::seek: cannot seek backwards in a forward only query");
609 if (actualIdx == (
at() - 1)) {
705 qWarning(
"QSqlQuery::seek: cannot seek backwards in a forward only query");
738 qWarning(
"QSqlQuery::seek: cannot seek backwards in a forward only query");
979 qWarning(
"QSqlQuery::prepare: no driver");
983 qWarning(
"QSqlQuery::prepare: database not open");
986 if (
query.isEmpty()) {
987 qWarning(
"QSqlQuery::prepare: empty query");
991 qDebug(
"\n QSqlQuery::prepare: %s",
query.toLocal8Bit().constData());
1018 qDebug().nospace() <<
"Executed prepared query (" <<
t.elapsed() <<
"ms, "
1095 QSql::ParamType paramType
T loadRelaxed() const noexcept
The QSqlDatabase class handles a connection to a database.
bool isValid() const
Returns true if the QSqlDatabase has a valid driver.
QSqlDriver * driver() const
Returns the database driver used to access the database connection.
static const char * defaultConnection
static QSqlDatabase database(const QString &connectionName=QLatin1StringView(defaultConnection), bool open=true)
\threadsafe
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
virtual QSqlResult * createResult() const =0
Creates an empty SQL result on the database.
virtual bool hasFeature(DriverFeature f) const =0
Returns true if the driver supports feature feature; otherwise returns false.
The QSqlError class provides SQL database error information.
bool isValid() const
Returns true if an error is set, otherwise false.
QSqlQueryPrivate(QSqlResult *result)
static QSqlQueryPrivate * shared_null()
The QSqlQuery class provides a means of executing and manipulating SQL statements.
QSqlQuery & operator=(const QSqlQuery &other)=delete
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
bool last()
Retrieves the last record in the result, if available, and positions the query on the retrieved recor...
const QSqlDriver * driver() const
Returns the database driver associated with the query.
bool previous()
Retrieves the previous record in the result, if available, and positions the query on the retrieved r...
QStringList boundValueNames() const
bool prepare(const QString &query)
Prepares the SQL query query for execution.
QVariant value(int i) const
Returns the value of field index in the current record.
int size() const
Returns the size of the result (number of rows returned), or -1 if the size cannot be determined or i...
int numRowsAffected() const
Returns the number of rows affected by the result's SQL statement, or -1 if it cannot be determined.
const QSqlResult * result() const
Returns the result associated with the query.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
Returns the current precision policy.
bool first()
Retrieves the first record in the result, if available, and positions the query on the retrieved reco...
QVariant boundValue(const QString &placeholder) const
Returns the value for the placeholder.
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)
Instruct the database driver to return numerical values with a precision specified by precisionPolicy...
bool isForwardOnly() const
Returns true if you can only scroll forward through a result set; otherwise returns false.
QString boundValueName(int pos) const
void clear()
Clears the result set and releases any resources held by the query.
QSqlError lastError() const
Returns error information about the last error (if any) that occurred with this query.
BatchExecutionMode
\value ValuesAsRows - Updates multiple rows.
QSqlRecord record() const
Returns a QSqlRecord containing the field information for the current query.
QString lastQuery() const
Returns the text of the current query being used, or an empty string if there is no current query tex...
bool isActive() const
Returns true if the query is {active}.
QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
void setForwardOnly(bool forward)
Sets forward only mode to forward.
int at() const
Returns the current internal position of the query.
bool exec()
Executes a previously prepared SQL query.
void bindValue(const QString &placeholder, const QVariant &val, QSql::ParamType type=QSql::In)
Set the placeholder placeholder to be bound to value val in the prepared statement.
QVariantList boundValues() const
bool isSelect() const
Returns true if the current query is a SELECT statement; otherwise returns false.
QSqlQuery(QSqlResult *r)
Constructs a QSqlQuery object which uses the QSqlResult result to communicate with a database.
void addBindValue(const QVariant &val, QSql::ParamType type=QSql::In)
Adds the value val to the list of values when using positional value binding.
bool isNull(int field) const
Returns true if the query is not \l{isActive()}{active}, the query is not positioned on a valid recor...
~QSqlQuery()
Destroys the object and frees any allocated resources.
bool isValid() const
Returns true if the query is currently positioned on a valid record; otherwise returns false.
bool execBatch(BatchExecutionMode mode=ValuesAsRows)
bool seek(int i, bool relative=false)
Retrieves the record at position index, if available, and positions the query on the retrieved record...
QString executedQuery() const
Returns the last query that was successfully executed.
The QSqlRecord class encapsulates a database record.
int count() const
Returns the number of fields in the record.
void setValue(int i, const QVariant &val)
Sets the value of the field at position index to val.
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found.
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.
virtual bool isNull(int i)=0
Returns true if the field at position index in the current row is null; otherwise returns false.
QString executedQuery() const
Returns the query that was actually executed.
void clear()
Clears the entire result set and releases any associated resources.
virtual bool execBatch(bool arrayBind=false)
virtual QVariant data(int i)=0
Returns the data for field index in the current row as a QVariant.
virtual void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy)
virtual void detachFromResultSet()
int at() const
Returns the current (zero-based) row position of the result.
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 ...
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 bool fetchLast()=0
Positions the result to the last record (last row) in the result.
QString lastQuery() const
Returns the current SQL query text, or an empty string if there isn't one.
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 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
virtual int size()=0
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
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.
virtual int numRowsAffected()=0
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
virtual QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
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.
virtual bool reset(const QString &sqlquery)=0
Sets the result to use the SQL statement query for subsequent data retrieval.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
QT_WARNING_POP void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLenum GLsizei GLsizei GLint * values
[15]
GLdouble GLdouble GLdouble GLdouble q
static void qInit(QSqlQuery *q, const QString &query, const QSqlDatabase &db)
#define qPrintable(string)