本文整理汇总了PHP中Mongo::drop方法的典型用法代码示例。如果您正苦于以下问题:PHP Mongo::drop方法的具体用法?PHP Mongo::drop怎么用?PHP Mongo::drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mongo
的用法示例。
在下文中一共展示了Mongo::drop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateCollection
public function testCreateCollection() {
$ns = $this->object->selectCollection('system.namespaces');
$this->object->drop('z');
$this->object->drop('zz');
$this->object->drop('zzz');
$this->object->createCollection('z');
$obj = $ns->findOne((object)array('name' => 'phpunit.z'));
$this->assertNotNull($obj);
$c = $this->object->createCollection('zz', true, 100);
$obj = $ns->findOne((object)array('name' => 'phpunit.zz'));
$this->assertNotNull($obj);
for($i=0;$i<100;$i++) {
$c->insert((object)array('x' => $i));
}
$this->assertLessThan(100, $c->count());
$c = $this->object->createCollection('zzz', true, 1000, 5);
$obj = $ns->findOne((object)array('name' => 'phpunit.zzz'));
$this->assertNotNull($obj);
for($i=0;$i<10;$i++) {
$c->insert((object)array('x' => $i));
}
$this->assertEquals(5, $c->count());
}
示例2: testEnsureIndex
public function testEnsureIndex()
{
$this->object->ensureIndex('foo');
$idx = $this->object->db->selectCollection('system.indexes');
$index = $idx->findOne((object) array('name' => 'foo_1'));
$this->assertNotNull($index);
$this->assertEquals($index['key']['foo'], 1);
$this->assertEquals($index['name'], 'foo_1');
// get rid of indexes
$this->object->drop();
$this->object->ensureIndex((object) array('bar' => -1));
$index = $idx->findOne((object) array('name' => 'bar_-1'));
$this->assertNotNull($index);
$this->assertEquals($index['key']['bar'], -1);
$this->assertEquals($index['ns'], 'phpunit.c');
}
示例3: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
public function setUp()
{
$m = new Mongo();
$this->object = $m->selectCollection('foo', 'bar');
$this->object->drop();
}
示例4: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
public function setUp()
{
$this->object = $this->sharedFixture->selectCollection('foo', 'bar');
$this->object->drop();
}