|
| | Transaction (const QSqlDatabase &db=QSqlDatabase()) |
| |
| | Transaction (Transaction &&other) |
| |
| Transaction & | operator= (Transaction &&other) |
| |
| | ~Transaction () |
| |
| bool | commit () |
| | Commits transaction. More...
|
| |
| bool | rollback () |
| | Rolls back transaction. More...
|
| |
| bool | started () const |
| | Returns true if the transaction has been started successfully. Otherwise it returns false. More...
|
| |
| bool | commited () const |
| | Returns true if the transaction has been commited successfully. Otherwise it returns false. More...
|
| |
| | Database (const QSqlDatabase &db=QSqlDatabase()) |
| |
| | Database (Database &&other) |
| |
| Database & | operator= (Database &&other) |
| |
| QSqlError | lastError () const |
| | Returns information about the last error that occurred on the underlying database. More...
|
| |
| NonQueryResult | execNonQuery (const QString &sql) const |
| | Executes non-query SQL statement (DELETE, INSERT, UPDATE, CREATE, ALTER, etc.) More...
|
| |
| QueryResult | execQuery (const QString &sql) const |
| | Executes SELECT query. More...
|
| |
| InsertQuery | insertInto (const QString &table) const |
| | Creates INSERT query wrapper. More...
|
| |
| DeleteQuery | deleteFrom (const QString &table) const |
| | Creates DELETE query wrapper. More...
|
| |
| UpdateQuery | update (const QString &table) const |
| | Creates UPDATE query wrapper. More...
|
| |
| PreparedQuery | prepare (const QString &sql, bool forwardOnly=true) const |
| | Prepares SQL statement. More...
|
| |
| QSqlDatabase & | qSqlDatabase () |
| | Returns a reference to the wrapped QSqlDatabase object. More...
|
| |
| template<typename Func > |
| int | each (const QString &query, Func &&f) const |
| | Executes query and applies function f to each result row. More...
|
| |
| template<typename Func > |
| int | first (const QString &query, Func &&f) const |
| | Executes query and applies function f to the first result row. More...
|
| |
| template<typename Func > |
| int | range (const QString &query, int start, int count, Func &&f) const |
| | Executes query and applies function f to count result rows starting from index start. More...
|
| |
| template<typename Func > |
| int | top (const QString &query, int topCount, Func &&f) const |
| | Executes query and applies function f to topCount result rows. More...
|
| |
| template<typename T > |
| T | scalar (const QString &query) const |
| | Executes query and returns scalar value converted to T. More...
|
| |
| QVariant | scalar (const QString &query) const |
| | Executes query and returns scalar value. More...
|
| |
QSqlDatabase transaction wrapper.
Features:
void test()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
db.open();
try
{
t.
execNonQuery(
"CREATE TABLE table (a int, b int, c int, d text)");
{
QVariantMap map = res.
toMap();
qDebug() << map;
}
.
where(
"c = ? OR c = ?", 3, 6);
{
QVariantMap map = res.
toMap();
qDebug() << map;
}
{
}
}