Permalink
Browse files

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 cd073b6)
  • Loading branch information...
1 parent c339887 commit bfa882711578a1345e905961cffeb1e52cbe2e03 @sphery sphery committed Mar 2, 2011
@@ -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);
@@ -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);
@@ -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())
{

0 comments on commit bfa8827

Please sign in to comment.