Shanty_Mongo_Document::_getMongoDb PHP Method

_getMongoDb() public method

Fetch an instance of MongoDb
public _getMongoDb ( boolean $writable = true ) : MongoDb
$writable boolean
return MongoDb
    public function _getMongoDb($writable = true)
    {
        if (is_null($this->getConfigAttribute('db'))) {
            require_once 'Shanty/Mongo/Exception.php';
            throw new Shanty_Mongo_Exception('Can not fetch instance of MongoDb. Document is not connected to a db.');
        }
        if ($writable) {
            $connection = Shanty_Mongo::getWriteConnection($this->getConfigAttribute('connectionGroup'));
        } else {
            $connection = Shanty_Mongo::getReadConnection($this->getConfigAttribute('connectionGroup'));
        }
        $temp = $connection->selectDB($this->getConfigAttribute('db'));
        # Tells replica set how many nodes must have the data before success
        //		$temp->w = 2;
        return $temp;
    }