Well, here is how I ended up working around it, although it still is strange that bindValue doesn't replace all of the same placeholders with the same thing if you reference them by name.
querystring = "insert into table (col1, col2, col3) values ";
for (int i = 0; i < uniquevaluelist.size(); ++i) {
querystring += "(:item1, :item2, :item3)";
if (i == uniquevaluelist.size() - 1) {
} else {
querystring += ", ";
}
}
query.prepare(querystring);
int j = 0;
for (int i = 0; i < uniquevaluelist.size(); ++i) {
j = i * 3;
query.bindValue((j + 0), uniquevaluelist.at(i));
query.bindValue((j + 1), "some not unique value");
query.bindValue((j + 2), "some other not unique value");
}
query.exec();
querystring = "insert into table (col1, col2, col3) values ";
for (int i = 0; i < uniquevaluelist.size(); ++i) {
querystring += "(:item1, :item2, :item3)";
if (i == uniquevaluelist.size() - 1) {
} else {
querystring += ", ";
}
}
query.prepare(querystring);
int j = 0;
for (int i = 0; i < uniquevaluelist.size(); ++i) {
j = i * 3;
query.bindValue((j + 0), uniquevaluelist.at(i));
query.bindValue((j + 1), "some not unique value");
query.bindValue((j + 2), "some other not unique value");
}
query.exec();
To copy to clipboard, switch view to plain text mode
Bookmarks