1 #ifndef EASYQTSQL_DELETEQUERY_H 2 #define EASYQTSQL_DELETEQUERY_H 29 #ifndef EASY_QT_SQL_MAIN 57 const QString &sql = createSql(m_table, expr);
59 const bool res = m_query.exec(sql);
61 #ifdef DB_EXCEPTIONS_ENABLED 83 m_params.append(last);
85 const QString &sql = createSql(m_table, expr);
89 for (
int i = 0; i < m_params.count(); ++i)
91 m_query.addBindValue(m_params.at(i));
94 const bool res = m_query.exec();
96 #ifdef DB_EXCEPTIONS_ENABLED 106 template <
typename... Rest>
NonQueryResult where(
const QString &expr,
const QVariant &first,
const Rest&... rest)
108 m_params.append(first);
109 return where(expr, rest...);
122 const QString &sql = createSql(m_table);
124 const bool res = m_query.exec(sql);
126 #ifdef DB_EXCEPTIONS_ENABLED 140 QVariantList m_params;
142 static QString createSql(
const QString &table,
const QString &expr =
"1=1")
144 return QString(
"DELETE FROM %0 WHERE %1").arg(table).arg(expr);
149 #endif // EASYQTSQL_DELETEQUERY_H NonQueryResult where(const QString &expr)
Executes conditional DELETE FROM table WHERE expr query.
Definition: EasyQtSql_DeleteQuery.h:55
NonQueryResult exec()
Executes unconditional DELETE FROM table query.
Definition: EasyQtSql_DeleteQuery.h:120
NonQueryResult where(const QString &expr, const QVariant &first, const Rest &... rest)
Definition: EasyQtSql_DeleteQuery.h:106
DeleteQuery(const QString &table, const QSqlDatabase &db)
Definition: EasyQtSql_DeleteQuery.h:42
QSqlQuery wrapper for non-select query results reading.
Definition: EasyQtSql_NonQueryResult.h:38
NonQueryResult where(const QString &expr, const QVariant &last)
Executes conditional DELETE FROM table WHERE expr query with parameter binding.
Definition: EasyQtSql_DeleteQuery.h:81
QSqlQuery wrapper for DELETE FROM ... WHERE .. query execution.
Definition: EasyQtSql_DeleteQuery.h:39
Exception class for SQL errors handling.
Definition: EasyQtSql_DBException.h:38