jeudi 13 août 2015

SELECT COUNT(*) doesn't work in QML

I'm trying to get the number of records with QML LocalStorage, which uses sqlite. Let's take this snippet

function f()
{
    var db = LocalStorage.openDatabaseSync(...)

    db.transaction
    (
        function(tx)
        {
            var b = tx.executeSql("SELECT * FROM t")
            console.log(b.rows.length)
            var  c = tx.executeSql("SELECT COUNT(*) FROM t")
            console.log(JSON.stringify(c))
        }
    )
}

The output is:

qml: 3
qml: {"rowsAffected":0,"insertId":"","rows":{}}

What am I doing wrong that the SELECT COUNT(*) doesn't output anything?

Aucun commentaire:

Enregistrer un commentaire