i am new to node.js and my boss has entrusted me with a job to integrate a notification system in our attendance project.. so far i have successfully created a connection to my data base using express and mysql node modules and the code that helped me in achieving that is given below
var express=require('express');
var mysql=require('mysql');
var app=express();
var connection=mysql.createConnection({
host:'localhost',
user:'root',
password:'',
database:'attendance'
});
connection.connect(function(error) {
if(!!error) {
console.log('Error in connection');
} else {
console.log('Connected');
}
});
app.get('/',function (req, resp) {
connection.query("Select * from employee_leaves", function (error, rows, fields) {
if (!!error) {
console.log("Error in the query");
} else {
console.log("successfully done\n");
console.log(rows);
}
});
})
app.listen(1337);
// now the issue is i want to query this statement
SELECT * from employee_leaves WHERE employee_leave_company_name ='$sup_company_name' AND leave_status='Pending'ORDER BY employee_leave_id desc"
the issue is these variable $sup_company_name is in php so
1) how should i fetch value from that variable
2)how to use where clause in node.js
Note:: $sup_company_name is declared in my require.php file the code of require.php file is given below P.S i m accessing that variable in my other pages by include('require.php') but i dont know how to access that variable in node.js
session_start();
$sup_id = $_SESSION['employee_id'];
$sup_type=$_SESSION['employee_type'];
$sup_company_name=$_SESSION['employee_company_name'];