I am using a WebSQL database to save a usage license information in a PhoneGap application. At all times of the system I will need to access this information, so I intend to save this in a global variable in the form of an array. This license to use, when opening the program I perform a function to fetch the information in the WebSQL of the same, but I am not able to insert the return of the function within that global variable. Here's the code:
<!-- language: lang-js -->
//license
LIC = [];
//WebSQL Connect
conn = openDatabase('test', 'test', 'test', 200 * 1024 * 1024);
//return license
function(){
conn.transaction(function (tx) {
//sql
tx.executeSql('SELECT * FROM license', [], function (tx, results) {
var len = results.rows.length, i;
//create array response
for (i = 0; i < len; i++){
//insert values on response
LIC['cpfCnpj'] = results.rows.item(i).cpfCnpj;
LIC['serial'] = results.rows.item(i).serial;
LIC['apiHash'] = results.rows.item(i).apiHash;
LIC['status'] = results.rows.item(i).status;
};
console.log(LIC); //aqui LIC retorna
}, null);
console.log(LIC); //aqui não retorna
});
}
console.log(LIC); //aqui não retorna
Does anyone have a light there to help me?