示例#1
0
        public override string GetSQLString(ISQL.DBType type)
        {
            StringBuilder sb = new StringBuilder();

            if (type == ISQL.DBType.mysql)
            {
                if (ignore)
                {
                    sb.Append("insert ");
                    sb.Append(" ignore ");
                }
                else
                {
                    sb.Append("replace");
                }
            }
            else
            {
                sb.Append("insert ");
            }
            sb.Append(" into ");
            sb.Append(tables.GetSQLString(type));
            if (type == ISQL.DBType.mysql)
            {
                sb.Append(" set ");
                sb.Append(fieldValues.GetSQLString(type));
            }
            else
            {
                ISQL[] fields = Sharpen.Collections.ToArray(fieldValues.GetFieldMap(), new ISQL[0]);
                if (fields.Length > 0)
                {
                    IList <string> fList = new List <string>();
                    IList <string> vList = new List <string>();
                    foreach (ISQL f in fields)
                    {
                        SQLCondition sc = (SQLCondition)f;
                        fList.Add("\"" + sc.GetField() + "\"");
                        vList.Add(" '" + SQLUtils.GetStandardSQLValue(sc.GetValue()) + "' ");
                    }
                    sb.Append(" (" + StringUtil.GetStringFromStrings(fList, ",") + ") values(" + StringUtil.GetStringFromStrings(vList, ",") + ") ");
                }
            }
            return(SQLUtils.RemoveMultiBlank(sb.ToString().Trim()));
        }
示例#2
0
 public virtual void AddWhereCondition(SQLCondition condition)
 {
     this.where.AddCondition(condition);
 }
示例#3
0
 public virtual void AddCondition(SQLCondition condition)
 {
     this.fieldValues.AddSQLCondition(condition);
 }