0
我試圖從我的phonegap應用程序連接到遠程數據庫。phonegap應用程序:未捕獲ReferenceError:要求未定義
我使用了一個示例腳本,我發現,但它不工作,我不斷收到require is not defined
錯誤。
這裏是我的代碼(這是一個標籤內):
var Client = require('mysql').Client;
var client = new Client();
client.host ='1**.**.**.**8:****';
client.user = '*****';
client.password = '*****************';
console.log("connecting...");
client.connect(function(err, results) {
if (err) {
console.log("ERROR: " + err.message);
throw err;
}
console.log("connected.");
clientConnected(client);
});
clientConnected = function(client)
{
tableHasData(client);
}
tableHasData = function(client)
{
client.query(
'SELECT * FROM test_db.Users LIMIT 0,10',
// you can keep this function anonymous
function (err, results, fields) {
if (err) {
console.log("ERROR: " + err.message);
throw err;
}
console.log("Got "+results.length+" Rows:");
for(var i in results){
console.log(results[i]);
console.log('\n');
//console.log("The meta data about the columns:");
//console.log(fields);
}
client.end();
});
};
我在做什麼錯?
有沒有辦法,我可以不用在服務器編程? – Sascuash
像那樣查詢你的數據庫?不,你將無法在科爾多瓦的應用程序上做到這一點... – Riron
感謝@Riron,我需要確定 – Sascuash