89 lines
2.1 KiB
JavaScript
89 lines
2.1 KiB
JavaScript
import {decode,encode} from 'html-entities';
|
|
|
|
|
|
|
|
|
|
function executeMysqlConnection(query){
|
|
let con = createMySQLConnection();
|
|
con.connect(function(err) {
|
|
if (err) throw err;
|
|
con.query(`SELECT * FROM subdomain_properties WHERE SubDomain = '${subdomain}'`, function (err, results) {
|
|
if (err) throw err;
|
|
// con.end();
|
|
if(results.length > 0){
|
|
|
|
}else{
|
|
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
function update(connection){
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Update json_data
|
|
*
|
|
* @param {object} json_data
|
|
* @param {string} db_table
|
|
* @param {object} connection
|
|
* @param {function} cb
|
|
*/
|
|
export function updateJsonData(json_data,db_table,connection,cb){
|
|
let data = encode(JSON.stringify(json_data));
|
|
const sql = `UPDATE ${db_table} SET jsontext = "${data}" WHERE mysql_id = "${json_data.json.mysql_id}"`;
|
|
connection.connect(function(err) {
|
|
if (err) throw err;
|
|
con.query(sql, function (err, results) {
|
|
if (err) throw err;
|
|
con.end();
|
|
if(cb!=undefined) cb();
|
|
});
|
|
});
|
|
}
|
|
|
|
export function updateMySQLMemberUsersJSONData(connection,email,json_data){
|
|
// const sql = 'UPDATE `users` SET `age` = 20 WHERE `name` = "Josh" LIMIT 1';
|
|
const sql = `UPDATE member_users SET json_data = "${json_data}" WHERE email = "${email}"`;
|
|
connection.connect(function(err) {
|
|
if (err) throw err;
|
|
con.query(sql, function (err, results) {
|
|
if (err) throw err;
|
|
con.end();
|
|
});
|
|
});
|
|
|
|
}
|
|
|
|
export async function getMemberUser(connection,email,callback){
|
|
connection.connect(function(err) {
|
|
if (err) throw err;
|
|
connection.query(`SELECT * FROM member_users WHERE email = '${email}'`, function (err, results) {
|
|
if (err) throw err;
|
|
con.end();
|
|
if(results.length > 0){
|
|
let membersuser = {
|
|
username: results[i].username,
|
|
json_data: results[i].json_data
|
|
};
|
|
callback(results[i]);
|
|
}else{
|
|
callback(false);
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|