我必須更新數據庫中的一行,寫這個更新查詢中的node.js
var o_voto_foto = {
Profilo: profilo,
Foto: data.id_foto_votata,
punteggio: data.voto,
};
connection.query('UPDATE prof_voto_foto SET ? WHERE profilo_id = :Profilo AND foto_id = :Foto',o_voto_foto, function(error, rows) {
if (error) {
var err = "Error on UPDATE 'votoFotoFancybox': " + error;
console.error(err);
throw err;
}
connection.end();
callback();
});
但我得到一個語法錯誤。然而 ,如果查詢與該語法
connection.query('UPDATE prof_voto_foto SET punteggio = '+data.voto+' WHERE profilo_id = '+profilo+' AND foto_id = '+data.id_foto_votata,function(error, rows) {
做我用這個外部庫 https://github.com/felixge/node-mysql
「但是我得到一個語法錯誤」 - **你得到了什麼**語法錯誤? – Quentin
錯誤:ER_PARSE_ERROR:您的SQL語法中有錯誤;檢查與您的MySQL服務器版本相對應的手冊,以便在第1行':Profilo AND foto_id =:Foto'處使用正確的語法。 – Barno