src/Schema.php
public function getColumns(string $table, bool $clear = false, bool $names = true)
    {
        if ($clear) {
            unset($this->columns[$table]);
        }

        if (!$this->hasTable($table, $clear)) {
            return false;
        }

        if (!isset($this->columns[$table])) {
            $compiler = $this->connection->schemaCompiler();

            $database = $this->getCurrentDatabase();

            $sql = $compiler->getColumns($database, $table);

            $results = $this->connection
                ->query($sql['sql'], $sql['params'])
                ->fetchAssoc()
                ->all();

            $columns = [];

            foreach ($results as $ord => &$col) {
                $columns[$col['name']] = [
                    'name' => $col['name'],
                    'type' => $col['type'],
                ];
            }

            $this->columns[$table] = $columns;
        }

        return $names ? array_keys($this->columns[$table]) : $this->columns[$table];
    }
public function getColumns(string $table, bool $clear = false, bool $names = true)
    {
        if ($clear) {
            unset($this->columns[$table]);
        }

        if (!$this->hasTable($table, $clear)) {
            return false;
        }

        if (!isset($this->columns[$table])) {
            $compiler = $this->connection->schemaCompiler();

            $database = $this->getCurrentDatabase();

            $sql = $compiler->getColumns($database, $table);

            $results = $this->connection
                ->query($sql['sql'], $sql['params'])
                ->fetchAssoc()
                ->all();

            $columns = [];

            foreach ($results as $ord => &$col) {
                $columns[$col['name']] = [
                    'name' => $col['name'],
                    'type' => $col['type'],
                ];
            }

            $this->columns[$table] = $columns;
        }

        return $names ? array_keys($this->columns[$table]) : $this->columns[$table];
    }
public function getColumns ( string $ table , bool $ clear = false , bool $ names = true ) { if ( $ clear ) { unset ( $ this -> columns [ $ table ] ) ; } if ( ! $ this -> hasTable ( $ table , $ clear ) ) { return false ; } if ( ! isset ( $ this -> columns [ $ table ] ) ) { $ compiler = $ this -> connection -> schemaCompiler ( ) ; $ database = $ this -> getCurrentDatabase ( ) ; $ sql = $ compiler -> getColumns ( $ database , $ table ) ; $ results = $ this -> connection -> query ( $ sql [ 'sql' ] , $ sql [ 'params' ] ) -> fetchAssoc ( ) -> all ( ) ; $ columns = [ ] ; foreach ( $ results as $ ord => & $ col ) { $ columns [ $ col [ 'name' ] ] = [ 'name' => $ col [ 'name' ] , 'type' => $ col [ 'type' ] , ] ; } $ this -> columns [ $ table ] = $ columns ; } return $ names ? array_keys ( $ this -> columns [ $ table ] ) : $ this -> columns [ $ table ] ; }
Get a list with all columns that belong to the specified table

@param   string $table
@param   boolean $clear (optional) Refresh column list
@param   boolean $names (optional) Return only the column names

@return false|string[]
@throws \Exception
Get a list with all columns that belong to the specified table