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

QSqlQuery wrapper for DELETE FROM ... WHERE .. query execution. More...

#include <EasyQtSql.h>

Public Member Functions

 DeleteQuery (const QString &table, const QSqlDatabase &db)
 
NonQueryResult where (const QString &expr)
 Executes conditional DELETE FROM table WHERE expr query. More...
 
NonQueryResult where (const QString &expr, const QVariant &last)
 Executes conditional DELETE FROM table WHERE expr query with parameter binding. More...
 
template<typename... Rest>
NonQueryResult where (const QString &expr, const QVariant &first, const Rest &... rest)
 
NonQueryResult exec ()
 Executes unconditional DELETE FROM table query. More...
 

Detailed Description

QSqlQuery wrapper for DELETE FROM ... WHERE .. query execution.

Constructor & Destructor Documentation

◆ DeleteQuery()

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

Member Function Documentation

◆ exec()

NonQueryResult EasyQtSql::DeleteQuery::exec ( )
inline

Executes unconditional DELETE FROM table query.

//DELETE FROM table
t.deleteFrom("table").exec();

◆ where() [1/3]

NonQueryResult EasyQtSql::DeleteQuery::where ( const QString &  expr)
inline

Executes conditional DELETE FROM table WHERE expr query.

//DELETE FROM table WHERE 1=0
t.deleteFrom("table").where("1=0");

◆ where() [2/3]

NonQueryResult EasyQtSql::DeleteQuery::where ( const QString &  expr,
const QVariant &  last 
)
inline

Executes conditional DELETE FROM table WHERE expr query with parameter binding.

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

//DELETE FROM table WHERE a=1 AND b=2
t.deleteFrom("table").where("a=? AND b=?", 1, 2);

◆ where() [3/3]

template<typename... Rest>
NonQueryResult EasyQtSql::DeleteQuery::where ( const QString &  expr,
const QVariant &  first,
const Rest &...  rest 
)
inline

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