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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -