2014-11-05 12:01:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var HyriseSqlConnector = function(host, port) {
|
|
|
|
|
|
|
|
this.setConnectionDetails(host, port);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HyriseSqlConnector.prototype.setConnectionDetails = function(host, port) {
|
|
|
|
this._host = host;
|
|
|
|
this._port = port;
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
2014-11-10 23:32:27 +01:00
|
|
|
|
2014-11-05 16:09:56 +01:00
|
|
|
HyriseSqlConnector.prototype.executeQuery = function(query, callback, error_callback) {
|
2014-11-05 12:01:01 +01:00
|
|
|
var endpoint = 'http://' + this._host + ':' + this._port + '/query';
|
|
|
|
var url = encodeURI(endpoint);
|
|
|
|
|
|
|
|
jQuery.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: url,
|
|
|
|
dataType: 'json',
|
|
|
|
data: {
|
|
|
|
performance: true,
|
|
|
|
sql: query
|
|
|
|
},
|
|
|
|
success: function(result) {
|
|
|
|
callback(result);
|
2014-11-05 16:09:56 +01:00
|
|
|
},
|
|
|
|
error: error_callback
|
2014-11-05 12:01:01 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
return this;
|
|
|
|
};
|