Sokil\Mongo\Database::getMongoDB PHP Method

getMongoDB() public method

public getMongoDB ( ) : MongoDB
return MongoDB
    public function getMongoDB()
    {
        if (empty($this->database)) {
            $this->database = $this->client->getMongoClient()->selectDB($this->databaseName);
        }
        return $this->database;
    }

Usage Example

Example #1
0
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Error setting write concern
  */
 public function testSetWriteConcern_Error()
 {
     $mongoCollectionMock = $this->getMock('\\MongoCollection', array('setWriteConcern'), array($this->database->getMongoDB(), 'test'));
     $mongoCollectionMock->expects($this->once())->method('setWriteConcern')->will($this->returnValue(false));
     $collection = new Collection($this->database, $mongoCollectionMock);
     $collection->setWriteConcern(1);
 }
All Usage Examples Of Sokil\Mongo\Database::getMongoDB