dojox.sql._exec
dojo.require("dojox._sql.common");
defined in dojox/_sql/common.js
Usage
function (params) (view source)
try{ // get the Gears Database object this._initDb(); // see if we need to open the db; if programmer // manually called dojox.sql.open() let them handle // it; otherwise we open and close automatically on // each SQL execution if(!this._dbOpen){ this.open(); this._autoClose = true; } // determine our parameters var sql = null; var callback = null; var password = null; var args = dojo._toArray(params); sql = args.splice(0, 1)[0]; // does this SQL statement use the ENCRYPT or DECRYPT // keywords? if so, extract our callback and crypto // password if(this._needsEncrypt(sql) || this._needsDecrypt(sql)){ callback = args.splice(args.length - 1, 1)[0]; password = args.splice(args.length - 1, 1)[0]; } // 'args' now just has the SQL parameters // print out debug SQL output if the developer wants that if(this.debug){ this._printDebugSQL(sql, args); } // handle SQL that needs encryption/decryption differently // do we have an ENCRYPT SQL statement? if so, handle that first if(this._needsEncrypt(sql)){ var crypto = new dojox.sql._SQLCrypto("encrypt", sql, password, args, callback); return; // encrypted results will arrive asynchronously }else if(this._needsDecrypt(sql)){ // otherwise we have a DECRYPT statement var crypto = new dojox.sql._SQLCrypto("decrypt", sql, password, args, callback); return; // decrypted results will arrive asynchronously } // execute the SQL and get the results var rs = this.db.execute(sql, args); // Gears ResultSet object's are ugly -- normalize // these into something JavaScript programmers know // how to work with, basically an array of // JavaScript objects where each property name is // simply the field name for a column of data rs = this._normalizeResults(rs); if(this._autoClose){ this.close(); } return rs; }catch(exp){ exp = exp.message||exp; console.debug("SQL Exception: " + exp); if(this._autoClose){ try{ this.close(); }catch(e){ console.debug("Error closing database: " + e.message||e); } } throw exp; }
parameter | type | description |
---|---|---|
params |