var add = function(bookList,demo) { var bookList=bookList; demo.transaction(function (book) { book.executeSql("INSERT INTO book (number,name,author,page,price) VALUES (?,?,?,?,?)", [bookList.number,bookList.name,bookList.author,bookList.page,bookList.price]); //console.log(bookList); }); };//添加数据 //传入两个参数,一个是实例化的数据库对象,一个是数据,这里?是动态绑定输出,后面的[]是变量
var dele = function(number,demo){ var number=String(number);//强制转字符串 demo.transaction(function (book) { book.executeSql('DELETE FROM book WHERE number=?',[number]); }); }; //删除数据
var update = function(bookList,number,demo){ var bookList=bookList; var number=number; //console.log(number); demo.transaction(function (book) { book.executeSql("UPDATE book SET name=?, author=?, page=?, price=? WHERE number=?",[bookList.name,bookList.author,bookList.page,bookList.price,number]); //console.log(bookList);