MySQL
(since 1.0)
A mysql connection class
Description
MySQL
Ape.MySQL is a class constructor. You can connect and use a MySQL database.
Parameters
host
Mysql host, can be an ip:port or an unix socket.
username
Mysql username
password
Mysql password
database
The database to select
Examples
Database connection
var sql = new Ape.MySQL("ip:port", "user", "password", "database");
sql.onConnect = function() {
Ape.log('Connected to mysql server');
}
Select request
sql.query("SELECT * FROM table", function(res, errorNo) {
if (errorNo) Ape.log('Request error : ' + errorNo + ' : '+ this.errorString());
else {
Ape.log('Fetching ' + res.length);
res.each(function(data) {
Ape.log(data.content);//data.<column name>
});
}
});
Insert request
sql.query("INSERT INTO table VALUES('a','b','c')", function(res, errorNo) {
if (errorNo) Ape.log('Request error : ' + errorNo + ' : '+ this.errorString());
else Ape.log('Inserted');
});
User notes
efyx said:
This wiki page gives you many information on how to use MySQL module <a href="http://www.ape-project.org/wiki/index.php/Serverside_js_module_using_MySQL" rel="nofollow" target="_blank">http://www.ape-project.org/wiki/index.php/Serverside_js_module_using_MySQL</a>
01/04/10 16:22
Post a note
CollaborAPE to our wiki !
Find the information you need on the APE Official Wiki : Install, Server, JSF, Help...

That is currently wrong. It can not be a hostname, it should be an IP address.