Go to the documentation of this file.
4 #include <QSqlDatabase>
16 #define REUSE_CONNECTION 1 // NOLINT(cppcoreguidelines-macro-usage)
19 const QString& dbUserName,
21 QString dbName =
"mythconverg",
41 QSqlDatabase
db(
void)
const {
return m_db; }
61 void CloseDatabases(
void);
62 void PurgeIdleConnections(
bool leaveOne =
false);
156 bool seek(
int where,
bool relative =
false);
159 bool exec(
const QString &query);
162 bool prepare(
const QString &query);
165 void bindValue(
const QString &placeholder,
const QVariant &val);
180 void bindValueNoNull(
const QString &placeholder,
const QVariant &val);
193 QVariant lastInsertId();
201 bool lostConnectionCheck(
void);
204 QVariant
value(
int i)
const {
return QSqlQuery::value(i); }
207 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
208 QMap<QString, QVariant> boundValues(
void)
const
209 {
return QSqlQuery::boundValues(); }
211 QVariantList
boundValues(
void)
const {
return QSqlQuery::boundValues(); }
213 QSqlError
lastError(
void)
const {
return QSqlQuery::lastError(); }
214 int size(
void)
const {
return QSqlQuery::size();}
215 bool isActive(
void)
const {
return QSqlQuery::isActive(); }
216 QSqlRecord
record(
void)
const {
return QSqlQuery::record(); }
219 bool isNull(
int field)
const {
return QSqlQuery::isNull(field); }
220 const QSqlDriver *
driver(
void)
const {
return QSqlQuery::driver(); }
221 int at(
void)
const {
return QSqlQuery::at(); }
224 static bool testDBConnection();
232 static MSqlQueryInfo InitCon(ConnectionReuse _reuse = kNormalConnection);
244 void bindValue(
const QString&,
const QVariant&, QSql::ParamType);
245 void bindValue(
int,
const QVariant&, QSql::ParamType);
246 void addBindValue(
const QVariant&, QSql::ParamType = QSql::In);
248 bool seekDebug(
const char *
type,
bool result,
249 int where,
bool relative)
const;
252 bool m_isConnected {
false};
253 bool m_returnConnection {
false};
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
bool isActive(void) const
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool isNull(int field) const
void InitSessionVars(void)
Structure containing the basic Database parameters.
QHash< QThread *, int > m_inuseCount
QSqlRecord record(void) const
DB connection pool, used by MSqlQuery. Do not use directly.
QVariant value(int i) const
QSqlDatabase db(void) const
MBASE_PUBLIC bool TestDatabase(const QString &dbHostName, const QString &dbUserName, QString dbPassword, QString dbName="mythconverg", int dbPort=3306)
MBASE_PUBLIC void MSqlEscapeAsAQuery(QString &query, const MSqlBindings &bindings)
Given a partial query string and a bindings object, escape the string.
QList< MSqlDatabase * > DBList
MSqlDatabase(QString name, QString driver="QMYSQL")
MSqlDatabase Info, used by MSqlQuery. Do not use directly.
QHash< QThread *, DBList > m_pool
QHash< QThread *, MSqlDatabase * > m_inuse
QHash< QThread *, DBList > m_staticPool
QVariantList boundValues(void) const
void setForwardOnly(bool f)
bool isConnected(void) const
Only updated once during object creation.
MBASE_PUBLIC void MSqlAddMoreBindings(MSqlBindings &output, MSqlBindings &addfrom)
Add the entries in addfrom to the map in output.
QString m_lastPreparedQuery
QSqlDatabase wrapper, used by MSqlQuery. Do not use directly.
QSqlError lastError(void) const
QString executedQuery(void) const
QString GetConnectionName(void) const
int numRowsAffected() const
void SetDBParams(const DatabaseParams ¶ms)
bool OpenDatabase(bool skipdb=false)
const QSqlDriver * driver(void) const