*

Devuelve los valores al ejecutar "SCHEMA CREATE"

@param string $tablename Nombre de la tabla
@return array listado de valores a insertar en la tabla para hacer el saveAll
965108
public function __getDefaultValues ( $tableName ) {
		$values = $this->__defaultValues;

		if ( $values && $tableName && array_key_exists( $tableName, $values )) {
			return $values[$tableName];
		} else {
			return false;
		}
	}
1289989
protected function _getConstraints($tableName)
    {

        $params = [
            ':schemaName' => $this->_adapter->getSchemaName(),
            ':tableName' => $tableName
        ];

        return $this->_adapter->query($this->_getConstraintsSql, $params);
    }
618677
public static function getModelTable($tableName) {
        $mt = DATA . 'mapper' . DIRECTORY_SEPARATOR . '__modelTables.php';
        if (!is_readable($mt))
            return array();

        $modelTables = include $mt;
        if (isset($modelTables[$tableName]))
            return $modelTables[$tableName];

        return array();
    }
321022
public function getColumns($tableName)
    {
        $sql = sprintf('SELECT * FROM information_schema.columns
                    WHERE table_schema=database()
                    AND table_name = %s', $this->quote($tableName));
        $rows = $this->pdo->query($sql)->fetchAll();

        $result = [];
        foreach ($rows as $row) {
            $name = $row['COLUMN_NAME'];
            $result[$name] = $row;
        }

        return $result;
    }
824295
public function table($tableName)
    {
        return new Table(
            $this->dbManager,
            $this->connectionName,
            $tableName,
            $this->getStructure($this->connectionName)
        );
    }
814145
public static function getTableColumns(string $schemaName, string $tableName): array
  {
    $sql = sprintf('
select COLUMN_NAME        as column_name
,      COLUMN_TYPE        as column_type
,      IS_NULLABLE        as is_nullable
,      CHARACTER_SET_NAME as character_set_name
,      COLLATION_NAME     as collation_name
,      EXTRA              as extra
from   information_schema.COLUMNS
where  TABLE_SCHEMA = %s
and    TABLE_NAME   = %s
order by ORDINAL_POSITION',
                   self::$dl->quoteString($schemaName),
                   self::$dl->quoteString($tableName));

    return self::$dl->executeRows($sql);
  }
479210
protected function _getConstraints($tableName)
    {
        $structure = [
            'constraintType' => null,
            'constraintName' => null,
            'columnName' => null,
            'referenceTable' => null,
            'referenceColumn' => null,
            'onUpdate' => null,
            'onDelete' => null
        ];
        $data = [];

        $columns = $this->_adapter->query("PRAGMA table_info({$tableName})");
        foreach ($columns as $col) {
            if ($col['pk'] == 1) {
                $data[] = array_merge(
                    $structure,
                    [
                        'constraintType' => 'PRIMARY KEY',
                        'constraintName' => $tableName.'Primary',
                        'columnName' => $col['name']
                    ]
                );
            }
        }

        $sql = "PRAGMA index_list({$tableName})";
        $indexes = $this->_adapter->query($sql);
        foreach ($indexes as $index) {
            if ($index['unique'] == 1) {
                $info = $this->_adapter->query(
                    "PRAGMA index_info({$index['name']})"
                );
                $data[] = array_merge(
                    $structure,
                    [
                        'constraintType' => 'UNIQUE',
                        'constraintName' => $index['name'],
                        'columnName' => $info[0]['name']
                    ]
                );
            }
        }

        $foreignKeys = $this->_adapter
            ->query("PRAGMA foreign_key_list({$tableName})");
        foreach ($foreignKeys as $frk) {
            $data[] = $this->_createFkData($frk, $tableName);
        }
        return new RecordList(['data' => $data]);
    }
1221715
public function schemaTemplate($schemaName)
    {
        return [
            'exists' => (new Query())
                ->select('nspname')
                ->from('pg_namespace')
                ->where('nspname = :value', [':value' => $schemaName])
                ->exists($this->db),
            'up' => "CREATE SCHEMA $schemaName",
            'down' => "DROP SCHEMA $schemaName",
        ];
    }
42268
public function createAlias(string $tableName): string
    {
        $alias                          = $tableName . (++$this->aliasIdCounter);
        $this->knownAliases[$tableName] = $alias;

        return $alias;
    }
301840
public function getTableColumnList($tableName) {

        if (!array_key_exists($tableName, $this->tableList)) {

            $this->addColumnMap($tableName, $this->getColumnMappingsFromConfig($tableName));
        }

        return $this->tableList[$tableName];
    }
462385
public function buildRecords($tableName, array $records)
    {
        $insertedRecords = array();
        $this->tables[$tableName] = $tableName;

        foreach ($records as $recordName => $recordValues) {
            array_walk($recordValues, function (&$value) use ($recordValues) {
                if (is_callable($value)) {
                    $value = call_user_func($value, $recordValues);
                }
            });

            $recordValues = $this->setForeignKeys($recordValues);

            list($table, $label) = $this->parseRecordLabel(
                $recordName[0] === "."
                ? $tableName . $recordName[0]
                : $recordName
            );

            if (!is_int($recordName)) {
                $recordValues['id'] = $this->generateKey($label, $table);
            }

            $cols = array();
            foreach (array_keys($recordValues) as $col) {
                $cols[] = $this->quoteIdentifier($col);
            }
            $fields = implode(', ', $cols);
            $values = array_values($recordValues);
            $placeholders = rtrim(str_repeat('?, ', count($recordValues)), ', ');
            $sql = "INSERT INTO " . $this->quoteIdentifier($tableName)
                . " ($fields) VALUES ($placeholders)";

            $sth = $this->db->prepare($sql);
            $sth->execute($values);

            $insertedRecords[$label] = (object) $recordValues;
        }

        return $insertedRecords;
    }
1149762
public function tableInfo($tableName, $schema = null)
    {
        return $this->_associateTableMeta($this->fetchAll('SELECT `column_name` as `name`, `data_type` AS `dataType`, `character_maximum_length` AS `maxLength`, `is_nullable` AS `null`, `column_default` AS `default`, `extra` AS `extra`, `column_key` AS `column_key` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `table_name` = :name AND `table_schema` = :schema ORDER BY `ordinal_position`', [
                    ':name' => $tableName,
                    ':schema' => $this->_config->name
        ]));
    }
348082
protected function _tableSplit($tableName, $config)
    {
        $schema = null;
        $table = strtoupper($tableName);
        if (strpos($tableName, '.') !== false) {
            $tableSplit = explode('.', $tableName);
            $table = strtoupper($tableSplit[1]);
            $schema = strtoupper($tableSplit[0]);
        } elseif (!empty($config['schema'])) {
            $schema = strtoupper($config['schema']);
        }
        return [$table, $schema];
    }
854123
public function getTableRows(string $tableName)
    {
        $statement = $this->connection->prepare("SELECT * FROM information_schema.columns WHERE table_catalog = :database AND table_name = :table");
        $statement->execute([
            ':database' => $this->Databaser->database,
            ':table'    => $tableName
        ]);

        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
260483
public function getTableForeignKeys($tableName = null, $connectionName = null)
    {
        $tableName = $this->validateTableName($tableName);

        return $this->getSchema($connectionName)->listTableForeignKeys($tableName);
    }
294862
public function getFields($tableName)
    {
        list($tableName) = explode(' ', $tableName);

        if (false === strpos($tableName, '`')) {
            if (strpos($tableName, '.')) {
                $tableName = str_replace('.', '`.`', $tableName);
            }
            $tableName = '`' . $tableName . '`';
        }

        $sql    = 'SHOW COLUMNS FROM ' . $tableName;
        $pdo    = $this->query($sql, [], false, true);
        $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
        $info   = [];

        if ($result) {
            foreach ($result as $key => $val) {
                $val                 = array_change_key_case($val);
                $info[$val['field']] = [
                    'name'    => $val['field'],
                    'type'    => $val['type'],
                    'notnull' => (bool) ('' === $val['null']), // not null is empty, null is yes
                    'default' => $val['default'],
                    'primary' => (strtolower($val['key']) == 'pri'),
                    'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
                ];
            }
        }

        return $this->fieldCase($info);
    }
1094821
protected function getColumns($tableName): array
    {
        $sql = sprintf('SELECT * FROM information_schema.columns
                    WHERE table_schema=database()
                    AND table_name = %s', $this->quote($tableName));

        $rows = $this->queryFetchAll($sql);

        $result = [];
        foreach ($rows as $row) {
            $name = $row['COLUMN_NAME'];
            $result[$name] = $row;
        }

        return $result;
    }