@throws Exception\ConnectionException
@throws \Soluble\Metadata\Exception\EmptyQueryException
@throws \Soluble\Metadata\Exception\InvalidQueryException

@return array<int, mixed>
179121
protected function readFields(string $sql): array
    {
        if (trim($sql) === '') {
            throw new Exception\EmptyQueryException('Cannot read fields for an empty query');
        }

        $sql = $this->getEmptiedQuery($sql);
        $stmt = $this->mysqli->prepare($sql);

        if ($stmt === false) {
            $message = $this->mysqli->error;
            throw new Exception\InvalidQueryException(
                sprintf('Invalid query: %s (%s)', $sql, $message)
            );
        }
        $stmt->execute();

        $result = $stmt->result_metadata();
        if ($result === false) {
            $message = $this->mysqli->error;
            throw new Exception\InvalidQueryException(
                sprintf('Cannot get metadata: %s (%s)', $sql, $message)
            );
        }

        $metaFields = $result->fetch_fields();

        if ($metaFields === false) {
            $result->close();
            $message = $this->mysqli->error;
            throw new Exception\InvalidQueryException(
                sprintf('Cannot fetch metadata fields: %s (%s)', $sql, $message)
            );
        }

        $result->close();
        $stmt->close();

        return $metaFields;
    }
408573
public function toArray()
    {
        $connections = array();

        /** @var $connection DbalConnection */
        foreach ($this as $key => $connection)
        {
            $connections[$key] = $connection->config();
        }

        return $connections;
    }
1186312
public function getArray()
    {
        $contents = include $this->context;

        if (gettype($contents) != 'array') {
            throw new InvalidFileException($this->context . ' does not return a valid array');
        }

        return $contents;
    }
1041075
public function getQueryAsArray()
        {
            $query = $this->getQuery();
            $querryArray = array();

            if ($query !== false) {
                parse_str($query, $querryArray);
            }

            return $querryArray;
        }
486440
public function fetch()
    {
        $this->throwIfContextInvalid();

        $this->reloadQueryAdapter();
        $results = $this->activeQuery->fetch();

        $this->resetCurrentQuery();

        if (!is_array($results) && get_class($results) === "WP_Error") {
            throw new Exception(json_encode($results));
        }

        return $this->wrapInEntities($results);
    }
977805
public function getQueryParams()
    {
        if (isset($this->_queryParams)) {
            return $this->_queryParams;
        }

        if ($queryString = $this->getQueryString()) {
            $result = [];
            parse_str($queryString, $result);
            return $this->_queryParams = $result;
        }

        return $this->_queryParams;
    }
975348
public function getConnection()
    {
        try {
            if ($this->instancia == null) {

                $json = new JsonReader(BASE_DIR . self::PATH_CONFIG_FILE);

                if (!empty(glob(dirname(__DIR__, 4) . self::PATH_CONFIG_FILE )[0])) {
                    $json = new JsonReader(glob(dirname(__DIR__, 4) . PATH_CONFIG_FILE)[0]);
                }

                $json= $json->read();
                try {

                    $connectionCache = $json->phiber->link->connection_cache == 1 ? true : false;

                    $this->instancia = new PDO(
                        $json->phiber->link->url,
                        $json->phiber->link->user,
                        $json->phiber->link->password,
                        array(
                            PDO::ATTR_PERSISTENT => $connectionCache
                        )
                    );
                } catch (PhiberException $e) {
                    throw new PhiberException(new Internationalization("database_connection_error"));
                }
            }

            return $this->instancia;

        } catch (PhiberException $e) {
            throw new PhiberException(new Internationalization("database_connection_error"));
        }
    }
75886
public function getType()
    {
        $sql = $this->getSql();

        $type = strtok(strtolower(trim($sql)), ' ');
        $type = preg_replace ('/[^a-z]/i', '', $type);

        $allowedTypes = [
            self::QUERY_TYPE_SELECT,
            self::QUERY_TYPE_INSERT,
            self::QUERY_TYPE_UPDATE,
            self::QUERY_TYPE_DELETE,
            self::QUERY_TYPE_TRUNCATE,
        ];

        if (!in_array($type, $allowedTypes)) {
            throw new RuntimeException('Invalid query type');
        }

        return $type;
    }
