Introduction
The MySQL module makes the MySQL database available in JavaScript. This module has been tested with MySQL version 5.0. If you use another version, and you encounter problems, you can try to rebuild this module with your MySQL version.
Database
mysql.Database represents a database. Before you can use a database, you have to connect to it.
var db = new mysql.Database();
if ( db.connect("localhost", "root", "password", "dbname") )
{
}
Executing SQL statements
SQL statements can be executed with query or prepare. With prepare you can bind JavaScript variables to the SQL statement.
db.query("CREATE TABLE person(name VARCHAR(30), nr INTEGER)");
var stmt = db.prepare("SELECT * FROM person WHERE nr = ?");
stmt.bind(0, 1);
var row;
while(row = stmt.fetchObject())
{
print(row.name);
print(row.nr);
}


© 2002 - 2007 Franky Braem.