2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
9 Ext.data.GearsDB = Ext.extend(Ext.data.SqlDB, {
\r
11 open : function(db, cb, scope){
\r
12 this.conn = google.gears.factory.create('beta.database', '1.0');
\r
14 this.openState = true;
\r
15 Ext.callback(cb, scope, [this]);
\r
16 this.fireEvent('open', this);
\r
21 this.fireEvent('close', this);
\r
24 exec : function(sql, cb, scope){
\r
25 this.conn.execute(sql).close();
\r
26 Ext.callback(cb, scope, [true]);
\r
29 execBy : function(sql, args, cb, scope){
\r
30 this.conn.execute(sql, args).close();
\r
31 Ext.callback(cb, scope, [true]);
\r
34 query : function(sql, cb, scope){
\r
35 var rs = this.conn.execute(sql);
\r
36 var r = this.readResults(rs);
\r
37 Ext.callback(cb, scope, [r]);
\r
41 queryBy : function(sql, args, cb, scope){
\r
42 var rs = this.conn.execute(sql, args);
\r
43 var r = this.readResults(rs);
\r
44 Ext.callback(cb, scope, [r]);
\r
48 readResults : function(rs){
\r
51 var c = rs.fieldCount();
\r
52 // precache field names
\r
54 for(var i = 0; i < c; i++){
\r
55 fs[i] = rs.fieldName(i);
\r
58 while(rs.isValidRow()){
\r
60 for(var i = 0; i < c; i++){
\r
61 o[fs[i]] = rs.field(i);
\r
71 // protected/inherited method
\r
72 isOpen : function(){
\r
73 return this.openState;
\r
76 getTable : function(name, keyName){
\r
77 return new Ext.data.SqlDB.Table(this, name, keyName);
\r