Hello,
In my app I have a list that is populated from a Web SQL database (as learned in the "Building a mobile app with the Appery.io and local SQLite databases" tutorial. I have used the javascript from that tutorial and have successfully copied the two tables I need local and can use a javascript REST service to retrieve the data. But on my second query I need to use a WHERE statement and when I include it, I get no data returned. Without the WHERE statement I get data, just not filtered as I want it.
In my code I set a variable "SelectedSuperCategory" to the value of a local storage variable.
I'm use my problem is just syntax, but I have not been able to find a resource with documentation for the syntax needed.
Please help.
code
var db = window.openDatabase("Advisor 0.1", "", "Advisor 0.1", 1024 * 1000);
var SelectedSuperCategory=(localStorage.getItem('Selected'));
Appery.GetLocalBasicCategory = Appery.createClass(null, {
Code: Select all
init: function(requestOptions) {
this.__requestOptions = $.extend({}, requestOptions);
},
process: function(settings) {
if (this.__requestOptions.echo) {
settings.success(this.__requestOptions.echo);
} else {
var ourFinalArray = [];
db.transaction(function(tx) {
tx.executeSql('SELECT DISTINCT "BasicCategory" FROM "Categories" WHERE "SuperCategory" = SelectedSuperCategory;', [], function(tx, results) {
var len = results.rows.length,
i;
if (len === 0) {
} else {
for (i = 0; i < len; i++) { // for each row
ourFinalArray.push(results.rows.item(i)); // pushing row object to an array
}
console.log("Categories: " + JSON.stringify(ourFinalArray));
settings.success(JSON.stringify(ourFinalArray));
}
settings.complete('success');
});
});
}
}
});
/code