-
Notifications
You must be signed in to change notification settings - Fork 0
/
methods.js
53 lines (52 loc) · 1.46 KB
/
methods.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var express = require('express');
var path=require('path');
const split = require('split-string');
var fs = require('fs');
var app = express();
var session = require('express-session');
var bodyParser = require('body-parser');
var mysql = require('mysql');
const db = require('./config.js');
var connection = db.connection;
module.exports.insertValues = function(pname, likedBy)
{
connection.query("SELECT * FROM rlikes where user = ?",[pname],function(err,results,fields)
{
if(err)
{
console.log("error at query");
}
else
{
if(results.length > 0)
{
console.log("db",likedBy,pname);
connection.query("UPDATE rlikes SET likedBy = ? where user=?",[likedBy,pname],function(err,results,fields)
{
if(err)
{
console.log("error at query");
}
else
{
console.log("likedBy values "+pname+" "+likedBy);
}
});
}
else
{
console.log("dber",likedBy,pname);
connection.query("INSERT INTO rlikes values('"+pname+"','"+likedBy+"')",function(err,resultRows,fields)
{
if(err)
{
console.log("error at query");
}
else{
console.log("likedBy values "+pname+" "+likedBy);
}
});
}
}
});
}