var query = "select * from ? where info = 1;"
var params = [table]; //table = 'light'
connection.query(query, params, function(err, rows) { //this rows returns 'undefined'
console.log(rows);
var sql = "UPDATE ? SET info = ?,off_time = '?',run_time = '?' WHERE info = '1'";
var run_time = time_cal(formatted, rows);
var params = [table, data, formatted, run_time];
connection.query(sql, params, function(err, rows) {
if (err) {
console.log(err);
} else {
console.log("update success!");
}
});
});
mysql table at below
column | type
--------------------------------------+
info | tinyint(1) .......//1
--------------------------------------+
on_time | time ........//10:00:00
--------------------------------------+
off_time | time ........//11:00:00
--------------------------------------+
run_time | time ........//01:00:00
--------------------------------------+
while selecting time variable by nodejs, rows have returned 'undefined'
how can i receive proper data?
可能的原因是,表和列名称无法用参数绑定中的参数替换。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.