Inspect given table and creates a map containing the mapped processing type and the original doctrine type
The map is indexed by column names which become the property names

@param string $table
@param Connection $connection
@return array
324709
private function loadPropertiesForTable($table, Connection $connection)
    {
        $columns = $connection->getSchemaManager()->listTableColumns($table);

        $props = [];

        foreach ($columns as $name => $column)
        {
            $processingType = $this->doctrineColumnToProcessingType($column);

            $props[$name] = [
                'processing_type' => $processingType,
                'doctrine_type' => $column->getType()->getName(),
            ];
        }

        return $props;
    }
334912
public static function castIdentifier(ClassMetadata $targetEntity, Connection $connection)
    {
        if (!isset(self::$cacheCastIdentifiers[$targetEntity->getName()])) {
            $cast = '';

            if ($connection->getDriver() instanceof PgSqlDriver) {
                $type = self::getIdentifierType($targetEntity);
                $cast = '::'.$type->getSQLDeclaration(
                    $targetEntity->getIdentifierFieldNames(),
                    $connection->getDatabasePlatform()
                );
            }

            self::$cacheCastIdentifiers[$targetEntity->getName()] = $cast;
        }

        return self::$cacheCastIdentifiers[$targetEntity->getName()];
    }
369559
public function getAll(Connection $connection): array
    {
        foreach ($this->registry as $types) {
            foreach (array_keys($types) as $type) {
                $this->get($connection, $type);
            }
        }

        return $this->instances[$connection->driver()];
    }
81716
protected function getPrefix(Connection $connection)
    {
        $params = $connection->getParams();

        return isset($params['prefix']) ? $params['prefix'] : null;
    }
744805
public function get(Connection $connection, string $type): ConstraintInterface
    {
        $driver = $connection->driver();

        if (isset($this->instances[$driver][$type])) {
            return $this->instances[$driver][$type];
        }

        return $this->instances[$driver][$type] = $this->createInstance($connection, $type);
    }
175726
public function getTableSchema($table, $database = 'base')
    {
        $cacher = $this->config->getSchemaCacher();
        if ($cacher->has($table)) return $cacher->get($table);

        $driver = $this->getDatabase($database)->getDriver();
        $connection = $this->establishConnection($database, Database::TARGET_SLAVE);
        $describe = $driver->getTableDescribe($connection, $table);

        $schema = new TableSchema($table, $describe);
        $cacher->cache($table, $schema);
        return $schema;
    }
816822
private function process(MapperInterface $mapper, Connection $connection, Node $cursor, $field = null, $type = null)
    {
        while ($result = $connection->executeFragment($cursor)) {
            if (pg_num_rows($result) === 0) {
                break;
            }

            while ($value = pg_fetch_assoc($result)) {
                $value = json_decode($value['json'], true);

                if ($field !== null) {
                    $value = $value[$field];
                }

                if ($type !== null) {
                    $value = $mapper->fromPg($value, $type);
                }

                yield $value;
            }

            pg_free_result($result);
        }

        pg_free_result($result);
    }
964596
static public function getSchemaBuilder($connection)
    {

        if (get_class($connection) === 'Illuminate\Database\MySqlConnection') {
            /** @var \Illuminate\Database\MySqlConnection $connection */
            $MySqlGrammar = $connection->withTablePrefix(new MySqlGrammar);
            $connection->setSchemaGrammar($MySqlGrammar);
            return new MySqlBuilder($connection);
        }

        return $connection->getSchemaBuilder();
    }
364922
public function parse(Connection $db)
    {
        $filter = null;
        if ($this->ignoreExistingTables) {
            $filter = function ($tableName) use ($db) {
                return $db->tableExists($tableName) ? false : true;
            };
        }

        return \DoctrineXml\Parser::fromDocument(
            $this->rawXML->asXML(),
            $db->getDatabasePlatform(),
            true,
            false,
            $filter,
            $this->getDatabaseVersion($db),
            $db->getSchemaManager()->createSchemaConfig()
        );
    }
