let insertSql = 'insert into User(username ,password,name,gender,age) values (?,?,?,?,?)';
let insertParams = [username, password, name, gender, age];
# mysqlConnection.query(insertSql, insertParams, function (error, results, fields) {
if (error) throw error;
return results;
}));
##;
#//2.select運算(我自己測試的時候發現,字串類型的列,要給參數額外增加引號,否則會被當做數字類型或列名來進行處理)
let selectSql = 'select id from User where username = \''.concat(username, '\' and password = \'', password, '\'');
mysqlConnection.query(selectSql, function (error, results, fields) {
if(error) throw error;
return results;
##});
##});
##});
#//3.delete操作
let deleteSql = 'delete from user where id = \''.concat(id, '\'');
mysqlConnection.query(deleteSql, function (error, results, fields) {
if (error) throw error;
return results;
#}) ;
//4.update操作
let updateSql = 'update User set age = 30 where id = \''.concat(id, ' \'');
mysqlConnection.query(updateSql, function (error, results, fields) {
if (error) throw error;
return results;
});
#