I've made this:
call:
Code: Select all
var data = {};
data = self.queryMySQL('SELECT * FROM table_one');
console.log(data); //No output here
Code: Select all
queryMySQL: function(query){
var result = {};
//connect to the mysql server
ige.mysql.connect(function (err, db) {
// Check if we connected to mysql correctly
if (!err) {
// Query the database
ige.mysql.query(query, function (err, rows, fields) {
if (!err) {
result=rows;
} else {
console.log('Error', err);
}
});
} else {
console.log(err);
}
});
console.log(result); //All is OK here
return result;
};
Does anybody know a solution?