本文整理汇总了PHP中Client::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getDatabase方法的具体用法?PHP Client::getDatabase怎么用?PHP Client::getDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client::getDatabase方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
// connect to mongo
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
// select database
$this->database = $client->getDatabase('test');
}
示例2: setUp
public function setUp()
{
// connect to mongo
$client = new Client();
// select database
$this->database = $client->getDatabase('test');
}
示例3: setUp
public function setUp()
{
// connect to mongo
$client = new Client();
// select database
$this->database = $client->getDatabase('test');
$this->queue = $this->database->getQueue('queue_channel');
}
示例4: setUp
public function setUp()
{
// connect to mongo
$client = new Client();
// select database
$database = $client->getDatabase('test');
// select collection
$this->collection = $database->getCollection('phpmongo_test_collection');
}
示例5: setUp
public function setUp()
{
// connect to mongo
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
// select database
$database = $client->getDatabase('test');
// select collection
$this->collection = $database->getCollection('phpmongo_test_collection');
}
示例6: setUp
public function setUp()
{
// connect to mongo
$client = new Client();
if (version_compare($client->getDbVersion(), '2.6.0', '<')) {
$this->markTestSkipped('Current primary does not have a Write API support.');
}
// select database
$database = $client->getDatabase('test');
$this->collection = $database->getCollection('phpmongo_test_collection');
}
示例7: setUp
public function setUp()
{
$client = new Client();
$this->cache = $client->getDatabase('test')->getCache('cache_namespace')->init();
}
示例8: testStoreDocumentInPool_DocumentAlreadyStored
public function testStoreDocumentInPool_DocumentAlreadyStored()
{
/**
* Store document to pool
*/
$this->assertTrue($this->collection->isDocumentPoolEmpty());
$document = $this->collection->createDocument(array('param' => 'value'))->save();
$this->assertFalse($this->collection->isDocumentPoolEmpty());
/**
* Modify document in another thread
*/
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
$client->getDatabase($document->getCollection()->getDatabase()->getName())->getCollection($document->getCollection()->getName())->find()->findOne()->set('param', 'updatedValue')->save();
// here oroginal document must be in unconsisted state
$this->assertEquals('value', $document->get('param'));
// overload document in pool with new data
$this->collection->find()->findOne();
$this->assertEquals('updatedValue', $document->get('param'));
}
示例9: setUp
public function setUp()
{
$client = new Client();
$this->database = $client->getDatabase('test');
$this->gridFs = $this->database->getGridFs('images');
}
示例10: setUp
public function setUp()
{
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
$this->database = $client->getDatabase('test');
$this->gridFs = $this->database->getGridFs('images');
}
示例11: testGetDatabase_NameNotSpecified_DefaultNameNotSpecified
/**
* @expectedException \Sokil\Mongo\Exception
* @expectedExceptionMessage Database not selected
*/
public function testGetDatabase_NameNotSpecified_DefaultNameNotSpecified()
{
$client = new Client('mongodb://127.0.0.1/');
$this->assertEquals('some_name', $client->getDatabase()->getName());
}
示例12: setUp
public function setUp()
{
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
$database = $client->getDatabase('test');
$this->collection = $database->getCollection('phpmongo_test_collection')->delete();
}
示例13: setUp
public function setUp()
{
$client = new Client();
$database = $client->getDatabase('test');
$this->collection = $database->getCollection('phpmongo_test_collection')->delete();
}
示例14: setUp
public function setUp()
{
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
$this->cache = $client->getDatabase('test')->getCache('cache_namespace')->init();
}