private function getLeastBusyConnectionOld() : pgConnection
    {
        if (count($this->connections) === 0) {
            // try to spin up another connection to return
            $conn = $this->createNewConnection();
            if ($conn === null) {
                throw new Exception('There are no connections. Cannot find least busy one and could not create a new one.');
            }

            return $conn;
        }

        $min = reset($this->connections);

        foreach ($this->connections as $connection) {
            // if this connection is idle - just return it
            if ($connection->getBacklogLength() === 0 && $connection->getState() === pgConnection::STATE_READY) {
                return $connection;
            }

            if ($min->getBacklogLength() > $connection->getBacklogLength()) {
                $min = $connection;
            }
        }

        if (count($this->connections) < $this->maxConnections) {
            return $this->createNewConnection();
        }

        return $min;
    }
private function getLeastBusyConnectionOld() : pgConnection
    {
        if (count($this->connections) === 0) {
            // try to spin up another connection to return
            $conn = $this->createNewConnection();
            if ($conn === null) {
                throw new Exception('There are no connections. Cannot find least busy one and could not create a new one.');
            }

            return $conn;
        }

        $min = reset($this->connections);

        foreach ($this->connections as $connection) {
            // if this connection is idle - just return it
            if ($connection->getBacklogLength() === 0 && $connection->getState() === pgConnection::STATE_READY) {
                return $connection;
            }

            if ($min->getBacklogLength() > $connection->getBacklogLength()) {
                $min = $connection;
            }
        }

        if (count($this->connections) < $this->maxConnections) {
            return $this->createNewConnection();
        }

        return $min;
    }
private function getLeastBusyConnectionOld ( ) : pgConnection { if ( count ( $ this -> connections ) === 0 ) { // try to spin up another connection to return $ conn = $ this -> createNewConnection ( ) ; if ( $ conn === null ) { throw new Exception ( 'There are no connections. Cannot find least busy one and could not create a new one.' ) ; } return $ conn ; } $ min = reset ( $ this -> connections ) ; foreach ( $ this -> connections as $ connection ) { // if this connection is idle - just return it if ( $ connection -> getBacklogLength ( ) === 0 && $ connection -> getState ( ) === pgConnection :: STATE_READY ) { return $ connection ; } if ( $ min -> getBacklogLength ( ) > $ connection -> getBacklogLength ( ) ) { $ min = $ connection ; } } if ( count ( $ this -> connections ) < $ this -> maxConnections ) { return $ this -> createNewConnection ( ) ; } return $ min ; }
Get least busy connection, with idle state or at least with minimum queued queries count
@return pgConnection
@throws Exception
@deprecated
@see getLeastBusyConnection()
Get least busy connection with idle state or at least with minimum queued queries count