src/DataStore/src/TableGateway/TableManagerMysql.php
public function getTableInfoStr($tableName)
    {
        $metadata = Factory::createSourceFromAdapter($this->db);
        $table = $metadata->getTable($tableName);
        $spaces = function ($count) {
            return str_repeat(' ', $count);
        };

        $result = "{$spaces(4)}With columns:" . PHP_EOL;

        /** @var ColumnObject $column */
        foreach ($table->getColumns() as $column) {
            $result .= "{$spaces(8)}{$column->getName()} -> {$column->getDataType()}" . PHP_EOL;
        }

        $result .= PHP_EOL;
        $result .= "{$spaces(4)}With constraints:" . PHP_EOL;

        /** @var ConstraintObject $constraint */
        foreach ($metadata->getConstraints($tableName) as $constraint) {
            $result .= "{$spaces(8)}{$constraint->getName()} -> {$constraint->getType()}" . PHP_EOL;

            if (!$constraint->hasColumns()) {
                continue;
            }

            $result .= "{$spaces(12)}column: " . implode(', ', $constraint->getColumns());

            if ($constraint->isForeignKey()) {
                $foreignKeyColumns = [];

                foreach ($constraint->getReferencedColumns() as $referenceColumn) {
                    $foreignKeyColumns[] = "{$constraint->getReferencedTableName()}.{$referenceColumn}";
                }

                $result .= ' => ' . implode(', ', $foreignKeyColumns) . PHP_EOL;
                $result .= "{$spaces(12)}OnDeleteRule: {$constraint->getDeleteRule()}" . PHP_EOL;
                $result .= "{$spaces(12)}OnUpdateRule: {$constraint->getUpdateRule()}" . PHP_EOL;
            } else {
                $result .= PHP_EOL;
            }
        }

        return $result;
    }
public function getTableInfoStr($tableName)
    {
        $metadata = Factory::createSourceFromAdapter($this->db);
        $table = $metadata->getTable($tableName);
        $spaces = function ($count) {
            return str_repeat(' ', $count);
        };

        $result = "{$spaces(4)}With columns:" . PHP_EOL;

        /** @var ColumnObject $column */
        foreach ($table->getColumns() as $column) {
            $result .= "{$spaces(8)}{$column->getName()} -> {$column->getDataType()}" . PHP_EOL;
        }

        $result .= PHP_EOL;
        $result .= "{$spaces(4)}With constraints:" . PHP_EOL;

        /** @var ConstraintObject $constraint */
        foreach ($metadata->getConstraints($tableName) as $constraint) {
            $result .= "{$spaces(8)}{$constraint->getName()} -> {$constraint->getType()}" . PHP_EOL;

            if (!$constraint->hasColumns()) {
                continue;
            }

            $result .= "{$spaces(12)}column: " . implode(', ', $constraint->getColumns());

            if ($constraint->isForeignKey()) {
                $foreignKeyColumns = [];

                foreach ($constraint->getReferencedColumns() as $referenceColumn) {
                    $foreignKeyColumns[] = "{$constraint->getReferencedTableName()}.{$referenceColumn}";
                }

                $result .= ' => ' . implode(', ', $foreignKeyColumns) . PHP_EOL;
                $result .= "{$spaces(12)}OnDeleteRule: {$constraint->getDeleteRule()}" . PHP_EOL;
                $result .= "{$spaces(12)}OnUpdateRule: {$constraint->getUpdateRule()}" . PHP_EOL;
            } else {
                $result .= PHP_EOL;
            }
        }

        return $result;
    }
public function getTableInfoStr ( $ tableName ) { $ metadata = Factory :: createSourceFromAdapter ( $ this -> db ) ; $ table = $ metadata -> getTable ( $ tableName ) ; $ spaces = function ( $ count ) { return str_repeat ( ' ' , $ count ) ; } ; $ result = "{$spaces(4)}With columns:" . PHP_EOL ; /** @var ColumnObject $column */ foreach ( $ table -> getColumns ( ) as $ column ) { $ result .= "{$spaces(8)}{$column->getName()} -> {$column->getDataType()}" . PHP_EOL ; } $ result .= PHP_EOL ; $ result .= "{$spaces(4)}With constraints:" . PHP_EOL ; /** @var ConstraintObject $constraint */ foreach ( $ metadata -> getConstraints ( $ tableName ) as $ constraint ) { $ result .= "{$spaces(8)}{$constraint->getName()} -> {$constraint->getType()}" . PHP_EOL ; if ( ! $ constraint -> hasColumns ( ) ) { continue ; } $ result .= "{$spaces(12)}column: " . implode ( ', ' , $ constraint -> getColumns ( ) ) ; if ( $ constraint -> isForeignKey ( ) ) { $ foreignKeyColumns = [ ] ; foreach ( $ constraint -> getReferencedColumns ( ) as $ referenceColumn ) { $ foreignKeyColumns [ ] = "{$constraint->getReferencedTableName()}.{$referenceColumn}" ; } $ result .= ' => ' . implode ( ', ' , $ foreignKeyColumns ) . PHP_EOL ; $ result .= "{$spaces(12)}OnDeleteRule: {$constraint->getDeleteRule()}" . PHP_EOL ; $ result .= "{$spaces(12)}OnUpdateRule: {$constraint->getUpdateRule()}" . PHP_EOL ; } else { $ result .= PHP_EOL ; } } return $ result ; }
Builds and gets table info

@see http://framework.zend.com/manual/current/en/modules/zend.db.metadata.html
@param string $tableName
@return string
Builds and gets table info