X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/2e847cf21b8ab9d15fa167b315ca5b2fa92638fc..6a7e4474cba9d8be4b2ec445e10f1691f7277c50:/examples/tasks/db/ext-gears-db.js diff --git a/examples/tasks/db/ext-gears-db.js b/examples/tasks/db/ext-gears-db.js index 70658b57..437b1532 100644 --- a/examples/tasks/db/ext-gears-db.js +++ b/examples/tasks/db/ext-gears-db.js @@ -1,77 +1,77 @@ /*! - * Ext JS Library 3.1.1 - * Copyright(c) 2006-2010 Ext JS, LLC + * Ext JS Library 3.2.0 + * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ -Ext.data.GearsDB = Ext.extend(Ext.data.SqlDB, { - // abstract methods - open : function(db, cb, scope){ - this.conn = google.gears.factory.create('beta.database', '1.0'); - this.conn.open(db); - this.openState = true; - Ext.callback(cb, scope, [this]); - this.fireEvent('open', this); - }, - - close : function(){ - this.conn.close(); - this.fireEvent('close', this); - }, - - exec : function(sql, cb, scope){ - this.conn.execute(sql).close(); - Ext.callback(cb, scope, [true]); - }, - - execBy : function(sql, args, cb, scope){ - this.conn.execute(sql, args).close(); - Ext.callback(cb, scope, [true]); - }, - - query : function(sql, cb, scope){ - var rs = this.conn.execute(sql); - var r = this.readResults(rs); - Ext.callback(cb, scope, [r]); - return r; - }, - - queryBy : function(sql, args, cb, scope){ - var rs = this.conn.execute(sql, args); - var r = this.readResults(rs); - Ext.callback(cb, scope, [r]); - return r; - }, - - readResults : function(rs){ - var r = []; - if(rs){ - var c = rs.fieldCount(); - // precache field names - var fs = []; - for(var i = 0; i < c; i++){ - fs[i] = rs.fieldName(i); - } - // read the data - while(rs.isValidRow()){ - var o = {}; - for(var i = 0; i < c; i++){ - o[fs[i]] = rs.field(i); - } - r[r.length] = o; - rs.next(); - } - rs.close(); - } - return r; - }, - - // protected/inherited method - isOpen : function(){ - return this.openState; - }, - - getTable : function(name, keyName){ - return new Ext.data.SqlDB.Table(this, name, keyName); - } +Ext.data.GearsDB = Ext.extend(Ext.data.SqlDB, { + // abstract methods + open : function(db, cb, scope){ + this.conn = google.gears.factory.create('beta.database', '1.0'); + this.conn.open(db); + this.openState = true; + Ext.callback(cb, scope, [this]); + this.fireEvent('open', this); + }, + + close : function(){ + this.conn.close(); + this.fireEvent('close', this); + }, + + exec : function(sql, cb, scope){ + this.conn.execute(sql).close(); + Ext.callback(cb, scope, [true]); + }, + + execBy : function(sql, args, cb, scope){ + this.conn.execute(sql, args).close(); + Ext.callback(cb, scope, [true]); + }, + + query : function(sql, cb, scope){ + var rs = this.conn.execute(sql); + var r = this.readResults(rs); + Ext.callback(cb, scope, [r]); + return r; + }, + + queryBy : function(sql, args, cb, scope){ + var rs = this.conn.execute(sql, args); + var r = this.readResults(rs); + Ext.callback(cb, scope, [r]); + return r; + }, + + readResults : function(rs){ + var r = []; + if(rs){ + var c = rs.fieldCount(); + // precache field names + var fs = []; + for(var i = 0; i < c; i++){ + fs[i] = rs.fieldName(i); + } + // read the data + while(rs.isValidRow()){ + var o = {}; + for(var i = 0; i < c; i++){ + o[fs[i]] = rs.field(i); + } + r[r.length] = o; + rs.next(); + } + rs.close(); + } + return r; + }, + + // protected/inherited method + isOpen : function(){ + return this.openState; + }, + + getTable : function(name, keyName){ + return new Ext.data.SqlDB.Table(this, name, keyName); + } }); \ No newline at end of file