Update to dms control phase1.
This commit is contained in:
@@ -135,3 +135,48 @@ void SQLHelper::QueryMap(const QString& sql, QMap<QString, QVariant> &result, co
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SQLHelper::exec(const QString& aSql)
|
||||
{
|
||||
QSqlQuery query(*defaultDatabase);
|
||||
bool result = query.exec(aSql);
|
||||
if(!result)
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant SQLHelper::queryValue(const QString& aSql)
|
||||
{
|
||||
QSqlQuery query(*defaultDatabase);
|
||||
if (!query.exec(aSql))
|
||||
{
|
||||
qDebug()<<query.lastError().text();
|
||||
return QVariant();
|
||||
}
|
||||
if(query.next())
|
||||
{
|
||||
return query.value(0);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QList<QVariant> SQLHelper::queryValues(const QString& aSql)
|
||||
{
|
||||
QList<QVariant> result;
|
||||
QSqlQuery query(*defaultDatabase);
|
||||
if (!query.exec(aSql))
|
||||
{
|
||||
qDebug()<<query.lastError().text();
|
||||
return QList<QVariant>();
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
result.append(query.value(0));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user