Introducing Web SQL Databases

Introducing Web SQL Databases

var db = openDatabase('mydb','1.0','my first database',2*1024*1024);

 
var db = openDatabase('mydb','1.0','my first database',2*1024*1024);
db.transaction(function(tx){
  // here be the transaction
  // do SQL magic here using the tx object
});
 
var db = openDatabase('mydb','1.0','my first database',2*1024*1024);
db.transaction(function(tx){
  tx.executeSql('CREATE TABLE foo (id unique, text)');
});
 
var db = openDatabase('mydb','1.0','my first database',2*1024*1024);
db.transaction(function(tx){
  tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
  tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "synergies")');
});
 
tx.executeSql('INSERT INTO foo (id, text) VALUES (?, ?)',[id,userValue]);
 
 
tx.executeSql('SELECT * FROM foo',[],function(tx, results){
  var len = results.rows.length, i;
  for(i =0; i < len; i++){
    alert(results.rows.item(i).text);
  }
});

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s