MCPcopy Create free account
hub / github.com/Nitrux/maui-shell / insert

Method insert

casklib/src/code/controllers/db.cpp:153–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153bool DB::insert(const QString &tableName, const QVariantMap &insertData) const
154{
155 if (tableName.isEmpty()) {
156 qDebug() << QStringLiteral("Fatal error on insert! The table name is empty!");
157 return false;
158
159 } else if (insertData.isEmpty()) {
160 qDebug() << QStringLiteral("Fatal error on insert! The insertData is empty!");
161 return false;
162 }
163
164 QStringList strValues;
165 QStringList fields = insertData.keys();
166 QVariantList values = insertData.values();
167 int totalFields = fields.size();
168 for (int i = 0; i < totalFields; ++i)
169 strValues.append("?");
170
171 QString sqlQueryString = "INSERT INTO " + tableName + " (" + QString(fields.join(",")) + ") VALUES(" + QString(strValues.join(",")) + ")";
172 QSqlQuery query(this->m_db);
173 query.prepare(sqlQueryString);
174
175 int k = 0;
176 foreach (const QVariant &value, values)
177 query.bindValue(k++, value);
178
179 return query.exec();
180}
181
182bool DB::update(const QString &tableName, const FMH::MODEL &updateData, const QVariantMap &where) const
183{

Callers 10

getSystemdEnvironmentFunction · 0.45
UpdateLaunchEnvJobMethod · 0.45
startMethod · 0.45
loadAutoStartListMethod · 0.45
startMethod · 0.45
StartProcessJobMethod · 0.45
addSignalMethod · 0.45
insertZpaceMethod · 0.45
addRecentAppMethod · 0.45
appInfoMethod · 0.45

Calls 2

QStringClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected