EasyQtSql
Easy SQL data access helper for QtSql
EasyQtSql::InsertQuery Class Reference

QSqlQuery wrapper for INSERT INTO table query execution. More...

#include <EasyQtSql.h>

Public Member Functions

 InsertQuery (const QString &table, const QSqlDatabase &db)
 
InsertQueryvalues (const QVariant &t)
 Adds list of insert-values to INSERT INTO table(...) VALUES ... query. More...
 
template<typename... Rest>
InsertQueryvalues (const QVariant &first, const Rest &... rest)
 
NonQueryResult exec ()
 Executes prepared InsertQuery with insert values list. More...
 

Detailed Description

QSqlQuery wrapper for INSERT INTO table query execution.

Constructor & Destructor Documentation

◆ InsertQuery()

EasyQtSql::InsertQuery::InsertQuery ( const QString &  table,
const QSqlDatabase &  db 
)
inline

Member Function Documentation

◆ exec()

NonQueryResult EasyQtSql::InsertQuery::exec ( )
inline

Executes prepared InsertQuery with insert values list.

◆ values() [1/2]

InsertQuery& EasyQtSql::InsertQuery::values ( const QVariant &  t)
inline

Adds list of insert-values to INSERT INTO table(...) VALUES ... query.

The method supports variable count of QVariant parameters. Parameters are bound with QSqlQuery::addBindValue.

NonQueryResult res = t.insertInto("table (a, b, c, d)")
.values(1, 2, 3, "a")
.values(4, 5, 6, "b")
.values(7, 8, 9, "c")
.exec();

◆ values() [2/2]

template<typename... Rest>
InsertQuery& EasyQtSql::InsertQuery::values ( const QVariant &  first,
const Rest &...  rest 
)
inline

The documentation for this class was generated from the following file: