Skip to content

Instantly share code, notes, and snippets.

@knxroot
Created November 11, 2012 21:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knxroot/4056323 to your computer and use it in GitHub Desktop.
Save knxroot/4056323 to your computer and use it in GitHub Desktop.
HTML5:websql ejemplo básico
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web SQL</title>
<script type="text/javascript">
function almacenar()
{
var db=openDatabase('Mibbdd','1.0','mi base de datos', 2*1024*1024);
db.transaction(function(tx)
{
tx.executeSql('CREATE TABLE IF NOT EXISTS tabla(nombre,apellido)');
tx.executeSql('INSERT INTO tabla (nombre,apellido) VALUES ("Gustavo","Lacoste")');
});
alert("BBDD inicializada");
db.transaction(function(tx)
{
tx.executeSql('SELECT * FROM tabla',[],function(tx,results)
{
var len=results.rows.length;
for (i=0;i<len;i++)
{
alert(results.rows.item(i).nombre+" "+results.rows.item(i).apellido);
}
});
});
}
</script>
</head>
<body onload="almacenar();">
</body>
</html>
@carlosromanmena
Copy link

No existe la función: openDatabase()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment