3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.data.GearsDB = Ext.extend(Ext.data.SqlDB, {
\r
10 open : function(db, cb, scope){
\r
11 this.conn = google.gears.factory.create('beta.database', '1.0');
\r
13 this.openState = true;
\r
14 Ext.callback(cb, scope, [this]);
\r
15 this.fireEvent('open', this);
\r
20 this.fireEvent('close', this);
\r
23 exec : function(sql, cb, scope){
\r
24 this.conn.execute(sql).close();
\r
25 Ext.callback(cb, scope, [true]);
\r
28 execBy : function(sql, args, cb, scope){
\r
29 this.conn.execute(sql, args).close();
\r
30 Ext.callback(cb, scope, [true]);
\r
33 query : function(sql, cb, scope){
\r
34 var rs = this.conn.execute(sql);
\r
35 var r = this.readResults(rs);
\r
36 Ext.callback(cb, scope, [r]);
\r
40 queryBy : function(sql, args, cb, scope){
\r
41 var rs = this.conn.execute(sql, args);
\r
42 var r = this.readResults(rs);
\r
43 Ext.callback(cb, scope, [r]);
\r
47 readResults : function(rs){
\r
50 var c = rs.fieldCount();
\r
51 // precache field names
\r
53 for(var i = 0; i < c; i++){
\r
54 fs[i] = rs.fieldName(i);
\r
57 while(rs.isValidRow()){
\r
59 for(var i = 0; i < c; i++){
\r
60 o[fs[i]] = rs.field(i);
\r
70 // protected/inherited method
\r
71 isOpen : function(){
\r
72 return this.openState;
\r
75 getTable : function(name, keyName){
\r
76 return new Ext.data.SqlDB.Table(this, name, keyName);
\r