1369601
public function fetch()
    {
        $adapter = $this->getAdapter();
        if (!$adapter)
            throw new \Exception("Adapter property is not set");

        $adapter->check($this);
        $adapter->filter($this);
        $adapter->sort($this);
        $result = $adapter->paginate($this);

        $filters = $this->getFilters();
        return [
            'sort_column'   => $this->getSortColumn(),
            'sort_dir'      => $this->getSortDir(),
            'page_number'   => $this->getPageNumber(),
            'page_size'     => $this->getPageSize(),
            'total_pages'   => $this->getTotalPages(),
            'filters'       => count($filters) ? $filters : new \StdClass(),
            'rows'          => $result,
        ];
    }
1219745
private function fetchMigrations()
    {
        if ( ! isset($this->migrations)) {
            return null;
        }

        if (empty($this->migrations)) {
            return array();
        }

        $migrations = array();
        $connection = $this->entityManager->getConnection();
        $driver     = $connection->getDatabasePlatform()->getName();

        foreach ($this->migrations as $migration) {
            $files = glob($migration . '/*.sql');

            if (empty($files)) {
                $files = glob($migration . '/' . $driver . '/*.sql');

                if (empty($files)) {
                    continue;
                }
            }

            foreach ($files as $file) {
                $version = basename($file, '.sql');

                if (preg_match('~^[vV]([^_]+)_~', $version, $matches)) {
                    $version = $matches[1];
                }

                $migrations[$version] = $file;
            }
        }

        uksort($migrations, 'version_compare');

        return $migrations;
    }
443858
public function delete(): int
    {
        $rows = 0;

        try {
            $rows = $this->queryRelate->getQuery()->delete();
        } catch (\RuntimeException $exception) {
            throw new ResourceDeleteException($exception->getMessage(), $exception->getCode(), $exception);
        } finally {
            $this->resetQueryRelate();
        }

        return $rows;
    }
308931
public function get(): array
    {
        try {
            $query = $this->apply($this->database->getTablePrefixer());
            $compiled = $this->database->getGrammar()->compileSelect($query);
            return $this->database->select($compiled->getSQL(), $compiled->getBindings());
        } catch (\Throwable $exception) {
            return $this->handleException($exception);
        }
    }
1280686
public function getConn()
    {
        if (!$this->config('connection.className')) {
            $this->error(__d('installer', 'Database engine cannot be empty.'));

            return false;
        }

        try {
            ConnectionManager::drop('installation');
            ConnectionManager::config('installation', $this->config('connection'));
            $conn = ConnectionManager::get('installation');
            $conn->connect();

            return $conn;
        } catch (\Exception $ex) {
            $this->error(__d('installer', 'Unable to connect to database, please check your information. Details: {0}', '<p>' . $ex->getMessage() . '</p>'));

            return false;
        }
    }
600131
private function getData()
    {
        $data = fgets($this->socket);
        if ($data === false || $data === '') {
            throw new ConnectionException('Nothing received while reading from client');
        }
        return $data;
    }
855864
public function getConnection()
    {
        $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
        // Taking provided connection name if any.
        // Otherwise, just fallback to the default connection.

        if (isset($repositoryConfig['search']['connection'])) {
            $doctrineConnectionId = sprintf('doctrine.dbal.%s_connection', $repositoryConfig['search']['connection']);
        } else {
            // "database_connection" is an alias to the default connection, set up by DoctrineBundle.
            $doctrineConnectionId = 'database_connection';
        }

        if (!$this->container->has($doctrineConnectionId)) {
            throw new InvalidArgumentException(
                "Invalid Doctrine connection '{$repositoryConfig['search']['connection']}' for repository '{$repositoryConfig['alias']}'." .
                'Valid connections are ' . implode(', ', array_keys($this->container->getParameter('doctrine.connections')))
            );
        }

        return $this->container->get($doctrineConnectionId);
    }
1116245
public function getQueries()
    {
        return array_merge(
            $this->getRenameTableQueries(),
            $this->getDropCheckQueries(),
            $this->getDropForeignKeyQueries(),
            $this->getDropIndexQueries(),
            $this->getDropPrimaryKeyQueries(),
            $this->getDropColumnQueries(),
            $this->getAlterColumnQueries(),
            $this->getCreateColumnQueries(),
            $this->getCreatePrimaryKeyQueries(),
            $this->getCreateIndexQueries(),
            $this->getCreateForeignKeyQueries(),
            $this->getCreateCheckQueries()
        );
    }
188101
public function getArray()
    {
        $parsed = @parse_ini_file($this->context, true);

        if (! $parsed) {
            throw new InvalidFileException('Unable to parse invalid INI file at ' . $this->context);
        }

        return $parsed;
    }