I am trying to optimize the speed that my Local database populates in a Web app that is being developed. Currently, it uses PHP to access the Database and then inserts tha
I would prepare a query with placeholders, then execute it for each row with the right arguments. Something like this (JS part only, using underscore.js for array helpers):
db.transaction(function(tx) {
var q = 'INSERT INTO Cost_Codes (Cost_Code_No, Name, Unit_Of_Measure) VALUES (?, ?, ?)';
_(rows).each(function(row) {
tx.executeSql(q, [row.code, row.name, row.unit]);
});
});
Edit: a query with placeholders has two main benefits: