示例#1
0
        public string GetColumnMySQLDefinitionLine(DBTableControl dbTables, ref List<ForeignKey> m_Fkey, List<string> UniqueConstraintNameList, ref string sql_DBm, SQLTable DBm_owner_Table)
        {
            SQLTable refTable = null;
            SQLTable new_ref_Table = null;
            if (obj != null)
            {
                string columnName = StaticLib.Func.GetNameFromObjectType(obj);
                this.Name = columnName;
                string sBasicType = null;
                // complex types
                string strNull;
                if (nulltype == nullTYPE.NOT_NULL)
                {
                    strNull = " NOT NULL";
                }
                else
                {
                    strNull = " NULL";
                }

                if (obj.GetType() == typeof(ID))
                {
                    ID ID = (ID)obj;
                    return Globals.LeftMargin + "`" + columnName + "` " + DBtypesFunc.GetBasicTypeMySQL(obj) +" unsigned NOT NULL AUTO_INCREMENT";
                }
                else if (dbTables.IsMyTable(out refTable, obj.GetType()))
                {
                    if (DBtypesFunc.Is_DBm_Type(refTable.objTable))
                    {
                        if (DBm_owner_Table == null)
                        {
                            DBm_owner_Table = this.ownerTable;
                        }
                        new_ref_Table = new SQLTable(refTable, DBm_owner_Table, dbTables.items);
                        dbTables.items.Add(new_ref_Table);

                        string new_sql_DBm = new_ref_Table.MySQLcmd_CreateTable(dbTables, UniqueConstraintNameList, ref sql_DBm, DBm_owner_Table);
                        sql_DBm += new_sql_DBm;

                        refTable = new_ref_Table;
                        this.Name = refTable.TableName;
                        int iCount = this.Name_in_language.sText_Length;
                        for (int i = 0; i < iCount; i++)
                        {
                            this.Name_in_language.sText(i,refTable.lngTableName.sText(i) + "_" + this.Name_in_language.sText(i));
                        }
                    }
                     this.Name =  this.Name  + "_ID";
                    string str;
                    ForeignKey fk = new ForeignKey();
                    object obj_reftable_id = refTable.FindIdentityObject();
                    string sIdentityType;
                    if (obj_reftable_id != null)
                    {
                        sIdentityType = " " + DBtypesFunc.GetBasicTypeMySQL(obj_reftable_id) + " ";
                    }
                    else
                    {
                        sIdentityType = " [" + Globals.m_IdentityIndexTYPE + "]";
                    }

                    str = Globals.LeftMargin + AddForeignKeyMySQL(ref m_Fkey, refTable, ref fk) + " " + sIdentityType + " unsigned " + strNull;
                    fKey = fk;
                    return str;
                }
                else
                {
                    sBasicType = DBTypes.DBtypesFunc.GetBasicTypeMySQL(obj);
                }
                return Globals.LeftMargin + "`" + columnName + "` " + sBasicType + strNull;
            }
            else
            {
                return "!!!Object Is Null!!!";
            }
        }