Load and return the list of columns that are restricted by a passed DB-table, the inverse fk list.
Require grant on “references” permissions of connected db-user. Memory cached.

@param	string	Name of external table to check.

@return	stdClass[]
342548
public function getInverseForeignKeys($tableName): array {
		
		if (!isset($this->definitions[$tableName]['inverseForeignKeys'])) {
			
			// old-style join because of speedness
			$query =
				'SELECT k.CONSTRAINT_NAME, k.REFERENCED_COLUMN_NAME, k.TABLE_NAME, ' .
				' k.COLUMN_NAME, r.UPDATE_RULE, r.DELETE_RULE' .
				' FROM information_schema.`KEY_COLUMN_USAGE` AS k' .
				' JOIN information_schema.`REFERENTIAL_CONSTRAINTS` AS r' .
				' WHERE k.CONSTRAINT_NAME != "PRIMARY"' .
				' AND k.TABLE_SCHEMA = ? AND k.REFERENCED_TABLE_NAME = ?' .
				' AND r.CONSTRAINT_SCHEMA = ? AND r.REFERENCED_TABLE_NAME = ?' .
				' AND k.CONSTRAINT_NAME = r.CONSTRAINT_NAME';

			$this->definitions[$tableName]['inverseForeignKeys'] = self::load($query, [DB_NAME, $tableName, DB_NAME, $tableName], PAIR_DB_OBJECT_LIST);
			
		}
		
		return $this->definitions[$tableName]['inverseForeignKeys'];

	}
1144360
public function getForeignKeysReferencingTable($tableName)
    {
        $matches = [];
        foreach ($this->foreignKeys as $fk) {
            if ($fk->getForeignTableName() === $tableName) {
                $matches[] = $fk;
            }
        }

        return $matches;
    }
801120
public function getSQLName($name)
    {
        $names = $this->getSQLNames();
        
        if (isset($names[$name]))
            return $names[$name];
        
        throw new NotFoundException('Cannot found real column name for ":name"', ['name' => $name]);
    }
330988
public function index(string $name = ''): array
    {
        //获取原始索引信息
        $indexes = $this->getIndex($name);
        $ret = [];

        //逐个处理
        foreach ($indexes as $index) {
            //索引名称
            $name = $index['Key_name'];

            //列名
            $col = $index['Column_name'];

            //列信息
            $columnInfo = [
                'name' => $col,
                'null' => $index['Null'] ? true : false,//列中是否含有NULL
                'subPart' => $index['Sub_part'],//如果列只是被部分地编入索引，则为被编入索引的字符的数目。如果整列被编入索引，则为NULL
            ];

            //索引中的第一列,则创建
            if ($index['Seq_in_index'] == 1) {
                $ret[$name] = [
                    'tableName' => $index['Table'], //所属表名
                    'isUnique' => !$index['Non_unique'], //是否唯一索引
                    'collation' => $index['Collation'], //这个有A和NULL, A是不区分大小写?
                    'columns' => [$col => $columnInfo],//本索引中包含的列
                    'cardinality' => $index['Cardinality'], //索引中唯一值的数目的估计值。
                    'packed' => $index['Packed'],//指示关键字如何被压缩。如果没有被压缩，则为NULL。
                    'type' => $index['Index_type'],//用过的索引方法（BTREE, FULLTEXT, HASH, RTREE）。
                    'comment' => $index['Comment'],//说明
                ];
            } else {
                //索引中的后继列,则只增加列信息
                $ret[$name]['columns'][$col] = $columnInfo;
            }
        }

        return $ret;
    }
151800
private static function getTable(string $className): array
    {
        $entities   = EntityCollector::getCollector();
        $fields     = $entities[$className]['field'];
        $idProperty = $entities[$className]['table']['id'];
        $tableName  = $entities[$className]['table']['name'];
        $idColumn   = $fields[$idProperty]['column'];

        return [$tableName, $idProperty, $idColumn, $fields];
    }
283369
private function getColumnFromName($name)
    {
        foreach ($this->columnConfiguration as $i => $col) {
            if ($col->getName() == $name) {
                return $col;
            }
        }

        // This exception should never happen. If it does, something is
        // wrong w/ the relationship between searchable columns and the
        // configuration.
        throw new DatatableException("A requested column was not found in the columnConfiguration.");
    }
