by Moss Collum <>


To use: Include simplemysqlconnection.js in your project, create a new SimpleMySQLConnection object, call executeQuery() to do queries, and call close() when you're finished. If the query is a SELECT statement, executeQuery() returns an array of associative arrays representing the values in each row of the response. Alternately, you can use executeRDFQuery() to get the results in the form of an RDF datasource suitable for use with a XUL template, rather than an array. An array can be converted into a datasource using getDatasourceFromArray().

Usage Example

Suppose you have a database named example, hosted on, on port 3306, accessible to username jrandom, password foobar, and containing a table called Users, with the following data:

user_id name home_page
1 J. Random Hacker
2 Moss Collum

To set up your connection, you would call:

connection = new SimpleMySQLConnection('', 3306, 'example', 'jrandom', 'foobar', '');

To get some data as an array, you could call:

results = connection.executeQuery("SELECT user_id, name, home_page FROM Users");
after which, for example, results[0]['name'] will be "J. Random Hacker", and results[1]['home_page'] will be "".

Alternately, to get the same data as an RDF datasource, you could call:

rdfresults = connection.executeRDFQuery("SELECT user_id, name, home_page FROM Users");

or, if you had already retrieved the results in array form:

rdfresults = connection.getDatasourceFromArray(results);

In either of these cases, rdfresults would contain an RDF datasource equivalent to the following RDF/XML:

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf=""
    <rdf:Description about="urn:root">
                        autordf:name="J. Random Hacker"
                        autordf:home_page="" />
                        autordf:name="Moss Collum"
                        autordf:home_page="" />


This document Copyright © 2003 Doodlelab, Inc.

This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

The mysqlxpcom project can be contacted through the mailing list or the member list.
Copyright © 2000-2019. All rights reserved. Terms of Use & Privacy Policy.