public static string EscapeValue(string value, int format, ref Dictionary <string, object> parameters) { string param = null; switch (format) { case ParameterFormat.RAW: param = value; break; case ParameterFormat.ESCAPE_PARAMETER_AS_FIELD: param = MySQLConnection.FieldEscape(value); break; default: param = String.Format("@val{0}", (parameters.Count + 1)); parameters.Add("@val" + (parameters.Count + 1), value); break; } return(param); }
public override bool Execute(Dictionary <string, object> parameters) { List <string> setFields = new List <string>(); foreach (FieldUpdate field in base.FieldUpdates) { string fieldEscaped = MySQLConnection.FieldEscape(field.Field); string value = MySQLConnection.EscapeValue(field.Value, field.ValueFormat, ref parameters); setFields.Add(String.Format("{0}={1}", fieldEscaped, value)); } string fieldSQL = String.Join(", ", setFields); if (base.Conditions.Count() < 1) { return(Database.ExecuteUpdate(String.Format("UPDATE {0} SET {1}", fieldSQL, Table))); } string query = String.Format("UPDATE {0} SET {1} WHERE {2}", base.Table, fieldSQL, Database.BuildConditionSQL(base.Conditions, ref parameters)); return(Database.ExecuteUpdate(query, parameters)); }
public MySQLInsert(string table, MySQLConnection database, params string[] fields) : base(table, database, fields) { }
public MySQLInsert(string table, MySQLConnection database) : base(table, database) { }
public MySQLDelete(string table, MySQLConnection database) : base(table, database) { }
public MySQLSelect(string table, MySQLConnection database) : base(table, database) { }