public void addTables(string tables) { tables = tables.Trim(); while (tables.Length > 0) { string tableShort = utl.cutl(ref tables, ",").Trim().ToLower(); tables = tables.Trim(); string tableName = utl.cutl(ref tableShort, " ").Trim().ToLower(); if (tableShort.Length == 0) { tableShort = tableName; } //if ((this.tables.Len() == 0) && (tables.Length == 0)) {this.Name = tableName; this.Short = tableShort; return; } if (currentState() == 0) // state is "empty", this DbGrid does not even contain a single table ... { Name = tableName; Short = tableShort; //dbdb if (db.Tables.hasKey(Name)) fields = new KeyPile<string, string>(db.Tables[Name].fields); for (int i = 1; i <= fields.Len; i++) { fields[i] = new DbField(Short + "." + fields[i].sql()); } } else { DbGrid g = new DbGrid(this); if (currentState() == 1) { this.tables.Add(Name + " " + Short, new DbGrid(this)); } this.tables.Add(tableName + " " + tableShort, new DbGrid(tableName + " " + tableShort)); Name = ""; Short = ""; fields = new Pile <DbField>(); foreach (DbGrid tab in this.tables) { foreach (DbField x in tab.Fields) { fields.Add(new DbField(tab.Short + "." + x.sql())); } } } } }
private void init(Pile <DbField> fields, string from, Pile <DbCnd> join, Pile <DbCnd> where) { this.count = -1; this.distinct = false; this.order = ""; this.fields = fields.Clone(); from = from.Trim(); while (from.Length > 0) { string tShort = utl.cutl(ref from, ",").Trim().ToLower(); string tName = utl.cutl(ref tShort, " ").Trim(); tShort = tShort.Trim(); if (tShort.Length == 0) { tShort = tName; } this.from.Add(tShort, tName); from = from.Trim(); } this.join = join; this.where = where; }