2013-10-05 71 views
0

我不知道为什么我无法访问我的属性。NodeJs-MySQL对象属性undefined

connection.query("call VerifyAccountToken(0, null)", function(err, rows, fields) { 
    if(err) console.log("Error: " + err); 

    console.log("SQLRet: ", rows[0].result); 
    console.log(rows); 
    console.log(fields); 
}); 

VerifyAccountToken以名为'result'的列返回单个行/列结果。 控制台输出如下:

SQLRet:未定义

[[{结果:0}], {段计数:0, affectedRows:0, insertId:0, serverStatus:2, WARNINGCOUNT:1, 消息: '', protocol41:真, changedRows:0}]

[[{目录: 'DEF', 分贝: '', 表: '', orgTable: '', 名: '结果', ORGNAME: 'IRES', filler1:, 的charsetnr:63, 长度:11, 类型:3, 国旗:0, 小数0, filler2:, 默认:未定义, ZEROFILL:假的, protocol41:真正}], 未定义]

我知道的一切告诉我,这应该工作。

+0

显然我需要使用rows [0] [0] .result ...这看起来像一个错误。 – DeaconSyre

回答

0

好显然我需要使用

rows[0][0].result; 

我不知道为什么存储过程节点mysql的巢返回的结果。

+0

大概这是因为MySQL存储过程可以返回多个结果集,这是一个非常有用的功能,行[0]可能是第一个“n”;请参阅此处的最后一段:http://dev.mysql.com/doc/refman/5.6/en/stored-routines-syntax.html –

相关问题