In official documentation this is used as an example of prepared statement using QSqlQuery:
QSqlQuery query;
query.prepare("INSERT INTO person (id, forename, surname) "
"VALUES (:id, :forename, :surname)");
query.bindValue(":id", 1001);
query.bindValue(":forename", "Bart");
query.bindValue(":surname", "Simpson");
query.exec();
However this will not work since the QDatabase is missing from the picture.
In my app I have X prepared statements in my class all using the same sqlite db. So what would be the recommended architecture to prepare all these statements and then use them from individual methods to execute queries?
I tried having the queries instanciated with the class using RIIA but it fails with strange errors (out of memory) on prepare() call because I am unable to have the db set up correctly entirely using RIIA first.
Aucun commentaire:
Enregistrer un commentaire