EasyQtSql
Easy SQL data access helper for QtSql
DeleteQuery Class Reference

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

#include <EasyQtSql_DeleteQuery.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()

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

Member Function Documentation

◆ exec()

NonQueryResult DeleteQuery::exec ( )
inline

Executes unconditional DELETE FROM table query.

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

◆ where() [1/3]

NonQueryResult 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 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 DeleteQuery::where ( const QString &  expr,
const QVariant &  first,
const Rest &...  rest 
)
inline

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