312041
protected function createClientsScopesTable(Connection $connection, DatabaseSchemaInterface $schema): void
    {
        $manager = $connection->getSchemaManager();

        $table = new Table($schema->getClientsScopesTable());
        $table->addColumn($schema->getClientsScopesIdentityColumn(), Type::INTEGER)
            ->setNotnull(true)->setAutoincrement(true)->setUnsigned(true);
        $table->addColumn($schema->getClientsScopesClientIdentityColumn(), Type::STRING)->setNotnull(true);
        $table->addColumn($schema->getClientsScopesScopeIdentityColumn(), Type::STRING)->setNotnull(true);
        $table->setPrimaryKey([$schema->getClientsScopesIdentityColumn()]);
        $table->addUniqueIndex([
            $schema->getClientsScopesClientIdentityColumn(),
            $schema->getClientsScopesScopeIdentityColumn()
        ]);

        $table->addForeignKeyConstraint(
            $schema->getClientsTable(),
            [$schema->getClientsScopesClientIdentityColumn()],
            [$schema->getClientsIdentityColumn()],
            $this->getOnDeleteCascadeConstraint()
        );

        $table->addForeignKeyConstraint(
            $schema->getScopesTable(),
            [$schema->getClientsScopesScopeIdentityColumn()],
            [$schema->getScopesIdentityColumn()],
            $this->getOnDeleteCascadeConstraint()
        );

        $manager->dropAndCreateTable($table);
    }
1155205
public function build(Connection $connection, Grammar $grammar)
    {
        $statement = [
            'index' => $this->index,
            'type'  => $this->type,
            'body'  => [
                $this->type => [
                    '_source'    => [
                        'enabled' => true,
                    ],
                    'properties' => $this->toDSL($grammar),
                ],
            ],
        ];

        return $connection->mapStatement($statement);
    }
1259037
public function getForeignTableNames($tableName = null, $connectionName = null)
    {
        $foreignKeys = $this->getTableForeignKeys($tableName, $connectionName);
        $tableNames  = [];

        foreach ($foreignKeys as $foreignKey) {
            $tableNames[] = $foreignKey->getForeignTableName();
        }

        return array_unique($tableNames);
    }
669308
public static function getQueryBuilder(Connection $connection)
    {
        switch ($connection->getDriver()->getName()) {
            case 'pdo_mysql':
                $adapter = new Database\Mysql\Adapter($connection);
                break;

            case 'pdo_sqlite':
                $adapter = new Database\Sqlite\Adapter($connection);
                break;

            case 'pdo_pgsql':
                $adapter = new Database\Pgsql\Adapter($connection);
                break;

            default:
                throw new NotSupportedException('Unknown driver');
        }

        $lookupBuilder = new LookupBuilder();
        $lookupBuilder->addLookupCollection($adapter->getLookupCollection());

        return new QueryBuilder($connection, $adapter, $lookupBuilder);
    }
937168
public static function describeTable($table, $connection = null)
	{
		if (is_null($connection)) {
			$connection = DB::connection();
		}

		if ($connection->getDriverName() === 'sqlite') {
			$result = $connection->select(sprintf('PRAGMA table_info(%s)', $table));
			$column_key = 'name';
		} else {
			$result = $connection->select(
				sprintf(
					'SELECT COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \'%s\' and TABLE_SCHEMA = \'%s\'', $table, $connection->getDatabaseName()
				)
			);
			$column_key = 'COLUMN_NAME';
		}

		return array_map(
			function ($item) use ($column_key) {
				return $item->$column_key;
			}, $result
		);
	}
299922
final public function run(Connection $connection)
    {
        $start = microtime(true);

        foreach (QueryBuilder::getBeforeRun() as $callback) {

            // function(\UniMapper\Query $query)
            $callback($this);
        }

        $result = $this->onExecute($connection);
        foreach (QueryBuilder::getAfterRun() as $callback) {

            // function(\UniMapper\Query $query, mixed $result, int $elapsed)
            $callback($this, $result, microtime(true) - $start);
        }

        return $result;
    }
920651
public static function createInsert(Connection $connection, $table, $values){
		if(!($values instanceof Traversable || (is_array($values) && !empty($values))))
			throw new InvalidArgumentException('Argument 3 must be a non-empty array or Traversable.');

		$obj = new self($connection);
		$obj->type = Manager::STMT_INSERT;
		$obj->source = $table;
		$obj->values = $values instanceof Traversable ? iterator_to_array($values) : $values;
		return $obj;
	}
337425
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
    {
        $schema = $connection->getDoctrineSchemaManager();

        $table = $this->getTablePrefix().$blueprint->getTable();

        $column = $connection->getDoctrineColumn($table, $command->from);

        $tableDiff = $this->getRenamedDiff($blueprint, $command, $column, $schema);

        return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff);
    }