storing with new table
This commit is contained in:
parent
32dbc7335e
commit
7cd768fd6f
@ -146,8 +146,12 @@ void StorageJob::start()
|
|||||||
query.bindValue(":id", params["key"].toString());
|
query.bindValue(":id", params["key"].toString());
|
||||||
query.exec();
|
query.exec();
|
||||||
|
|
||||||
query.prepare("insert into " + m_clientName + " values(:valueGroup, :id, :datavalue, date('now'), date('now'))");
|
query.prepare("insert into " + m_clientName + " values(:valueGroup, :id, :txt, :int, :float, :binary, date('now'), date('now'))");
|
||||||
query.bindValue(":valueGroup", valueGroup);
|
query.bindValue(":valueGroup", valueGroup);
|
||||||
|
query.bindValue(":txt", QVariant());
|
||||||
|
query.bindValue(":int", QVariant());
|
||||||
|
query.bindValue(":float", QVariant());
|
||||||
|
query.bindValue(":binary", QVariant());
|
||||||
|
|
||||||
const QString key = params.value("key").toString();
|
const QString key = params.value("key").toString();
|
||||||
if (!key.isEmpty()) {
|
if (!key.isEmpty()) {
|
||||||
@ -158,11 +162,35 @@ void StorageJob::start()
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
query.bindValue(":id", it.key());
|
query.bindValue(":id", it.key());
|
||||||
query.bindValue(":datavalue", it.value());
|
|
||||||
|
QString field;
|
||||||
|
switch (QMetaType::Type(it.value().type())) {
|
||||||
|
case QVariant::String:
|
||||||
|
field = ":txt";
|
||||||
|
break;
|
||||||
|
case QVariant::Int:
|
||||||
|
field = ":int";
|
||||||
|
break;
|
||||||
|
case QVariant::Double:
|
||||||
|
case QMetaType::Float:
|
||||||
|
field = ":float";
|
||||||
|
break;
|
||||||
|
case QVariant::ByteArray:
|
||||||
|
field = ":binary";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
query.bindValue(field, it.value());
|
||||||
|
|
||||||
if (!query.exec()) {
|
if (!query.exec()) {
|
||||||
setResult(false);
|
setResult(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query.bindValue(field, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
setResult(query.exec("COMMIT;"));
|
setResult(query.exec("COMMIT;"));
|
||||||
|
Loading…
Reference in New Issue
Block a user