Hey all i have a quest is use now a database class.
Can any one give me a example for the clein site whit a query thast
show reseltaat ?
Than i can try to work forword whit is.
var MysqlConnector = new Class({
Implements: [Options],
options: {
host: "127.0.0.1:3306",
login: "****",
password: "**",
database: "***",
keepAliveMsec: 60000,
reconnectMsec: 5000
},
db: null,
dbTemp: null,
dbKeepAliveTimer: null,
dbReconnectTimer: null,
initialize: function(options){
this.setOptions(options);
this.connect();
},
connect: function() {
Ape.log("[MysqlConn] connect('"+this.options.host+"',
'"+this.options.login
+":"+this.options.password.slice(0,1)+"***"+this.options.password.slice(-1)+"',
'"+this.options.database+"')");
this.dbTemp = new Ape.MySQL(this.options.host,
this.options.login, this.options.password, this.options.database);
this.dbTemp.connector = this;
this.dbTemp.onConnect = function()
{ this.connector.onConnectOk(); };
this.dbTemp.onError = function(errorNo)
{ this.connector.onConnectError(errorNo); }
},
onConnectOk: function() {
Ape.log("[MysqlConn] (re)connected to mysql server");
this.db = this.dbTemp;
this.dbTemp = null;
if (this.dbKeepAliveTimer != null) {
Ape.clearInterval(this.dbKeepAliveTimer);
this.dbKeepAliveTimer = null;
}
if (this.dbReconnectTimer != null) {
Ape.clearInterval(this.dbReconnectTimer);
this.dbReconnectTimer = null;
}
this.dbKeepAliveTimer = Ape.setInterval(this.keepAliveEvent,
this.options.keepAliveMsec, this);
},
onConnectError: function(errorNo) {
Ape.log("[MysqlConn] Connection error("+errorNo+") : "+
this.errorString());
if (this.dbKeepAliveTimer != null) {
Ape.clearInterval(this.dbKeepAliveTimer);
this.dbKeepAliveTimer = null;
}
if (this.dbReconnectTimer != null) {
Ape.clearInterval(this.dbReconnectTimer);
this.dbReconnectTimer = null;
}
this.dbReconnectTimer = Ape.setInterval(this.reconnectEvent,
this.options.reconnectMsec, this);
},
reconnectEvent: function(connector) {
// be careful: this=Global object ; to acces MysqlConntor, use
'connector'.
connector.connect();
},
keepAliveEvent: function(connector) {
// be careful: this=Global object ; to acces MysqlConntor, use
'connector'.
if (connector.db != null) {
connector.db.query("SELECT session_id FROM joomla_session
LIMIT 0,1;", connector.keepAliveQueryResult);
}
},
keepAliveQueryResult: function(res, errorNo) {
// be careful: this=MySql object ; to acces MysqlConntor, use
'this.connector'.
if (errorNo) {
Ape.log("[MysqlConn] ERROR (" + errorNo + ") in mysql
keepalive request : " + this.errorString());
this.connector.db = null;
this.connector.connect();
}
else {
var time = new Date();
Ape.log("[MysqlConn] mysql keepalive done ("+time.getHours()
+":"+time.getMinutes()+":"+time.getSeconds()+").");
}
},
query: function(queryString, resFunction) {
if (this.db == null) {
Ape.log("[MysqlConn] ERROR: unable to make query
'"+queryString+"': not connected to DB. Will try again to
reconnect.");
this.connect();
}
else {
this.db.query(queryString, resFunction);
}
}
});
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/