Let Node.js and PHP use the same database(mysql)? -
i built application using php, , want make application have real-time service. so, use socket.io node.js. but, how let node.js , php use same database(mysql)?
install mysql module nodejs.
npm install mysql
using module can use mysql database
var mysql = require('mysql'); var conn = mysql.createconnection( { host : 'localhost', user : '.....', password : '......', database : '.......' } ); conn.connect(); var querystring = 'select * .............'; conn.query(querystring, function(err, rows, fields) { if (err) { console.log(err); } else { console.log(rows); } });
Comments
Post a Comment