Wrapper method for MongoClient::selectCollection().
public selectCollection ( string $db, string $collection ) : Doctrine\MongoDB\Collection | ||
$db | string | |
$collection | string | |
return | Doctrine\MongoDB\Collection |
public function testDriverOptions() { if (!extension_loaded('mongo')) { $this->markTestSkipped('Test will not work with polyfills for ext-mongo'); } $callCount = 0; $streamContext = stream_context_create(['mongodb' => ['log_cmd_delete' => function () use(&$callCount) { $callCount++; }]]); $connection = new Connection(null, [], null, null, ['context' => $streamContext]); $connection->selectCollection('test', 'collection')->remove([]); $this->assertSame(1, $callCount); }
/** * Constructor/DI. * * @param string $dbName */ public function __construct($dbName) { $connection = new Connection('mongodb://localhost:27017'); $this->collection = $connection->selectCollection($dbName, 'Todo'); }
/** * Gets the MongoDB Collection object for a Model. * * @param EntityMetadata $metadata * @return \Doctrine\MongoDB\Collection */ protected function getModelCollection(EntityMetadata $metadata) { return $this->connection->selectCollection($metadata->persistence->db, $metadata->persistence->collection); }