我正在尝试通过回调在某些函数中执行MySQL查询,并出现错误:
TypeError:回调不是函数
select
A.itemid,
B.fullname
from A inner join B on B.id = A.itemid
where A.itemtype = 1
union all
select
A.itemid,
C.fullname
from A inner join C on C.id = A.itemid
where A.itemtype = 2
union all
select
A.itemid,
D.fullname
from A inner join D on D.id = A.itemid
where A.itemtype = 3
我想在第二个功能中分配数据。
答案 0 :(得分:0)
这应该做..
getContent = function (lang, callback) => {
con.query("SELECT "+lang+" FROM content", function(err,result) {
if (err) throw err;
if (result.length > 0) {
callback(result);
} else {
callback(false);
}
});
};
getContent(l, function(data) {
console.log(data);
});