From bfa882711578a1345e905961cffeb1e52cbe2e03 Mon Sep 17 00:00:00 2001 From: "Michael T. Dean" Date: Wed, 2 Mar 2011 14:59:51 -0500 Subject: [PATCH] Don't use QDateTime::toString() for prepared queries. When using bindValue() to specify datetime values, do not use toString(). Instead, pass the QDateTime to bindValue() so that it can pass the value using the MySQL-C-API MYSQL_TIME type--so that database datetime string literal format isn't an issue. Refs #8585. Thanks, again, to Rob Smith for finding another incorrect pattern to search for. (cherry picked from commit cd073b6e9b323958f785cab47884e605e4033885) --- mythtv/libs/libmythtv/recordinginfo.cpp | 6 +++--- mythtv/programs/mythbackend/housekeeper.cpp | 2 +- mythtv/programs/mythfilldatabase/filldata.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mythtv/libs/libmythtv/recordinginfo.cpp b/mythtv/libs/libmythtv/recordinginfo.cpp index aae62e4f82b..4abab354e30 100644 --- a/mythtv/libs/libmythtv/recordinginfo.cpp +++ b/mythtv/libs/libmythtv/recordinginfo.cpp @@ -625,7 +625,7 @@ void RecordingInfo::ApplyRecordRecTitleChange(const QString &newTitle, const QSt query.bindValue(":TITLE", newTitle); query.bindValue(":SUBTITLE", newSubtitle); query.bindValue(":CHANID", chanid); - query.bindValue(":START", recstartts.toString("yyyyMMddhhmmss")); + query.bindValue(":START", recstartts); if (!query.exec()) MythDB::DBError("RecTitle update", query); @@ -1137,8 +1137,8 @@ void RecordingInfo::AddHistory(bool resched, bool forcedup) ":CATEGORY,:SERIESID,:PROGRAMID,:FINDID,:RECORDID," ":STATION,:RECTYPE,:RECSTATUS,:DUPLICATE,:REACTIVATE);"); result.bindValue(":CHANID", chanid); - result.bindValue(":START", startts.toString(Qt::ISODate)); - result.bindValue(":END", endts.toString(Qt::ISODate)); + result.bindValue(":START", startts); + result.bindValue(":END", endts); result.bindValue(":TITLE", title); result.bindValue(":SUBTITLE", subtitle); result.bindValue(":DESC", description); diff --git a/mythtv/programs/mythbackend/housekeeper.cpp b/mythtv/programs/mythbackend/housekeeper.cpp index 46e75910fad..f202e273cfc 100644 --- a/mythtv/programs/mythbackend/housekeeper.cpp +++ b/mythtv/programs/mythbackend/housekeeper.cpp @@ -518,7 +518,7 @@ void HouseKeeper::CleanupRecordedTables(void) while (query.next()) { deleteQuery.bindValue(":CHANID", query.value(0).toString()); - deleteQuery.bindValue(":STARTTIME", query.value(1).toString()); + deleteQuery.bindValue(":STARTTIME", query.value(1).toDateTime()); if (!deleteQuery.exec()) MythDB::DBError("HouseKeeper Cleaning Recorded Tables", deleteQuery); diff --git a/mythtv/programs/mythfilldatabase/filldata.cpp b/mythtv/programs/mythfilldatabase/filldata.cpp index 39ed4c2e0d2..788219f77f8 100644 --- a/mythtv/programs/mythfilldatabase/filldata.cpp +++ b/mythtv/programs/mythfilldatabase/filldata.cpp @@ -43,7 +43,7 @@ bool updateLastRunEnd(MSqlQuery &query) query.prepare("UPDATE settings SET data = :ENDTIME " "WHERE value='mythfilldatabaseLastRunEnd'"); - query.bindValue(":ENDTIME", qdtNow.toString("yyyy-MM-dd hh:mm")); + query.bindValue(":ENDTIME", qdtNow); if (!query.exec()) { @@ -59,7 +59,7 @@ bool updateLastRunStart(MSqlQuery &query) query.prepare("UPDATE settings SET data = :STARTTIME " "WHERE value='mythfilldatabaseLastRunStart'"); - query.bindValue(":STARTTIME", qdtNow.toString("yyyy-MM-dd hh:mm")); + query.bindValue(":STARTTIME", qdtNow); if (!query.exec()) {