I'm trying to send data from items table to the order_items table (where order_id is unique for that order, so for all items it will be the same). So how can I retrieve data directly from the items table?
var itemsSql = "CREATE TABLE IF NOT EXISTS items (" +
"item_id INTEGER PRIMARY KEY," +
"item_name VARCHAR(140) NOT NULL," +
"item_description VARCHAR(255) NOT NULL," +
"list_price DECIMAL(5,2) NOT NULL );";
var orderItemsSql = "CREATE TABLE IF NOT EXISTS order_items (" +
"order_id INTEGER," +
"item_id INTEGER," +
"quantity INTEGER NOT NULL," +
"FOREIGN KEY (order_id) REFERENCES orders (order_id)," +
"FOREIGN KEY (item_id) REFERENCES items (item_id) );";
function addOrderItems(order_id) {
var sqlString = "INSERT INTO order_items (order_id, item_id, quantity)" +
"VALUES( ?, ?, ?)";
var getItemId = "SELECT item_id FROM cart";
var getQuantity = "SELECT quantity FROM cart";
db.transaction(function (tx) {
tx.executeSql(sqlString, [$('#orderId').val(),item_id,quanity ],
function (tx, res) {
console.debug("done!");
}, errorHandler);
});
}
Aucun commentaire:
Enregistrer un commentaire