[mythtv] Escaping strings for INSERT statements

Isaac Richards ijr at po.cwru.edu
Sun Sep 5 12:05:38 EDT 2004


On Sunday 05 September 2004 11:45 am, Kevin Kuphal wrote:
> In working with the log data, I noticed that I get SQL errors when
> inserting log entries with apostrophes, like "Blue's Clues" for the
> title of a show.  Is there a Qt method to escape these strings properly
> that I can put into the LogEntry function or do I need to use some kind
> of regex?  I noticed that the QSqlDriver has a formatValue function but
> I'm not sure that it applies.  I didn't know if other parts of the code
> had a function I could reuse to address this.

If you use the prepare/bindValue functions of QSqlQuery, it'll automatically 
take care of escaping and any other formatting necessary.

Isaac


More information about the mythtv-dev mailing list