3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 Ext.data.GearsDB = Ext.extend(Ext.data.SqlDB, {
9 open : function(db, cb, scope){
10 this.conn = google.gears.factory.create('beta.database', '1.0');
12 this.openState = true;
13 Ext.callback(cb, scope, [this]);
14 this.fireEvent('open', this);
19 this.fireEvent('close', this);
22 exec : function(sql, cb, scope){
23 this.conn.execute(sql).close();
24 Ext.callback(cb, scope, [true]);
27 execBy : function(sql, args, cb, scope){
28 this.conn.execute(sql, args).close();
29 Ext.callback(cb, scope, [true]);
32 query : function(sql, cb, scope){
33 var rs = this.conn.execute(sql);
34 var r = this.readResults(rs);
35 Ext.callback(cb, scope, [r]);
39 queryBy : function(sql, args, cb, scope){
40 var rs = this.conn.execute(sql, args);
41 var r = this.readResults(rs);
42 Ext.callback(cb, scope, [r]);
46 readResults : function(rs){
49 var c = rs.fieldCount();
50 // precache field names
52 for(var i = 0; i < c; i++){
53 fs[i] = rs.fieldName(i);
56 while(rs.isValidRow()){
58 for(var i = 0; i < c; i++){
59 o[fs[i]] = rs.field(i);
69 // protected/inherited method
71 return this.openState;
74 getTable : function(name, keyName){
75 return new Ext.data.SqlDB.Table(this, name, keyName);