X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/ee06f37b0f6f6d94cd05a6ffae556660f7c4a2bc..c930e9176a5a85509c5b0230e2bff5c22a591432:/docs/source/AirConnection.html diff --git a/docs/source/AirConnection.html b/docs/source/AirConnection.html new file mode 100644 index 00000000..58bf9324 --- /dev/null +++ b/docs/source/AirConnection.html @@ -0,0 +1,87 @@ + +
+Ext.sql.AirConnection = Ext.extend(Ext.sql.Connection, { + // abstract methods + open : function(db){ + this.conn = new air.SQLConnection(); + var file = air.File.applicationDirectory.resolvePath(db); + this.conn.open(file); + this.openState = true; + this.fireEvent('open', this); + }, + + close : function(){ + this.conn.close(); + this.fireEvent('close', this); + }, + + createStatement : function(type){ + var stmt = new air.SQLStatement(); + stmt.sqlConnection = this.conn; + return stmt; + }, + + exec : function(sql){ + var stmt = this.createStatement('exec'); + stmt.text = sql; + stmt.execute(); + }, + + execBy : function(sql, args){ + var stmt = this.createStatement('exec'); + stmt.text = sql; + this.addParams(stmt, args); + stmt.execute(); + }, + + query : function(sql){ + var stmt = this.createStatement('query'); + stmt.text = sql; + stmt.execute(this.maxResults); + return this.readResults(stmt.getResult()); + }, + + queryBy : function(sql, args){ + var stmt = this.createStatement('query'); + stmt.text = sql; + this.addParams(stmt, args); + stmt.execute(this.maxResults); + return this.readResults(stmt.getResult()); + }, + + addParams : function(stmt, args){ + if(!args){ return; } + for(var key in args){ + if(args.hasOwnProperty(key)){ + if(!isNaN(key)){ + var v = args[key]; + if(Ext.isDate(v)){ + v = v.format(Ext.sql.Proxy.DATE_FORMAT); + } + stmt.parameters[parseInt(key)] = v; + }else{ + stmt.parameters[':' + key] = args[key]; + } + } + } + return stmt; + }, + + readResults : function(rs){ + var r = []; + if(rs && rs.data){ + var len = rs.data.length; + for(var i = 0; i < len; i++) { + r[r.length] = rs.data[i]; + } + } + return r; + } +});+ + \ No newline at end of file