summaryrefslogtreecommitdiffstats
path: root/examples/declarative/sql/hello.qml
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-09-16 08:21:12 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-09-16 08:21:12 (GMT)
commit5d35dbc3552f722cf4de220d8737e8201e4f61e5 (patch)
tree382aa85b2b63c109b0307f327e6cf4befb7a40d9 /examples/declarative/sql/hello.qml
parent4937e80baf3cce7444a007f5b3fa4979ea93f3fc (diff)
downloadQt-5d35dbc3552f722cf4de220d8737e8201e4f61e5.zip
Qt-5d35dbc3552f722cf4de220d8737e8201e4f61e5.tar.gz
Qt-5d35dbc3552f722cf4de220d8737e8201e4f61e5.tar.bz2
Better SQL database performance / memory usage.
Rows accessible incrementally. Rows.forwardOnly for optimization.
Diffstat (limited to 'examples/declarative/sql/hello.qml')
-rw-r--r--examples/declarative/sql/hello.qml12
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
index fb6d21c..e43d320 100644
--- a/examples/declarative/sql/hello.qml
+++ b/examples/declarative/sql/hello.qml
@@ -2,10 +2,9 @@ import Qt 4.6
Text {
Script {
- function test()
+ function allGreetings()
{
var db = openDatabase("QmlExampleDB", "", "The Example QML SQL!", 1000000);
- print(db)
var r = ""
db.transaction(function(tx) {
@@ -13,9 +12,16 @@ Text {
tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
tx.executeSql('SELECT * FROM Greeting', [],
function(tx, rs) {
+ /* Inefficient HTML5-compatible way
for(var i = 0; i < rs.rows.length; i++) {
r += rs.rows[i][0] + ", " + rs.rows[i][1] + "\n"
}
+ */
+ /* Efficient way: forward only, not "length" query */
+ rs.rows.forwardOnly = true;
+ for(var i = 0; rs.rows[i]; i++) {
+ r += rs.rows[i][0] + ", " + rs.rows[i][1] + "\n"
+ }
},
function(tx, error) {
print("ERROR:", error.message)
@@ -26,5 +32,5 @@ Text {
return r
}
}
- text: test()
+ text: allGreetings()
}