connection.query
function menerima dua hingga tiga argumen:pernyataan SQL, (nilai) dan panggilan balik. Di sini, fungsi mengambil empat argumen, jadi dianggap [first_name, last_name,]
adalah panggilan balik.
Yang dapat Anda lakukan adalah:
...
connection.query('INSERT INTO user SET user_id = ?, first_name = ?,last_name = ?', [decoded.id, first_name, last_name,], (err, rows) => {
if (!err) {
res.render('add-crew', { alert: 'Crew member added succesfully!' });
} else {
console.log(err);
}
console.log('The data from user table:\n', rows);
});
...
Saya harap ini yang Anda cari.
Sunting Anda juga bisa melakukan:
...
connection.query('INSERT INTO user SET ?', {user_id: decoded.id, first_name: first_name, last_name: last_name}, (err, rows) => {
if (!err) {
res.render('add-crew', { alert: 'Crew member added succesfully!' });
} else {
console.log(err);
}
console.log('The data from user table:\n', rows);
});
...