src/Charcoal/Source/DatabaseSource.php
public function tableStructure()
    {
        $dbh    = $this->db();
        $table  = $this->table();
        $driver = $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
        if ($driver === self::SQLITE_DRIVER_NAME) {
            $query = sprintf('PRAGMA table_info("%s") ', $table);
        } else {
            $query = sprintf('SHOW COLUMNS FROM `%s`', $table);
        }

        $this->logger->debug($query);
        $sth = $dbh->query($query);

        $cols = $sth->fetchAll((PDO::FETCH_GROUP | PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC));
        if ($driver === self::SQLITE_DRIVER_NAME) {
            $struct = [];
            foreach ($cols as $col) {
                // Normalize SQLite's result (PRAGMA) with mysql's (SHOW COLUMNS)
                $struct[$col['name']] = [
                    'Type'      => $col['type'],
                    'Null'      => !!$col['notnull'] ? 'NO' : 'YES',
                    'Default'   => $col['dflt_value'],
                    'Key'       => !!$col['pk'] ? 'PRI' : '',
                    'Extra'     => ''
                ];
            }
            return $struct;
        } else {
            return $cols;
        }
    }
public function tableStructure()
    {
        $dbh    = $this->db();
        $table  = $this->table();
        $driver = $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
        if ($driver === self::SQLITE_DRIVER_NAME) {
            $query = sprintf('PRAGMA table_info("%s") ', $table);
        } else {
            $query = sprintf('SHOW COLUMNS FROM `%s`', $table);
        }

        $this->logger->debug($query);
        $sth = $dbh->query($query);

        $cols = $sth->fetchAll((PDO::FETCH_GROUP | PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC));
        if ($driver === self::SQLITE_DRIVER_NAME) {
            $struct = [];
            foreach ($cols as $col) {
                // Normalize SQLite's result (PRAGMA) with mysql's (SHOW COLUMNS)
                $struct[$col['name']] = [
                    'Type'      => $col['type'],
                    'Null'      => !!$col['notnull'] ? 'NO' : 'YES',
                    'Default'   => $col['dflt_value'],
                    'Key'       => !!$col['pk'] ? 'PRI' : '',
                    'Extra'     => ''
                ];
            }
            return $struct;
        } else {
            return $cols;
        }
    }
public function tableStructure ( ) { $ dbh = $ this -> db ( ) ; $ table = $ this -> table ( ) ; $ driver = $ dbh -> getAttribute ( PDO :: ATTR_DRIVER_NAME ) ; if ( $ driver === self :: SQLITE_DRIVER_NAME ) { $ query = sprintf ( 'PRAGMA table_info("%s") ' , $ table ) ; } else { $ query = sprintf ( 'SHOW COLUMNS FROM `%s`' , $ table ) ; } $ this -> logger -> debug ( $ query ) ; $ sth = $ dbh -> query ( $ query ) ; $ cols = $ sth -> fetchAll ( ( PDO :: FETCH_GROUP | PDO :: FETCH_UNIQUE | PDO :: FETCH_ASSOC ) ) ; if ( $ driver === self :: SQLITE_DRIVER_NAME ) { $ struct = [ ] ; foreach ( $ cols as $ col ) { // Normalize SQLite's result (PRAGMA) with mysql's (SHOW COLUMNS) $ struct [ $ col [ 'name' ] ] = [ 'Type' => $ col [ 'type' ] , 'Null' => ! ! $ col [ 'notnull' ] ? 'NO' : 'YES' , 'Default' => $ col [ 'dflt_value' ] , 'Key' => ! ! $ col [ 'pk' ] ? 'PRI' : '' , 'Extra' => '' ] ; } return $ struct ; } else { return $ cols ; } }
Get the table columns information.

@return array An associative array.
Get the table columns information .