예제 #1
0
 public override string GetSQLString(ISQL.DBType type)
 {
     if (orList.Count > 0 || andList.Count > 0)
     {
         string sb = string.Empty;
         if (andList.Count > 0)
         {
             FieldValuesSQL fv = new FieldValuesSQL(" and ");
             foreach (ISQL sql in andList)
             {
                 fv.AddSQLCondition(sql);
             }
             sb = sb + fv.GetSQLString(type);
         }
         if (orList.Count > 0)
         {
             FieldValuesSQL fv = new FieldValuesSQL(" or ");
             foreach (ISQL sql in orList)
             {
                 fv.AddSQLCondition(sql);
             }
             if (andList.Count > 0)
             {
                 sb = sb + " and (" + fv.GetSQLString(type) + ")";
             }
             else
             {
                 sb = fv.GetSQLString(type);
             }
         }
         return("(" + sb + ")");
     }
     return(string.Empty);
 }
예제 #2
0
 public override string GetSQLString(ISQL.DBType type)
 {
     if (fieldValues.Size() == 0 || StringUtil.IsNullOrEmpty(fieldValues.GetSQLString(type)))
     {
         return(string.Empty);
     }
     else
     {
         return(" where " + fieldValues.GetSQLString(type));
     }
 }
예제 #3
0
        public override string GetSQLString(ISQL.DBType type)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("update ");
            sb.Append(tables.GetSQLString(type));
            sb.Append(" set ");
            sb.Append(fieldValues.GetSQLString(type));
            sb.Append(where.GetSQLString(type));
            return(SQLUtils.RemoveMultiBlank(sb.ToString().Trim()));
        }
예제 #4
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()));
        }
예제 #5
0
 public override string GetSQLString(ISQL.DBType type)
 {
     return(SQLUtils.RemoveMultiBlank("CREATE TABLE `" + tableName + "` (" + fields.GetSQLString(type) + ")" + SQLUtils.BLANK + options.GetSQLString(type) + ";"));
 }