Created
July 6, 2012 07:08
-
-
Save dhavaln/3058562 to your computer and use it in GitHub Desktop.
HTML5 Database Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title>Insert title here</title> | |
<script type="text/javascript"> | |
var filename = "name"; | |
var filepath = "path"; | |
function insertInTable(name, path) | |
{ | |
var db = window.openDatabase('taukydb', '1.0', 'Tauky Database', 2000); | |
db.transaction(populateDB, errorCB, successCB); | |
} | |
function populateDB(tx) { | |
tx.executeSql('DROP TABLE IF EXISTS taukytb'); | |
tx.executeSql('CREATE TABLE IF NOT EXISTS taukytb (name TEXT UNIQUE, path TEXT, uploaded INTEGER)'); | |
tx.executeSql('INSERT INTO taukytb (name, path, uploaded) VALUES ("'+filename+'", "'+filepath+'", 0)'); | |
} | |
// Transaction success callback | |
function successCB() { | |
alert("Hurrey!!!"); | |
//this is just for testing | |
var db = window.openDatabase("anotherdb", "1.0", "Cordova Demo", 1024 * 1); | |
db.transaction(populateDB, errorCB, function(){}); | |
} | |
function queryDB(tx) { | |
tx.executeSql('SELECT * FROM taukytb', [], querySuccess, errorCB); | |
} | |
function querySuccess(tx, results) { | |
var len = results.rows.length; | |
alert(len); | |
} | |
//Transaction error callback | |
function errorCB1(err) { | |
alert("Error 11111 processing SQL: "+err.code); | |
//console.log("Error processing SQL: "+err.code); | |
} | |
// Transaction error callback | |
function errorCB(err) { | |
console.log(err.message); | |
//alert("Error processing SQL: "+err.code); | |
//console.log("Error processing SQL: "+err.code); | |
} | |
</script> | |
</head> | |
<body> | |
<button onclick="insertInTable()">Start</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment