List table columns.

@param $table

@return \Doctrine\DBAL\Schema\Column[]
543481
public function columns($table)
    {
        return Cache::remember("{$table}_columns", $this->lifetime(), function () use ($table) {
            $columns = $this->manager->listTableColumns($table);
            $keys = array_keys($columns);
            $vals = array_values($columns);

            $keys = array_map(function ($key) {
                return trim(str_replace(['`', '"'], '', $key));
            }, $keys);

            return array_combine($keys, $vals);
        });
    }
730606
private function get_columns( $table ) {
		global $wpdb;

		$table_sql    = $this->esc_sql_ident( $table );
		$primary_keys = $text_columns = $all_columns = array();

		foreach ( $wpdb->get_results( "DESCRIBE $table_sql" ) as $col ) {
			if ( 'PRI' === $col->Key ) {
				$primary_keys[] = $col->Field;
			}

			if ( $this->is_text_col( $col->Type ) ) {
				$text_columns[] = $col->Field;
			}

			$all_columns[] = $col->Field;
		}

		return array( $primary_keys, $text_columns, $all_columns );
	}
386312
public function getTableIndexes( $table )
    {
        $query = "SELECT * FROM information_schema.statistics WHERE table_schema =
                 ? AND table_name = ?";

        $params = [ $this->name, $table ];

        $statement = $this->database->prepare( $query );
        $statement->execute( $params );

        $results = $statement->fetchAll();

        $indexes = [ ];

        if ( !empty( $results ) )
        {
            $name = NULL;

            $i = 0;

            foreach ( $results as $result )
            {
                if ( !in_array( $result[ 'INDEX_NAME' ], $indexes ) )
                {
                    $indexes[ ] = $result[ 'INDEX_NAME' ];
                }
            }
        }

        return $indexes;
    }
208662
public function getTableKeys($table)
	{
		$keys = array();

		$fieldCasing = $this->connection->getAttribute(\PDO::ATTR_CASE);

		$this->connection->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_UPPER);

		$table = strtoupper($table);

		$this->setQuery('pragma table_info( ' . $table . ')');
		$rows = $this->loadObjectList();

		foreach ($rows as $column)
		{
			if ($column->PK == 1)
			{
				$keys[$column->NAME] = $column;
			}
		}

		$this->connection->setAttribute(\PDO::ATTR_CASE, $fieldCasing);

		return $keys;
	}
486595
public static function getTableBelongsToFields(Table $table): array
    {
        $fields = [];
        $belongsToModels = Configure::read('RolesCapabilities.accessCheck.belongsToModels');

        foreach ($table->associations() as $association) {
            // skip non-assignation models
            if (!in_array($association->className(), $belongsToModels)) {
                continue;
            }

            $fields[] = $association->foreignKey();
        }

        return $fields;
    }
1073471
protected function findColumns($table)
	{
		$sql='SHOW FULL COLUMNS FROM '.$table->rawName;
		try
		{
			$columns=$this->getDbConnection()->createCommand($sql)->queryAll();
		}
		catch(Exception $e)
		{
			return false;
		}
		foreach($columns as $column)
		{
			$c=$this->createColumn($column);
			$table->columns[$c->name]=$c;
			if($c->isPrimaryKey)
			{
				if($table->primaryKey===null)
					$table->primaryKey=$c->name;
				elseif(is_string($table->primaryKey))
					$table->primaryKey=array($table->primaryKey,$c->name);
				else
					$table->primaryKey[]=$c->name;
				if($c->autoIncrement)
					$table->sequenceName='';
			}
		}
		return true;
	}
350994
public function get_columns($table) {
		$result = $this->get_table_definition($table);

		$columns = [];
		foreach ($result as $row) {
			$columns[] = &$row['Field'];
		}

		return $columns;
	}
314272
protected function addColumns(Table $table)
    {
        $stmt = $this->dbh->query(sprintf('SHOW COLUMNS FROM %s', $this->getPlatform()->doQuoting($table->getName())));

        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $column = $this->getColumnFromRow($row, $table);
            $table->addColumn($column);
        }
    }
1262856
protected function findColumns($table)
	{
		$sql=<<<EOD
SELECT a.attname, LOWER(format_type(a.atttypid, a.atttypmod)) AS type, d.adsrc, a.attnotnull, a.atthasdef,
	pg_catalog.col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attnum > 0 AND NOT a.attisdropped
	AND a.attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname=:table
		AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = :schema))
ORDER BY a.attnum
EOD;
		$command=$this->getDbConnection()->createCommand($sql);
		$command->bindValue(':table',$table->name);
		$command->bindValue(':schema',$table->schemaName);

		if(($columns=$command->queryAll())===array())
			return false;

		foreach($columns as $column)
		{
			$c=$this->createColumn($column);
			$table->columns[$c->name]=$c;

			if(stripos($column['adsrc'],'nextval')===0 && preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i',$column['adsrc'],$matches))
			{
				if(strpos($matches[1],'.')!==false || $table->schemaName===self::DEFAULT_SCHEMA)
					$this->_sequences[$table->rawName.'.'.$c->name]=$matches[1];
				else
					$this->_sequences[$table->rawName.'.'.$c->name]=$table->schemaName.'.'.$matches[1];
				$c->autoIncrement=true;
			}
		}
		return true;
	}
900887
protected function columns(Table $table)
		{
			$columns = array();

			foreach ($table->columns as $column) {
				// Each of the data type's have their own definition creation method,
				// which is responsible for creating the SQL for the type. This lets
				// us to keep the syntax easy and fluent, while translating the
				// types to the correct types.
				$sql = $this->wrap($column) . ' ' . $this->type($column);

				$elements = array('nullable', 'defaults', 'incrementer');

				foreach ($elements as $element) {
					$sql .= $this->$element($table, $column);
				}

				$columns[] = $sql;
			}

			return $columns;
		}
290723
protected function _fetchTableColumns($table)
    {
        $return = array();
        $query  = $this->getObject('lib:database.query.show')
            ->show('FULL COLUMNS')
            ->from($table);

        if($columns = $this->select($query, Database::FETCH_OBJECT_LIST))
        {
            foreach($columns as $column)
            {
                // Set the table name in the raw info (MySQL doesn't add this).
                $column->Table = $table;

                $column = $this->_parseColumnInfo($column, $table);
                $return[$column->name] = $column;
            }
        }

        return $return;
    }
996106
public function getIndexes($table): ?array
	{
		return $this->driverQuery($this->getSql()->indexList($this->prefixTable($table)), FALSE);
	}
816733
protected function generateColumns($table)
    {
        $columns = [];
        $needPK = true;
        foreach ($table->columns as $column) {
            if ($column->autoIncrement) {
                $columns[$column->name] = $column->type == Schema::TYPE_BIGINT ? 'Schema::TYPE_BIGPK' : 'Schema::TYPE_PK';
                $needPK = false;
                continue;
            }
            list($type, $extra) = $this->getSchemaType($column);
            $quote = "'";
            if (!$column->allowNull) {
                $extra .= ' NOT NULL';
            }

            if ($column->defaultValue !== null) {
                $extra .= ' DEFAULT ';
                if ($column->defaultValue instanceof Expression || is_numeric($column->defaultValue)) {
                    $extra .= $column->defaultValue;
                } else {
                    $extra .= "'{$column->defaultValue}'";
                    $quote = '"';
                }
            }

            if (!empty($extra)) {
                $type = "$type . {$quote}$extra{$quote}";
            }
            $columns[$column->name] = $type;
        }
        if ($needPK && !empty($table->primaryKey)) {
            $pks = implode(']], [[', $table->primaryKey);
            $columns[0] = "PRIMARY KEY ([[{$pks}]])";
        }

        return $columns;
    }
145563
public function getFields ($table)
		{
			$sql = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = " . $this->quote($table);

			return $this->query($sql)->fetchColumn('COLUMN_NAME');
		}
1159569
public function getTableKeys($table)
    {
        $this->connect();

        $keys = array();
        $query = $this->getQuery(true);

        $fieldCasing = $this->getOption(PDO::ATTR_CASE);

        $this->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);

        $table = strtoupper($table);
        $query->setQuery('pragma table_info( ' . $table . ')');

        // $query->bind(':tableName', $table);

        $this->setQuery($query);
        $rows = $this->loadObjectList();

        foreach ($rows as $column)
        {
            if ($column->PK == 1)
            {
                $keys[$column->NAME] = $column;
            }
        }

        $this->setOption(PDO::ATTR_CASE, $fieldCasing);

        return $keys;
    }
925306
public function getIdActionColumnNames($table)
    {
        $columns = $this->getColumns($table);

        $columns = array_filter($columns, function ($columnName) {
            return strpos($columnName, 'idaction') !== false;
        });

        return array_values($columns);
    }
330127
public function FetchColumns($Table) {
      $Sql = $this->FetchColumnSql($Table);
      $Data = $this->Query($Sql);
      $Return = array();
      foreach($Data->ResultArray() as $Row) {
         if (isset($Row['COLUMN_NAME']))
            $Return[] = $Row['COLUMN_NAME'];
         else
            $Return[] = current($Row);
      }

      return $Return;
   }