How to use the escape function from mysql

Find comprehensive JavaScript mysql.escape code examples handpicked from public code repositorys.

63
64
65
66
67
68
69
70
71
72
});

data = "SELECT * " +
    "FROM users " +
    "WHERE username = " + mysql.escape(req.body.name) +
    "AND password = " + mysql.escape(req.body.pass);


connectDB.query(data, (err, result) => {
    if (err) throw err;
fork icon0
star icon0
watch icon1

+ 71 other calls in file

39
40
41
42
43
44
45
46
47
48
   database: "hotel"
});

data = "SELECT * " +
   "FROM  user " +
   "WHERE email = " + mysql.escape(req.body.mail) +
   " AND password = " + mysql.escape(req.body.pass);


connectDB.query(data, (err, result) => {
fork icon0
star icon0
watch icon1

+ 35 other calls in file

42
43
44
45
46
47
48
49
50
51
});

data = "SELECT * " +
    "FROM admin " +
    "WHERE name = " + mysql.escape(req.body.name) +
    "AND pass = " + mysql.escape(req.body.pass);

data1 = "SELECT * " +
    "FROM  bookingstatus " +
    "WHERE status = 0 ";
fork icon0
star icon0
watch icon1

+ 87 other calls in file

1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
}
// number、string、boolean 类型
if (typeOf.isNumber(value) ||
    typeOf.isString(value) ||
    typeOf.isBooloon(value)) {
    return mysql.escape(value);
}
// null 类型
if (typeOf.isNull(value)) {
    return 'null';
fork icon0
star icon0
watch icon1

+ 2 other calls in file

37
38
39
40
41
42
43
44
45
46
this.resume = function() {
    connection.resume();
};

this.escape = function(val, stringifyObjects, timeZone) {
    return Mysql.escape(val, stringifyObjects, timeZone || connection.config.timezone);
};

this.escapeId = function(val, forbidQualified) {
    return Mysql.escapeId(val, forbidQualified);
fork icon0
star icon0
watch icon0