-/*!
- * Ext JS Library 3.0.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-Ext.data.GearsDB = Ext.extend(Ext.data.SqlDB, {\r
- // abstract methods\r
- open : function(db, cb, scope){\r
- this.conn = google.gears.factory.create('beta.database', '1.0');\r
- this.conn.open(db);\r
- this.openState = true;\r
- Ext.callback(cb, scope, [this]);\r
- this.fireEvent('open', this);\r
- },\r
-\r
- close : function(){\r
- this.conn.close();\r
- this.fireEvent('close', this);\r
- },\r
-\r
- exec : function(sql, cb, scope){\r
- this.conn.execute(sql).close();\r
- Ext.callback(cb, scope, [true]);\r
- },\r
-\r
- execBy : function(sql, args, cb, scope){\r
- this.conn.execute(sql, args).close();\r
- Ext.callback(cb, scope, [true]);\r
- },\r
-\r
- query : function(sql, cb, scope){\r
- var rs = this.conn.execute(sql);\r
- var r = this.readResults(rs);\r
- Ext.callback(cb, scope, [r]);\r
- return r;\r
- },\r
-\r
- queryBy : function(sql, args, cb, scope){\r
- var rs = this.conn.execute(sql, args);\r
- var r = this.readResults(rs);\r
- Ext.callback(cb, scope, [r]);\r
- return r;\r
- },\r
-\r
- readResults : function(rs){\r
- var r = [];\r
- if(rs){\r
- var c = rs.fieldCount();\r
- // precache field names\r
- var fs = [];\r
- for(var i = 0; i < c; i++){\r
- fs[i] = rs.fieldName(i);\r
- }\r
- // read the data\r
- while(rs.isValidRow()){\r
- var o = {};\r
- for(var i = 0; i < c; i++){\r
- o[fs[i]] = rs.field(i);\r
- }\r
- r[r.length] = o;\r
- rs.next();\r
- }\r
- rs.close();\r
- }\r
- return r;\r
- },\r
-\r
- // protected/inherited method\r
- isOpen : function(){\r
- return this.openState;\r
- },\r
-\r
- getTable : function(name, keyName){\r
- return new Ext.data.SqlDB.Table(this, name, keyName);\r
- }\r
-});
\ No newline at end of file