为什么我不能把回拨作为记录?必须作为字段('id')ss:https://prnt.sc/ju4xb2
从dao读取结果作为数据行[0]
如何从记录ex:'0001'获取数据?请帮忙谢谢
刀
var executeQuery = function(query,callback) {
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'testt'
});
connection.connect();
connection.query(query, function(err, rows, fields) {
if (err) throw err;
connection.end();
console.log("Here in Dao: " + rows[0].mobile_phone);
callback(rows[0].mobile_phone);
});
};
module.exports = {
executeQuery: executeQuery
};
模型
var DAO = require('../lib/database.js');
module.exports = {
getuser : function(id,callback){
var User = DAO.executeQuery("select mobile_phone from ms_customer WHERE id = " + id, function(mobile_phone){
// var json = JSON.stringify(User);
console.log("Return from Dao = " +User);
callback(mobile_phone);
});
}
}
控制器
test : function(req,res){
var customerModel = require('../model/customer');
customerModel.getuser('0001', function(mobile_phone){
console.log("return from model_user = " + mobile_phone);
});
},
我总是得到error='er\u bad\u field\u error:'where子句'中的未知列'0001'
1条答案
按热度按时间hc8w905p1#
我想查询语句出错了,请试试这个。