Skip to content

Commit

Permalink
Don't use QDateTime::toString() for prepared queries.
Browse files Browse the repository at this point in the history
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
sphery committed Apr 16, 2011
1 parent c339887 commit bfa8827
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/recordinginfo.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythbackend/housekeeper.cpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions mythtv/programs/mythfilldatabase/filldata.cpp
Expand Up @@ -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())
{
Expand All @@ -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())
{
Expand Down

0 comments on commit bfa8827

Please sign in to comment.