MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / getRecords

Method getRecords

sources/db/DBManager.cpp:289–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289bool DBManager::getRecords(QVector<QVariantMap>& results, const QStringList& tColumns, const QStringList& tOrder) const
290{
291 SqlDatabase* idb = getDB();
292 SqlQuery query(idb);
293
294 QString sColumns("*");
295 if (!tColumns.isEmpty())
296 sColumns = tColumns.join(", ");
297
298 QString sOrder("");
299 if (!tOrder.isEmpty())
300 {
301 sOrder = " ORDER BY ";
302 sOrder.append(tOrder.join(", "));
303 }
304
305 query.prepare(QString("SELECT %1 FROM %2%3").arg(sColumns, _table, sOrder));
306
307 if (!query.exec())
308 {
309 Error(_log, "Failed to get records: '%s' in table: '%s' Error: %s", QSTRING_CSTR(sColumns), QSTRING_CSTR(_table), QSTRING_CSTR(idb->error()));
310 return false;
311 }
312
313 // iterate through all found records
314 while (query.next())
315 {
316 QVariantMap entry;
317 SqlRecord rec = query.record();
318 for (unsigned int i = 0; i < rec.count(); i++)
319 {
320 entry[rec.fieldName(i)] = rec.value(i);
321 }
322 results.append(entry);
323 }
324
325 return true;
326}
327
328
329bool DBManager::deleteRecord(const VectorPair& conditions) const

Callers

nothing calls this directly

Calls 9

isEmptyMethod · 0.80
execMethod · 0.80
recordMethod · 0.80
countMethod · 0.80
fieldNameMethod · 0.80
prepareMethod · 0.45
errorMethod · 0.45
nextMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected