Zwraca informację o kolumnach tabeli
@param string $tableName nazwa tabeli
@param array $schema nie istotny w MySQL
@return array
960845
public function tableInfo($tableName, $schema = null)
    {
        //schema nie jest używane w sqlite
        return $this->_associateTableMeta($this->fetchAll('PRAGMA table_info(' . $this->prepareTable($tableName) . ')'));
    }
1029578
public function getPrimary($table, $schema = null)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string')->test(2, 'string', 'null');
        
        $select = array('columns.column_name');
        
        $where = array(
            "pg_attribute.attrelid = pg_class1.oid AND pg_class1.relname='".$table."'",
            'columns.column_name = pg_attribute.attname AND columns.table_name=pg_class1.relname',
            'pg_class1.oid = pg_index.indrelid AND pg_attribute.attnum = ANY(pg_index.indkey)',
            'pg_class2.oid = pg_index.indexrelid');
        
        if ($schema) {
            $where[1] .= ' AND columns.table_schema="'.$schema.'"';
        }
        
        $query = Select::i()
            ->select($select)
            ->from('pg_attribute')
            ->innerJoin('pg_class AS pg_class1', $where[0], false)
            ->innerJoin('information_schema.COLUMNS	AS columns', $where[1], false)
            ->innerJoin('pg_index', $where[2], false)
            ->innerJoin('pg_class AS pg_class2', $where[3], false)
            ->where('pg_class2.relname LIKE \'%_pkey\'')
            ->getQuery();
        
        return $this->query($query);
    }
37418
public function getColumns(string $tableName): array
    {
        $sql = 'SELECT
            column_name,
            column_default,
            is_nullable,
            data_type,
            character_maximum_length,
            character_octet_length,
            numeric_precision,
            numeric_scale,
            character_set_name,
            collation_name,
            column_type,
            column_key,
            extra,
            `privileges`,
            column_comment
            FROM information_schema.columns
            WHERE table_schema = %s
            AND table_name = %s;';

        [$dbName, $tableName] = $this->parseTableName($tableName);
        $sql = sprintf($sql, $dbName, $tableName);

        $result = $this->db->query($sql)->fetchAll(PDO::FETCH_ASSOC);

        return $result ?: [];
    }
1168211
function generateTableSchema( $tableName, $table, $params )
    {
        return $this->generateTableSQL( $tableName, $table, $params, false, false );
    }
692950
public function getTableGeomType($tableName, $schema = null)
    {
        $connection = $this->connection;
        if (strpos($tableName, '.')) {
            list($schema, $tableName) = explode('.', $tableName);
        }
        $_schema = $schema ? $connection->quote($schema) : 'current_schema()';
        $type = $connection->query("SELECT \"type\"
                FROM geometry_columns
                WHERE f_table_schema = " . $_schema . "
                AND f_table_name = " . $connection->quote($tableName))->fetchColumn();
        return $type;
    }
520183
public function getTables($schema = null)
    {
        if ($schema) {
            $sql = 'SHOW FULL TABLES FROM `' . $this->_escapeIdentifier($schema) . '` WHERE Table_Type != "VIEW"';
        } else {
            $sql = 'SHOW FULL TABLES WHERE Table_Type != "VIEW"';
        }

        $tables = [];
        foreach ($this->query($sql, [], \PDO::FETCH_NUM) as $row) {
            $tables[] = $row[0];
        }

        return $tables;
    }
280562
protected static function _updateQuery($tableName)
    {
        //prefixy nazw
        $namePrefix = self::_getNamePrefix($tableName);
        //nazwa klasy
        $className = $namePrefix . 'Query';
        //nazwa klasy pola
        $fieldClassName = $namePrefix . 'QueryField';
        //nazwa klasy złączenia
        $joinClassName = $namePrefix . 'QueryJoin';
        //nazwa rekordu
        $recordClassName = $namePrefix . 'Record';
        //ścieżka
        $path = self::_mkdirRecursive(self::_getPathPrefix($tableName)) . '/' . $className . '.php';
        //kod zapytania
        $queryCode = "{\n\n" . self::INDENT .
            'protected $_tableName = \'' .
            $tableName . '\';' .
            "\n\n}";
        //wczytanie istniejącego rekordu
        if (file_exists($path)) {
            $queryCode = file_get_contents($path);
        }
        //odczyt struktury
        $structure = DbConnector::getTableStructure($tableName);
        //pusta, lub błędna struktura
        if (empty($structure)) {
            throw new OrmException('\Mmi\Orm\Builder: no table found, or table invalid: ' . $tableName);
        }

        $methods = '';
        //budowanie komentarzy do metod
        foreach ($structure as $fieldName => $fieldDetails) {
            $fieldName = ucfirst(Convert::underscoreToCamelcase($fieldName));
            //metody where... np. whereActive()
            $methods .= ' * @method QueryHelper\\' . $fieldClassName . ' where' . $fieldName . '()' . "\n";
            //metody andField... np. andFieldActive()
            $methods .= ' * @method QueryHelper\\' . $fieldClassName . ' andField' . $fieldName . '()' . "\n";
            //orField
            $methods .= ' * @method QueryHelper\\' . $fieldClassName . ' orField' . $fieldName . '()' . "\n";
            //orderAsc
            $methods .= ' * @method ' . $className . ' orderAsc' . $fieldName . '()' . "\n";
            //orderDesc
            $methods .= ' * @method ' . $className . ' orderDesc' . $fieldName . '()' . "\n";
            //groupBy
            $methods .= ' * @method ' . $className . ' groupBy' . $fieldName . '()' . "\n";
        }
        $queryHead = '<?php' . "\n\n" .
            'namespace ' . self::_getNamespace($tableName) . ";\n\n" .
            '//<editor-fold defaultstate="collapsed" desc="' . $className . '">' . "\n" .
            '/**' . "\n" .
            ' * @method ' . $className . ' limit($limit = null)' . "\n" .
            ' * @method ' . $className . ' offset($offset = null)' . "\n" .
            ' * @method ' . $className . ' orderAsc($fieldName, $tableName = null)' . "\n" .
            ' * @method ' . $className . ' orderDesc($fieldName, $tableName = null)' . "\n" .
            ' * @method ' . $className . ' andQuery(\Mmi\Orm\Query $query)' . "\n" .
            ' * @method ' . $className . ' whereQuery(\Mmi\Orm\Query $query)' . "\n" .
            ' * @method ' . $className . ' orQuery(\Mmi\Orm\Query $query)' . "\n" .
            ' * @method ' . $className . ' resetOrder()' . "\n" .
            ' * @method ' . $className . ' resetWhere()' . "\n" .
            $methods .
            ' * @method QueryHelper\\' . $fieldClassName . ' andField($fieldName, $tableName = null)' . "\n" .
            ' * @method QueryHelper\\' . $fieldClassName . ' where($fieldName, $tableName = null)' . "\n" .
            ' * @method QueryHelper\\' . $fieldClassName . ' orField($fieldName, $tableName = null)' . "\n" .
            ' * @method QueryHelper\\' . $joinClassName . ' join($tableName, $targetTableName = null, $alias = null)' . "\n" .
            ' * @method QueryHelper\\' . $joinClassName . ' joinLeft($tableName, $targetTableName = null, $alias = null)' . "\n" .
            ' * @method ' . $recordClassName . '[] find()' . "\n" .
            ' * @method ' . $recordClassName . ' findFirst()' . "\n" .
            ' * @method ' . $recordClassName . ' findPk($value)' . "\n" .
            ' */' . "\n" . '//</editor-fold>' . "\n" . 'class ' . $className . ' extends \Mmi\Orm\Query';
        $queryCode = $queryHead . "\n" . substr($queryCode, strpos($queryCode, '{'));
        file_put_contents($path, $queryCode);
    }
453025
private function createTable(Schema $schema)
    {
        $table = $schema->createTable(RdsDeliveryExecutionService::TABLE_NAME);

        $table->addOption("engine", "InnoDB");
        $table->addOption("charset", "utf8");
        $table->addOption("collate", "utf8_unicode_ci");

        $this->createColumns($table);

        /**
         * Create index for the following methods
         * @see RdsDeliveryExecutionService::getExecutionsByDelivery()
         * @see RdsDeliveryExecutionService::getUserExecutions()
         */
        $this->createIndex($table, [
            RdsDeliveryExecutionService::COLUMN_DELIVERY_ID,
            RdsDeliveryExecutionService::COLUMN_USER_ID,
        ]);

        /**
         * Create index for the following methods
         * @see RdsDeliveryExecutionService::getDeliveryExecutionsByStatus()
         */
        $this->createIndex($table, [
            RdsDeliveryExecutionService::COLUMN_USER_ID,
        ]);
    }
379982
protected function _generateMetaColumnsSQL($table, $schema)
	{
		if ($schema) {
			return sprintf($this->metaColumnsSQL1, $table, $table, $table, $schema);
		}
		else {
			return sprintf($this->metaColumnsSQL, $table, $table, $schema);
		}
	}
1347209
public static function buildFromTableName($tableName)
    {
        //pomijanie modułów z vendorów
        foreach (\Mmi\Mvc\StructureParser::getModules() as $module) {
            if (strtolower(basename($module)) == explode('_', $tableName)[0] && false !== strpos($module, 'vendor')) {
                return;
            }
        }
        //aktualizacja QUERY-FIELD
        self::_updateQueryField($tableName);
        //aktualizacja QUERY-JOIN
        self::_updateQueryJoin($tableName);
        //aktualizacja QUERY
        self::_updateQuery($tableName);
        //aktualizacja RECORD
        self::_updateRecord($tableName);
    }
1071812
protected function getColumnUpdate(array $schema, string $table, string $columnName): string
    {
        $columns = $schema['tables'][$table]['columns'];
        $columnData = $columns[$columnName];

        $phinxType = $this->getPhinxColumnType($columnData);
        $columnAttributes = $this->getPhinxColumnOptions($phinxType, $columnData, $columns);
        $result = sprintf("%s->changeColumn('%s', '%s', $columnAttributes)", $this->ind2, $columnName, $phinxType, $columnAttributes);

        return $result;
    }
462049
public function getTableColumns($tableName = null, $connectionName = null)
    {
        $tableName = $this->validateTableName($tableName);

        return $this->getSchema($connectionName)->listTableColumns($tableName);
    }
397795
public function getFields($tableName) {
        list($tableName) = explode(' ', $tableName);
        $result =   $this->query("SELECT   column_name,   data_type,   column_default,   is_nullable
        FROM    information_schema.tables AS t
        JOIN    information_schema.columns AS c
        ON  t.table_catalog = c.table_catalog
        AND t.table_schema  = c.table_schema
        AND t.table_name    = c.table_name
        WHERE   t.table_name = '$tableName'");
        $info   =   array();
        if($result) {
            foreach ($result as $key => $val) {
                $info[$val['column_name']] = array(
                    'name'    => $val['column_name'],
                    'type'    => $val['data_type'],
                    'notnull' => (bool) ($val['is_nullable'] === ''), // not null is empty, null is yes
                    'default' => $val['column_default'],
                    'primary' => false,
                    'autoinc' => false,
                );
            }
        }
        return $info;
    }
1355091
protected function fetchTables($schema)
    {
        $rows = $this->arraify($this->connection->select('SHOW FULL TABLES FROM '.$this->wrap($schema).' WHERE Table_type="BASE TABLE"'));
        $names = array_column($rows, 'Tables_in_'.$schema);

        return Arr::flatten($names);
    }
203417
protected function getColumnCreate($schema, $table, $columnName)
    {
        $columns = $schema['tables'][$table]['columns'];
        $columnData = $columns[$columnName];
        $phinxType = $this->getPhinxColumnType($columnData);
        $columnAttributes = $this->getPhinxColumnOptions($phinxType, $columnData, $columns);

        return [$table, $columnName, $phinxType, $columnAttributes];
    }
656874
public function describeTable($tableName, $schemaName = null)
    {
        $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
                c.typename, c.default, c.nulls, c.length, c.scale,
                c.identity, tc.type AS tabconsttype, k.colseq
                FROM syscat.columns c
                LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
                 ON (k.tabschema = tc.tabschema
                   AND k.tabname = tc.tabname
                   AND tc.type = 'P'))
                 ON (c.tabschema = k.tabschema
                 AND c.tabname = k.tabname
                 AND c.colname = k.colname)
            WHERE "
            . $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
        if ($schemaName) {
            $sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
        }
        $sql .= " ORDER BY c.colno";

        $desc = array();
        $stmt = $this->_adapter->query($sql);

        /**
         * To avoid case issues, fetch using FETCH_NUM
         */
        $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);

        /**
         * The ordering of columns is defined by the query so we can map
         * to variables to improve readability
         */
        $tabschema      = 0;
        $tabname        = 1;
        $colname        = 2;
        $colno          = 3;
        $typename       = 4;
        $default        = 5;
        $nulls          = 6;
        $length         = 7;
        $scale          = 8;
        $identityCol    = 9;
        $tabconstype    = 10;
        $colseq         = 11;

        foreach ($result as $key => $row) {
            list ($primary, $primaryPosition, $identity) = array(false, null, false);
            if ($row[$tabconstype] == 'P') {
                $primary = true;
                $primaryPosition = $row[$colseq];
            }
            /**
             * In IBM DB2, an column can be IDENTITY
             * even if it is not part of the PRIMARY KEY.
             */
            if ($row[$identityCol] == 'Y') {
                $identity = true;
            }

            $desc[$this->_adapter->foldCase($row[$colname])] = array(
            'SCHEMA_NAME'      => $this->_adapter->foldCase($row[$tabschema]),
            'TABLE_NAME'       => $this->_adapter->foldCase($row[$tabname]),
            'COLUMN_NAME'      => $this->_adapter->foldCase($row[$colname]),
            'COLUMN_POSITION'  => $row[$colno]+1,
            'DATA_TYPE'        => $row[$typename],
            'DEFAULT'          => $row[$default],
            'NULLABLE'         => (bool) ($row[$nulls] == 'Y'),
            'LENGTH'           => $row[$length],
            'SCALE'            => $row[$scale],
            'PRECISION'        => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
            'UNSIGNED'         => false,
            'PRIMARY'          => $primary,
            'PRIMARY_POSITION' => $primaryPosition,
            'IDENTITY'         => $identity
            );
        }

        return $desc;
    }
325391
public function initialize($schema, $table=null)
    {
        $mapper = $this->_mapper($schema);
        $table = $table ? $this->_connection($schema)->table($table) : $mapper->table();

        $sequencePool = $this->_connection($schema)->sequencePool();
        $sequencePool->initialize();

        $columns = array();

        // build a map of properties to create
        foreach ($schema->properties() as $prop) {
            $columns[$prop->name] = $prop->type;

            // reset sequences as we go
            if (property_exists($prop->type, 'sequence')) {
                $sequencePool->delete($mapper->sequenceName($prop));
            }
        }

        $table->create($columns);

        return $this;
    }