html5 sql
function db_insert(document_list) {
var insertSql = null;
for(var i = 0; i < document_list.length; i++) {
console.log(document_list[i].documentId + ',' + document_list[i].name + ',' + document_list[i].brief);
}
for(var i = 0; i < document_list.length; i++) {
if(i == 0) {
insertSql = ' select "' +document_list[i].documentId+ '","' +document_list[i].name+ '","' +(document_list[i].brief == null ? " " : document_list[i].brief)+ '" ';
} else {
insertSql += ' union all select "' + document_list[i].documentId + '","' + document_list[i].name + '","' +(document_list[i].brief == null ? " " : document_list[i].brief)+ '" ';
}
}
console.log("sql " + insertSql);
db.transaction(function(tx) {
tx.executeSql('insert into document(documentId,name,brief) ' + insertSql, [], onSuccess, onError);
});
}
语句拼写的时候中间有undefined变量会导致整体undefined