65079
protected function getForeignKeys(string $tableName): ?array
    {
        $sql = sprintf("SELECT
                cols.TABLE_NAME,
                cols.COLUMN_NAME,
                cRefs.CONSTRAINT_NAME,
                refs.REFERENCED_TABLE_NAME,
                refs.REFERENCED_COLUMN_NAME,
                cRefs.UPDATE_RULE,
                cRefs.DELETE_RULE
            FROM INFORMATION_SCHEMA.COLUMNS AS cols
            LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS refs
                ON refs.TABLE_SCHEMA=cols.TABLE_SCHEMA
                AND refs.REFERENCED_TABLE_SCHEMA=cols.TABLE_SCHEMA
                AND refs.TABLE_NAME=cols.TABLE_NAME
                AND refs.COLUMN_NAME=cols.COLUMN_NAME
            LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS cons
                ON cons.TABLE_SCHEMA=cols.TABLE_SCHEMA
                AND cons.TABLE_NAME=cols.TABLE_NAME
                AND cons.CONSTRAINT_NAME=refs.CONSTRAINT_NAME
            LEFT JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS cRefs
                ON cRefs.CONSTRAINT_SCHEMA=cols.TABLE_SCHEMA
                AND cRefs.CONSTRAINT_NAME=refs.CONSTRAINT_NAME
            WHERE
                cols.TABLE_NAME = %s
                AND cols.TABLE_SCHEMA = DATABASE()
                AND refs.REFERENCED_TABLE_NAME IS NOT NULL
                AND cons.CONSTRAINT_TYPE = 'FOREIGN KEY'
            ;", $this->quote($tableName));

        $rows = $this->queryFetchAll($sql);

        if (empty($rows)) {
            return null;
        }

        $result = [];
        foreach ($rows as $row) {
            $result[$row['CONSTRAINT_NAME']] = $row;
        }

        return $result;
    }
723397
protected function loadTable($name)
	{
		$table=new CMssqlTableSchema;
		$this->resolveTableNames($table,$name);
		//if (!in_array($table->name, $this->tableNames)) return null;
		$table->primaryKey=$this->findPrimaryKey($table);
		$table->foreignKeys=$this->findForeignKeys($table);
		if($this->findColumns($table))
		{
			return $table;
		}
		else
			return null;
	}
435496
public function Columns($Name = '') {
      if (strlen($Name) > 0) {
         if (array_key_exists($Name, $this->_Columns))
            return $this->_Columns[$Name];
         else {
            foreach($this->_Columns as $ColName => $Def) {
               if (strcasecmp($Name, $ColName) == 0)
                  return $Def;
            }
            return NULL;
         }
      }
		return $this->_Columns;
	}
395430
public function parseTable($name): array
    {
        if ($name instanceof Model) {
            return [$name->alias(), $name->name()];
        }

        if (is_array($name)) {
            return [key($name), current($name)];
        }

        if (is_scalar($name)) {
            return static::parseName($name);
        }

        return [null, $name];
    }
1094821
protected function getColumns($tableName): array
    {
        $sql = sprintf('SELECT * FROM information_schema.columns
                    WHERE table_schema=database()
                    AND table_name = %s', $this->quote($tableName));

        $rows = $this->queryFetchAll($sql);

        $result = [];
        foreach ($rows as $row) {
            $name = $row['COLUMN_NAME'];
            $result[$name] = $row;
        }

        return $result;
    }
458885
public function getColumn($name)
    {
        $columnValues = array();
        foreach ($this->getRows() as $row) {
            $columnValues[] = $row->getColumn($name);
        }
        return $columnValues;
    }
361765
public function getColumn(string $name)
    {
        if (!isset($this->fields[$name])) {
            Throw new ColumnException(sprintf('A field named "%s" does not exist in this table', $name));
        }

        return $this->fields[$name];
    }
691873
public function getColumns($tableName)
    {
        if (!isset($this->cache[$tableName])) {
            $columns = $this->entityManager->getConnection()->getSchemaManager()->listTableColumns($tableName);
            if ('leads' === $tableName) {
                if (!$this->extendedFieldAliases) {
                    // Hacked this query into here to avoid a recursive dependency in 2.15.0
                    $fq = $this->entityManager->getConnection()->createQueryBuilder();
                    $fq->select('f.alias')
                        ->from(MAUTIC_TABLE_PREFIX.'lead_fields', 'f')
                        ->where(
                            $fq->expr()->orX(
                                $fq->expr()->eq('f.object', $fq->expr()->literal('extendedField')),
                                $fq->expr()->eq('f.object', $fq->expr()->literal('extendedFieldSecure'))
                            )
                        );
                    foreach ($fq->execute()->fetchAll() as $result) {
                        $this->extendedFieldAliases[$result['alias']] = 'extendedField - This is never used as an actual column object';
                    }
                }
                if ($this->extendedFieldAliases) {
                    $columns = array_merge($columns, $this->extendedFieldAliases);
                }
            }
            $this->cache[$tableName] = $columns ?: [];
        }

        return $this->cache[$tableName];
    }
1279785
public function getBlocks($name)
    {
        $result = array();

        if(isset($this->__blocks[$name])) {
            $result = $this->__blocks[$name];
        }

        return $result;
    }
1299834
public function types($name)
    {
        $return = [];
        foreach ($this->controls as $control) {
            if ((method_exists($control, 'getType') ? $control->getType() : $control->type) == $name) {
                array_push($return, $control);
            }
        }
        return $return;
    }
393485
protected function isColumnSetLocally($name)
	{
		$columns = $this->getColumns();
		return array_contains(
			$columns,
			function($descriptor) use ($name)
			{
				$alias = $descriptor[2];
				$column = $descriptor[1];
				return $name === (null === $alias ? $column : $alias);
			}
		);
	}