1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- var sqlite = {
- db: undefined,
-
- //开启数据库连接
- open: function(name, vesion, desc, size){
- sqlite.db = openDatabase( name, vesion, desc, size );
- return sqlite.db;
- },
-
- //执行语句
- executeSql: function( sql, params, successHandle, errorHandle ){
- sqlite.db.transaction(function(tx){
- tx.executeSql( sql, params, successHandle, errorHandle);
- })
- },
-
- //新增
- insert: function(sql, list, successHandle, errorHandle){
- sqlite.db.transaction(function(tx){
- for(var i=0; i<list.length; i++){
- tx.executeSql( sql, list[i] , function(tx, rs){
- console.log(rs)
- }, function(tx, rs){
- console.log(rs)
- });
- }
- }, errorHandle, successHandle)
- },
-
- //删除
- delete: function( sql, params, successHandle, errorHandle ){
- sqlite.db.transaction(function(tx){
- tx.executeSql( sql, params, successHandle, errorHandle );
- })
- },
-
- //查询
- search: function( sql, params, successHandle, errorHandle ){
- sqlite.db.transaction(function(tx){
- tx.executeSql( sql, params, successHandle, errorHandle);
- })
- }
- }
|