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