mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-02 19:47:16 +01:00
SqlQuery: Add more BindValue methods
This commit is contained in:
parent
c420f69da8
commit
bc1c0c3c6d
@ -22,8 +22,9 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QVariantList>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "sqlquery.h"
|
||||
|
||||
@ -37,6 +38,54 @@ void SqlQuery::BindValue(const QString &placeholder, const QVariant &value) {
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindStringValue(const QString &placeholder, const QString &value) {
|
||||
|
||||
BindValue(placeholder, value.isNull() ? "" : value);
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindUrlValue(const QString &placeholder, const QUrl &value) {
|
||||
|
||||
BindValue(placeholder, value.isValid() ? value.toString(QUrl::FullyEncoded) : "");
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindIntValue(const QString &placeholder, const int value) {
|
||||
|
||||
BindValue(placeholder, value <= 0 ? -1 : value);
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindLongLongValue(const QString &placeholder, const qint64 value) {
|
||||
|
||||
BindValue(placeholder, value <= 0 ? -1 : value);
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindFloatValue(const QString &placeholder, const float value) {
|
||||
|
||||
BindValue(placeholder, value <= 0 ? -1 : value);
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindBoolValue(const QString &placeholder, const bool value) {
|
||||
|
||||
BindValue(placeholder, value ? 1 : 0);
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindNotNullIntValue(const QString &placeholder, const int value) {
|
||||
|
||||
BindValue(placeholder, value == -1 ? QVariant() : value);
|
||||
|
||||
}
|
||||
|
||||
void SqlQuery::BindNotNullLongLongValue(const QString &placeholder, const qint64 value) {
|
||||
|
||||
BindValue(placeholder, value == -1 ? QVariant() : value);
|
||||
|
||||
}
|
||||
|
||||
bool SqlQuery::Exec() {
|
||||
|
||||
bool success = exec();
|
||||
|
@ -34,6 +34,15 @@ class SqlQuery : public QSqlQuery {
|
||||
explicit SqlQuery(const QSqlDatabase &db) : QSqlQuery(db) {}
|
||||
|
||||
void BindValue(const QString &placeholder, const QVariant &value);
|
||||
void BindStringValue(const QString &placeholder, const QString &value);
|
||||
void BindUrlValue(const QString &placeholder, const QUrl &value);
|
||||
void BindIntValue(const QString &placeholder, const int value);
|
||||
void BindLongLongValue(const QString &placeholder, const qint64 value);
|
||||
void BindFloatValue(const QString &placeholder, const float value);
|
||||
void BindBoolValue(const QString &placeholder, const bool value);
|
||||
void BindNotNullIntValue(const QString &placeholder, const int value);
|
||||
void BindNotNullLongLongValue(const QString &placeholder, const qint64 value);
|
||||
|
||||
bool Exec();
|
||||
QString LastQuery() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user