そのように答えをポーリングすることができます。ノードにmysqlライブラリを使用したことがないので、APIを作成しました。
行数間隔
varconnection= ...、lastCount;
funciton mysqlPoll() {
var query = connection.query('SELECT count(field) as count FROM table');
query.exec(function(result) {
if (result.count != lastCount) {
//Select all the rows here using offset to skip the already processes
//process them
lastCount = result.count;
}
});
}
setInterval(mysqlPoll, 500); //every 1/2 second
プライマリ自動インクキー間隔がある場合はより良い
var connection = ...,
lastCount = 0;
funciton mysqlPoll() {
var query = connection.query('SELECT * FROM table WHERE primaryId > '+lastCount);
query.exec(function(result) {
if (result.count != lastCount) {
//Select all the rows here using offset to skip the already processes
//process them
lastCount = lastResultsPrimaryId;
}
});
}
setInterval(mysqlPoll, 500); //every 1/2 second
もう1つのオプションは、node.jsでソケット(net、httpなど)を開き、phpスクリプトからpingして更新をトリガーすることです。
お役に立てば幸い