小编Dee*_*uel的帖子

无法使用mysql和节点js返回选择查询值

我是节点js的新手,现在我正在尝试使用节点js在mysql中设置select查询的返回值....我正在使用node-mysql包...

示例代码

var mysql =  require('mysql');
var connection =  mysql.createConnection({
    host : "localhost",
    user : "root",
    password: "root123",
    database: "testdb"
});

var retValue = undefined;

var query = connection.query('SELECT * FROM tblData;');
query
    .on('error', function(err) {
        // Handle error, an 'end' event will be emitted after this as well
    })
    .on('fields', function(fields) {
        // the field packets for the rows to follow
    })
    .on('result', function(row) {
        // Pausing the connnection is useful if your processing involves I/O
        connection.pause();
        processRow(row, function() …
Run Code Online (Sandbox Code Playgroud)

javascript mysql asynccallback node.js

6
推荐指数
1
解决办法
2388
查看次数

标签 统计

asynccallback ×1

javascript ×1

mysql ×1

node.js ×1