how to join two table in codeigniter easily[updated] | ci_model | ci_controller | codeigniter 3 -datainflow
Nodejs is used database application and the Mysql is very popular database, nodejs has a simple way to connect with mySQL database.
We have to install database driver in nodejs to connect with Mysql database.
Step 1 : open terminal and change directory to node_modules of your project folder and run the command : “npm install mysql”
Step 2 : after installing mysql, open your routes file under the routes folder use the following code
var express = require('express'); var router = express.Router(); /* GET home page. */ var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "root", password: "****", database: "nodejs" }); con.connect(function(err) { if (err) throw err; console.log("Connected!"); }); module.exports = con;
Step 3: run the project
Related posts