src/Db/MySqlDb.php
protected function getColumns($tablename = '') {
        $ltablename = strtolower($tablename);
        /* @var \PDOStatement $stmt */
        $stmt = $this->get(
            'information_schema.COLUMNS',
            [
                'TABLE_SCHEMA' => $this->getDbName(),
                'TABLE_NAME' => $tablename ? $this->px.$tablename : [Db::OP_LIKE => addcslashes($this->px, '_%').'%']
            ],
            [
                'columns' => [
                    'TABLE_NAME',
                    'COLUMN_TYPE',
                    'IS_NULLABLE',
                    'EXTRA',
                    'COLUMN_KEY',
                    'COLUMN_DEFAULT',
                    'COLUMN_NAME'
                ],
                Db::OPTION_MODE => Db::MODE_PDO,
                'escapeTable' => false,
                'order' => ['TABLE_NAME', 'ORDINAL_POSITION']
            ]
        );

        $stmt->execute();
        $tablecolumns = $stmt->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);

        foreach ($tablecolumns as $ctablename => $cdefs) {
            $ctablename = strtolower(ltrim_substr($ctablename, $this->px));
            $columns = [];

            foreach ($cdefs as $cdef) {
                $column = [
                    'type' => $this->columnTypeString($cdef['COLUMN_TYPE']),
                    'required' => !force_bool($cdef['IS_NULLABLE']),
                ];
                if ($cdef['EXTRA'] === 'auto_increment') {
                    $column['autoincrement'] = true;
                }
                if ($cdef['COLUMN_KEY'] === 'PRI') {
                    $column['primary'] = true;
                }

                if ($cdef['COLUMN_DEFAULT'] !== null) {
                    $column['default'] = $this->forceType($cdef['COLUMN_DEFAULT'], $column['type']);
                }

                $columns[$cdef['COLUMN_NAME']] = $column;
            }
            $this->tables[$ctablename]['columns'] = $columns;
        }
        if ($ltablename && isset($this->tables[$ltablename]['columns'])) {
            return $this->tables[$ltablename]['columns'];
        }
        return null;
    }
protected function getColumns($tablename = '') {
        $ltablename = strtolower($tablename);
        /* @var \PDOStatement $stmt */
        $stmt = $this->get(
            'information_schema.COLUMNS',
            [
                'TABLE_SCHEMA' => $this->getDbName(),
                'TABLE_NAME' => $tablename ? $this->px.$tablename : [Db::OP_LIKE => addcslashes($this->px, '_%').'%']
            ],
            [
                'columns' => [
                    'TABLE_NAME',
                    'COLUMN_TYPE',
                    'IS_NULLABLE',
                    'EXTRA',
                    'COLUMN_KEY',
                    'COLUMN_DEFAULT',
                    'COLUMN_NAME'
                ],
                Db::OPTION_MODE => Db::MODE_PDO,
                'escapeTable' => false,
                'order' => ['TABLE_NAME', 'ORDINAL_POSITION']
            ]
        );

        $stmt->execute();
        $tablecolumns = $stmt->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);

        foreach ($tablecolumns as $ctablename => $cdefs) {
            $ctablename = strtolower(ltrim_substr($ctablename, $this->px));
            $columns = [];

            foreach ($cdefs as $cdef) {
                $column = [
                    'type' => $this->columnTypeString($cdef['COLUMN_TYPE']),
                    'required' => !force_bool($cdef['IS_NULLABLE']),
                ];
                if ($cdef['EXTRA'] === 'auto_increment') {
                    $column['autoincrement'] = true;
                }
                if ($cdef['COLUMN_KEY'] === 'PRI') {
                    $column['primary'] = true;
                }

                if ($cdef['COLUMN_DEFAULT'] !== null) {
                    $column['default'] = $this->forceType($cdef['COLUMN_DEFAULT'], $column['type']);
                }

                $columns[$cdef['COLUMN_NAME']] = $column;
            }
            $this->tables[$ctablename]['columns'] = $columns;
        }
        if ($ltablename && isset($this->tables[$ltablename]['columns'])) {
            return $this->tables[$ltablename]['columns'];
        }
        return null;
    }
Get the columns for tables and put them in {MySqlDb::$tables}.

@param string $tablename The table to get the columns for or blank for all columns.
@return array|null Returns an array of columns if {@link $tablename} is specified, or null otherwise.