Still work in progress - I’m working on a simple jquery-like syntax for accessing databases under Titanium developer. So far I’ve got the basics of opening, closing, querying and executing SQL plus iterating through the results.
Example usage:-
$(“databasename”).open()
.select(“* FROM mytable”)
.forEach(function(e) {
alert(e.fieldByName(‘name’));
})
.close();
So in sequence we open the DB, select a resultset, iterate through (displaying an alert in this case) then close the DB.
You could also split out the code too putting each stage into relevant variables.
Here’s an execute example (setting up the DB in this case) :-
$(“db”).open(databasename)
.execute(‘CREATE TABLE IF NOT EXISTS mytable (ID INTEGER PRIMARY KEY, NAME TEXT)’)
.close();
That’s it for now, comments welcome.