我在mysql數據庫中添加了新的用戶信息。我如何獲得最近添加的記錄ID,以便我可以創建用戶登錄詳細信息。請介意這個應用程序的環境。 我使用的是 1. Windows 2. NPM,Express 3. MySQL 這是我的代碼。如何在node.js中從mysql獲取最近添加的recode id
var input = JSON.parse(JSON.stringify(req.body));
req.getConnection(function (err, connection) {
var data = {
username : input.username,
pswd : input.pswd,
email : input.email,
phone : input.phone
};
var query = connection.query("INSERT INTO customer set ? ",data, function(err, rows)
{
if (err)
console.log("Error inserting : %s ",err);
//console.log(query.sql);
res.redirect('/dashboard');
});
});
怎麼最近添加的記錄ID將幫助在創建用戶登錄細節? – Ravi 2014-09-11 12:32:40