我试图像这样做一个基本的选择:
router.post('/', function(req, res, next) {
var username = req.body.username;
var password = req.body.password;
var sql = "SELECT * FROM user WHERE username = username";
db.query(sql, function (err, rows, fields) {
if (err) throw err;
var hash = rows.password;
console.log(hash);
});
res.redirect('/');
});
不幸的是,console.log正在记录未定义,因此,我认为我的查询无效。任何线索都会受到赞赏。