Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public MySQLInsert(string table, MySQLConnection database, params string[] fields)
     : base(table, database, fields)
 {
 }
Ejemplo n.º 4
0
 public MySQLInsert(string table, MySQLConnection database) : base(table, database)
 {
 }
Ejemplo n.º 5
0
 public MySQLDelete(string table, MySQLConnection database) : base(table, database)
 {
 }
Ejemplo n.º 6
0
 public MySQLSelect(string table, MySQLConnection database) : base(table, database)
 {
 }