Node.js SQL Server代码似乎有问题,但仍然有效吗?
试图按属性选择一个条目(id,user_name,foo,bar,等等);
这是我的socketing代码;
socket.on('database attribute', function(msg) {
queryDriver.getAllEntriesByAttribute(gatheringstable, 'user_name', 'john', function(err, gatherings) {
console.log(gatherings);
io.emit('database attribute', gatherings);
});
});
回答如下:
更改:
'SELECT * FROM ' + table + ' WHERE ' + attribute + '=' + value
至
'SELECT * FROM ' + table + ' WHERE "' + attribute + '"=' + value
在你的驱动程序代码中,我应该让你使用“正确”的命令。
如果你检查true / false 1 = 2或2 = 1,那么对于sql没什么区别,所以“标准”命令确实是人类偏好,而不是更多
评论列表(0)
- 暂无评论