1 #ifndef EASYQTSQL_INSERTQUERY_H 2 #define EASYQTSQL_INSERTQUERY_H 29 #ifndef EASY_QT_SQL_MAIN 64 if (m_insertArray.isEmpty())
66 m_insertArray.resize(m_args.count());
70 Q_ASSERT(m_insertArray.size() == m_args.size());
73 for (
int i = 0; i < m_args.count(); ++i)
75 m_insertArray[i].append(m_args.at(i));
95 QString sql = QLatin1String(
"INSERT INTO ");
97 sql.append(QLatin1String(
" VALUES ("));
100 for (
int i = 0; i < m_insertArray.count(); ++i)
102 lst.append(QLatin1String(
"?"));
105 sql.append(lst.join(QLatin1String(
",")));
106 sql.append(QLatin1String(
")"));
112 if (m_insertArray.count() > 0 && m_insertArray[0].count() > 1)
114 for (
int i = 0; i < m_insertArray.count(); ++i)
116 q.addBindValue(m_insertArray.at(i));
123 for (
int i = 0; i < m_insertArray.count(); ++i)
125 q.addBindValue(m_insertArray.at(i).first());
132 m_insertArray.clear();
134 #ifdef DB_EXCEPTIONS_ENABLED 148 QVector<QVariantList> m_insertArray;
151 #endif // EASYQTSQL_INSERTQUERY_H InsertQuery & values(const QVariant &first, const Rest &... rest)
Definition: EasyQtSql_InsertQuery.h:83
InsertQuery(const QString &table, const QSqlDatabase &db)
Definition: EasyQtSql_InsertQuery.h:42
InsertQuery & values(const QVariant &t)
Adds list of insert-values to INSERT INTO table(...) VALUES ... query.
Definition: EasyQtSql_InsertQuery.h:60
QSqlQuery wrapper for non-select query results reading.
Definition: EasyQtSql_NonQueryResult.h:38
NonQueryResult exec()
Executes prepared InsertQuery with insert values list.
Definition: EasyQtSql_InsertQuery.h:93
QSqlQuery wrapper for INSERT INTO table query execution.
Definition: EasyQtSql_InsertQuery.h:39
Exception class for SQL errors handling.
Definition: EasyQtSql_DBException.h:38