如何在 phonegap 存储数据库中创建两个或多个表?它适用于一个表,但如果您尝试创建另一个表,则会返回 Error processing SQL:1; (
var db = window.openDatabase("Database", "1.0", "Order database", 1000000);
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
db.transaction(populateDB, errorCB, successCB);
}
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS ORDER');
tx.executeSql('CREATE TABLE IF NOT EXISTS ORDER (id INTEGER PRIMARY KEY, status)');
tx.executeSql('INSERT INTO ORDER (id, status) VALUES (1, "new" )');
tx.executeSql('INSERT INTO ORDER (id, status) VALUES (2, "done" )');
tx.executeSql('INSERT INTO ORDER (id, status) VALUES (3, "new" )');
tx.executeSql('INSERT INTO ORDER (id, status) VALUES (4, "undone" )');
tx.executeSql('DROP TABLE IF EXISTS CLIENT');
tx.executeSql('CREATE TABLE IF NOT EXISTS CLIENT (id INTEGER PRIMARY KEY, name, addr, mail, phone)');
tx.executeSql('INSERT INTO CLIENT (id, name, addr, mail, phone) VALUES (1, "Kentavr", "Kiev", "Kentavr@i.ua", "044-454-34-34")');
tx.executeSql('INSERT INTO CLIENT (id, name, addr, mail, phone) VALUES (2, "ООО New Step ", "Kiev", "Newstep@i.ua", "044-433-222-24")');
tx.executeSql('INSERT INTO CLIENT (id, name, addr, mail, phone) VALUES (3, "NEXT", "Lvov", "next@i.ua", "033-1-3434-24")');
tx.executeSql('INSERT INTO CLIENT (id, name, addr, mail, phone) VALUES (4, "Briz", "Lvov", "brizxt@i.ua", "033-1-1111-24")');
tx.executeSql('INSERT INTO CLIENT (id, name, addr, mail, phone) VALUES (5, "Brand", "Lvov", "brhjjt@i.ua", "033-1-1001-24")');
}
function queryDB(tx) {
tx.executeSql('SELECT * FROM CLIENT WHERE addr="Lvov" ', [], querySuccess, errorCB);
}