NODE JS 프로그래밍중 궁금한점이있습니다.
글쓴이: 익명 사용자 / 작성시간: 목, 2017/06/01 - 12:56오전
VIEW.JS 파일에서 SELECT.JS 파일을 require로 호출하여 함수로 사용하고있습니다.
헌데 Node.js에서 SELECT.JS 에 나오는 rows 값을 retrun 시켜주고 싶은데 query문 안에서만 results가 값이 rows가 들어가더라구요 return 할때는 다시 undefind가 됩니다. 고수닙들 어떻게해야 좋을까요 ㅠ
exports.searchs = function(select,par) {
var mysql = require('mysql');
var results;
var connection = mysql.createConnection({
connectionLimit: 3,
host: '211.57.200.101',
user: 'root',
database: 'VLMS_License',
password: '516911ts!@'
});
connection.query('SELECT * from example where id= ? ',par, function (err, rows, fields) {
results=rows;
});
connection.end();
return results;
}Forums:

댓글 달기