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.sql.AirConnection = Ext.extend(Ext.sql.Connection, {
\r
10 open : function(db){
\r
11 this.conn = new air.SQLConnection();
\r
12 var file = air.File.applicationDirectory.resolvePath(db);
\r
13 this.conn.open(file);
\r
14 this.openState = true;
\r
15 this.fireEvent('open', this);
\r
20 this.fireEvent('close', this);
\r
23 createStatement : function(type){
\r
24 var stmt = new air.SQLStatement();
\r
25 stmt.sqlConnection = this.conn;
\r
29 exec : function(sql){
\r
30 var stmt = this.createStatement('exec');
\r
35 execBy : function(sql, args){
\r
36 var stmt = this.createStatement('exec');
\r
38 this.addParams(stmt, args);
\r
42 query : function(sql){
\r
43 var stmt = this.createStatement('query');
\r
45 stmt.execute(this.maxResults);
\r
46 return this.readResults(stmt.getResult());
\r
49 queryBy : function(sql, args){
\r
50 var stmt = this.createStatement('query');
\r
52 this.addParams(stmt, args);
\r
53 stmt.execute(this.maxResults);
\r
54 return this.readResults(stmt.getResult());
\r
57 addParams : function(stmt, args){
\r
58 if(!args){ return; }
\r
59 for(var key in args){
\r
60 if(args.hasOwnProperty(key)){
\r
64 v = v.format(Ext.sql.Proxy.DATE_FORMAT);
\r
66 stmt.parameters[parseInt(key)] = v;
\r
68 stmt.parameters[':' + key] = args[key];
\r
75 readResults : function(rs){
\r
78 var len = rs.data.length;
\r
79 for(var i = 0; i < len; i++) {
\r
80 r[r.length] = rs.data[i];
\r