QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution.
More...
#include <EasyQtSql_UpdateQuery.h>
QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution.
◆ UpdateQuery()
UpdateQuery::UpdateQuery |
( |
const QString & |
table, |
|
|
const QSqlDatabase & |
db |
|
) |
| |
|
inline |
◆ exec()
Executes UPDATE query without conditions.
◆ set() [1/2]
UpdateQuery& UpdateQuery::set |
( |
const QString & |
field, |
|
|
const QVariant & |
value |
|
) |
| |
|
inline |
Sets table field to value
- Parameters
-
field | Table field name |
value | Value to set |
- Returns
- UpdateQuery reference
The method returns an UpdateQuery reference so its call can be chained:
◆ set() [2/2]
UpdateQuery& UpdateQuery::set |
( |
const QVariantMap & |
map | ) |
|
|
inline |
Sets table fields to values from map
- Parameters
-
map | Values map. Map key is field name, map value is field value. |
The method returns an UpdateQuery reference so its calls can be chained.
.
set(QVariantMap{ {
"a", 111}, {
"b", 222} })
◆ where() [1/3]
Executes update query with expr condition.
- Parameters
-
.
set(QVariantMap{ {
"a", 111}, {
"b", 222} })
◆ where() [2/3]
NonQueryResult UpdateQuery::where |
( |
const QString & |
expr, |
|
|
const QVariant & |
last |
|
) |
| |
|
inline |
Executes update query with expr condition and last parameter binding.
- Parameters
-
expr | WHERE condition |
last | Parameter to bind on WHERE expression |
The method supports variable count of QVariant parameters. Parameters are bound with QSqlQuery::addBindValue.
.
set(QVariantMap{ {
"a", 111}, {
"b", 222} })
.
where(
"a=? AND b=?", 1, 2);
◆ where() [3/3]
template<typename... Rest>
NonQueryResult UpdateQuery::where |
( |
const QString & |
expr, |
|
|
const QVariant & |
first, |
|
|
const Rest &... |
rest |
|
) |
| |
|
inline |
The documentation for this class was generated from the following file: