Mongolid\Connection\Pool::getConnection PHP Method

getConnection() public method

Gets a connection from the pool. It will cycle through the existent connections.
public getConnection ( ) : Connection
return Connection
    public function getConnection()
    {
        if ($chosenConn = $this->connections->pop()) {
            $this->connections->push($chosenConn);
            return $chosenConn;
        }
    }

Usage Example

Example #1
0
 /**
  * Retrieves the Collection object.
  *
  * @return Collection
  */
 protected function getCollection() : Collection
 {
     $conn = $this->connPool->getConnection();
     $database = $conn->defaultDatabase;
     $collection = $this->schema->collection;
     return $conn->getRawConnection()->{$database}->{$collection};
 }
All Usage Examples Of Mongolid\Connection\Pool::getConnection