diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-09-16 05:52:27 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-09-16 05:52:27 (GMT) |
commit | 64dba2e0de580853bd82ba2ce60229215c633396 (patch) | |
tree | af685ffc2f9de17bad10867c3822439b04e9e31a /examples/declarative/sql/hello.qml | |
parent | df394cd24e65dcfa929074b794878081a42659c7 (diff) | |
download | Qt-64dba2e0de580853bd82ba2ce60229215c633396.zip Qt-64dba2e0de580853bd82ba2ce60229215c633396.tar.gz Qt-64dba2e0de580853bd82ba2ce60229215c633396.tar.bz2 |
Basic first-working SQL database interface.
A simple Qt-based implementation of HTML5 SQL local storage databases.
Diffstat (limited to 'examples/declarative/sql/hello.qml')
-rw-r--r-- | examples/declarative/sql/hello.qml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml new file mode 100644 index 0000000..fb6d21c --- /dev/null +++ b/examples/declarative/sql/hello.qml @@ -0,0 +1,30 @@ +import Qt 4.6 + +Text { + Script { + function test() + { + var db = openDatabase("QmlExampleDB", "", "The Example QML SQL!", 1000000); + print(db) + var r = "" + + db.transaction(function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)', []); + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + tx.executeSql('SELECT * FROM Greeting', [], + function(tx, rs) { + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows[i][0] + ", " + rs.rows[i][1] + "\n" + } + }, + function(tx, error) { + print("ERROR:", error.message) + } + ); + }) + + return r + } + } + text: test() +} |