public static bool updateOrNewConfig(string key, string value) { MysqlDatas data = getValue(key); if (!data.hasRows) { InsertQueryBuilder query = new InsertQueryBuilder(); query.Table = _table; query.addValue("config_key", key); query.addValue("config_value", value); query.addValue("created_at", Helper.GetDatabaseDateFormat()); string cmd = query.BuildQuery(); return(Utils.Mysql.execute(cmd)); } else { UpdateQueryBuilder query = new UpdateQueryBuilder(); query.Table = _table; query.addSet("config_value", value); query.AddWhere("config_key", Comparison.Equals, key); string cmd = query.BuildQuery(); return(Utils.Mysql.execute(cmd)); } return(false); }
public static bool deleteValue(int id) { DeleteQueryBuilder query = new DeleteQueryBuilder(); query.Table = _table; query.AddWhere("id", Comparison.Equals, id); string cmd = query.BuildQuery(); bool result = Utils.Mysql.execute(cmd); if (result) { UpdateQueryBuilder update = new UpdateQueryBuilder(); update.Table = "users"; update.addSet("faculty", "0"); update.AddWhere("faculty", Comparison.Equals, id); cmd = update.BuildQuery(); Utils.Mysql.execute(cmd); } return(result); }
public static bool blockedUser(int id) { /* Hard Delete */ /* * DeleteQueryBuilder query = new DeleteQueryBuilder(); * query.Table = _table; * query.AddWhere("id", Comparison.Equals, id); * string cmd = query.BuildQuery(); * bool result = Mysql.execute(cmd); * return result; */ /*Soft Delete*/ UpdateQueryBuilder query = new UpdateQueryBuilder(); query.Table = _table; query.addSet("status", "blocked"); query.AddWhere("id", Comparison.Equals, id); string cmd = query.BuildQuery(); bool result = Mysql.execute(cmd); return(result); }