[mythtv] Ticket #1660: database updates in *recorder.cpp cause dropped data

Chris Pinkham cpinkham at bc2va.org
Thu Feb 8 04:58:27 UTC 2007


* On Wed Feb 07, 2007 at 05:55:51PM -0500, Tony Lill wrote:
> > #1660: database updates in *recorder.cpp cause dropped data

> How did you manage to insert 30 rows in one statement with this
> method. I couldn't figure that out, which was the main reason I went
> with a QString.

I built a QString and appended to it in the loop but used bindValue on it for
the parts that were static:

+    if (isVideo)
+        queryStr =
+            "INSERT INTO filemarkup (filename, mark, type, offset) VALUES ";
+    else
+        queryStr = "INSERT INTO recordedseek "
+                       "(chanid, starttime, mark, type, offset) VALUES ";
+

Then this inside the loop:

+            queryStr += sep;

and

+            queryStr += QString("(:PATH, %1, %2, %3)")
+                                .arg(frame_str).arg(type).arg(offset_str);

or this:

+            queryStr += QString("(:CHANID, :STARTTIME, %1, %2, %3)")
+                                .arg(frame_str).arg(type).arg(offset_str);

Then after the loop:

+    queryStr += ";";
+    query->prepare(queryStr);
+
+    query->bindValue(":PATH", pathname);
+    query->bindValue(":CHANID", chanid);
+    query->bindValue(":STARTTIME", recstartts);
+
+    gAsyncDB->AddQuery(query);

So I used bindValue as much as possible so I didn't have to worry about formatting
the starttime, filename, etc..  I only had to worry about putting the numbers
in the string.

--
Chris


More information about the mythtv-dev mailing list