[mythtv] [mythtv-commits] mythtv commit: r21780 by stuartm

Daniel Kristjansson danielk at cuymedia.net
Fri Sep 11 21:15:51 UTC 2009

On Fri, 2009-09-11 at 17:14 +0000, mythtv at cvs.mythtv.org wrote:
> Author: stuartm
>         Date: 2009-09-11 17:14:46 +0000 (Fri, 11 Sep 2009)
> Set the record id after insertion of a new rule using QSqlQuery::lastInsertId().

lastInsertId() can be used when the database back end supports it, but
then you should query it before and after the insert and only its value
if the insert is successful and the value has been incremented by one
and the insert does not use the DELAYED keyword (and obviously it can
not be used with REPLACE inserts.)

In any case, if the record id is really needed there should be a backup
method for obtaining it when someone else happens to do an insert
shortly after you do an insert into the table and when the database
backend does not support the optionally supported lastInsertId().

-- Daniel

More information about the mythtv-dev mailing list