MCPcopy Create free account
hub / github.com/cutelyst/cutelyst / queryToJsonObjectArray

Method queryToJsonObjectArray

Cutelyst/Plugins/Utils/Sql/sql.cpp:99–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99QJsonArray Sql::queryToJsonObjectArray(QSqlQuery &query)
100{
101 QJsonArray ret;
102 const QSqlRecord record = query.record();
103 const int columns = record.count();
104 QStringList cols;
105 for (int i = 0; i < columns; ++i) {
106 cols.append(record.fieldName(i));
107 }
108
109 while (query.next()) {
110 QJsonObject line;
111 for (int i = 0; i < columns; ++i) {
112 line.insert(cols.at(i), QJsonValue::fromVariant(query.value(i)));
113 }
114 ret.append(line);
115 }
116 return ret;
117}
118
119QVariantList Sql::queryToList(QSqlQuery &query)
120{

Callers

nothing calls this directly

Calls 2

insertMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected