I have a query formulated as follows:
insert into table (col1, col2, col3) values ("uniquething", :item1, :item2),("uniquething2", :item1, :item2),("uniquething3", :item1, :item2)
insert into table (col1, col2, col3) values ("uniquething", :item1, :item2),("uniquething2", :item1, :item2),("uniquething3", :item1, :item2)
To copy to clipboard, switch view to plain text mode
I use bindvalue as follows
query.bindValue(":item1", "something");
query.bindValue(":item2", "something2");
query.bindValue(":item1", "something");
query.bindValue(":item2", "something2");
To copy to clipboard, switch view to plain text mode
When the code executes the query, the result in the database is:
col1 | col2 | col3
-----------------------------------------------------
uniquething | null | null
uniquething2 | null | null
uniquething3 | something | something2
col1 | col2 | col3
-----------------------------------------------------
uniquething | null | null
uniquething2 | null | null
uniquething3 | something | something2
To copy to clipboard, switch view to plain text mode
so it seems that if there are multiple of the same placeholder, bindValue only replaces 1 of them, and leaves the others as null. Is this a bug or is it by design? and is there a way to bind a value to multiple placeholders, other than the obvious of naming all of them uniquely?
Bookmarks