Skip to content

Instantly share code, notes, and snippets.

@lrieger
Created October 7, 2009 15:23
Show Gist options
  • Save lrieger/204125 to your computer and use it in GitHub Desktop.
Save lrieger/204125 to your computer and use it in GitHub Desktop.
this.db.transaction(function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS " + this.tableName + " (flag REAL)",[], function(tx, result) {
tx.executeSql("SELECT flag FROM " + this.tableName, [], function(tx, result) {
if (result.rows.length == 0) {
tx.executeSql("INSERT INTO " + this.tableName + " (flag) VALUES (1)", [], function(tx, result) {
firstTimeCallback();
}, function(tx, error) {
Mojo.Log.error("There was an error inserting into " + this.tableName + ": " + error.message);
});
} else {
everyOtherTimeCallback();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment