本文整理汇总了PHP中MongoDB::drop方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDB::drop方法的具体用法?PHP MongoDB::drop怎么用?PHP MongoDB::drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB
的用法示例。
在下文中一共展示了MongoDB::drop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
if ($this->db instanceof \MongoDB) {
$this->db->drop();
}
parent::tearDown();
}
示例2: tearDown
public function tearDown()
{
$this->database->dropCollection('testCollection');
$this->database->drop();
if (Mongo::getInstance()) {
Mongo::getInstance()->destroy();
}
}
示例3: 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(array('name' => 'phpunit.z'));
$this->assertNotNull($obj);
// even though we're only setting this to 100, it allocates 1 extent,
// so we can fit 4096, not 100, bytes of data in the collection.
$c = $this->object->createCollection('zz', true, 100);
$obj = $ns->findOne(array('name' => 'phpunit.zz'));
$this->assertNotNull($obj);
for($i=0;$i<100;$i++) {
$c->insert(array('x' => $i));
}
$this->assertLessThan(100, $c->count());
$c = $this->object->createCollection('zzz', true, 1000, 5);
$obj = $ns->findOne(array('name' => 'phpunit.zzz'));
$this->assertNotNull($obj);
for($i=0;$i<10;$i++) {
$c->insert(array('x' => $i));
}
$this->assertEquals(5, $c->count());
}
示例4: drop
/**
* Drop the database
*
* @return boolean
*/
public function drop()
{
$ok = $this->db->drop();
if (1 == (int) $ok['ok']) {
return true;
}
return false;
}
示例5: dropDb
/**
* Drops a database
*/
public function dropDb()
{
$this->mongo->drop();
return;
if (!isset($this->_db)) {
$this->_db = $this->_mongo();
}
$this->_db->dropDB($this->mongo);
}
示例6: flush
/**
* {@inheritdoc}
*/
public function flush($all = false)
{
if (true === $all) {
$res = $this->db->drop();
return (bool) $res['ok'];
}
// $res = $this->collection->drop();
$regex = new \MongoRegex('/^' . $this->mapKey('') . '/');
$res = $this->collection->remove(array('key' => $regex));
return (bool) $res['ok'];
}
示例7: drop_db
/**
* Drop database
*
* @param string $database
* @return bool|array
*/
public function drop_db($database)
{
if (!empty($database)) {
try {
return $this->_database->drop();
} catch (\Exception $e) {
$this->_last_error = $e;
}
}
return false;
}
示例8: drop
/**
* Wrapper method for MongoDB::drop().
*
* This method will dispatch preDropDatabase and postDropDatabase events.
*
* @see http://php.net/manual/en/mongodb.drop.php
* @return array
*/
public function drop()
{
if ($this->eventManager->hasListeners(Events::preDropDatabase)) {
$this->eventManager->dispatchEvent(Events::preDropDatabase, new EventArgs($this));
}
$result = $this->mongoDB->drop();
if ($this->eventManager->hasListeners(Events::postDropDatabase)) {
$this->eventManager->dispatchEvent(Events::postDropDatabase, new EventArgs($this));
}
return $result;
}
示例9: 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(array('name' => 'phpunit.z'));
$this->assertNotNull($obj);
$c = $this->object->createCollection('zz', true, 100);
$obj = $ns->findOne(array('name' => 'phpunit.zz'));
$this->assertNotNull($obj);
for ($i = 0; $i < 10; $i++) {
$c->insert(array('x' => $i));
}
$this->assertLessThan(10, $c->count());
$c = $this->object->createCollection('zzz', true, 1000, 5);
$obj = $ns->findOne(array('name' => 'phpunit.zzz'));
$this->assertNotNull($obj);
for ($i = 0; $i < 10; $i++) {
$c->insert(array('x' => $i));
}
$this->assertEquals(5, $c->count());
}
示例10: drop
/**
* drop.
*/
public function drop()
{
$this->time->start();
$return = parent::drop();
$time = $this->time->stop();
$this->log(array('type' => 'drop', 'time' => $time));
return $return;
}
示例11: dropDb
/**
* Drop the current DB.
* @since v1.0
*/
public function dropDb()
{
$this->_mongoDb->drop();
}
示例12: drop
/**
* Intercept native call to re-enable profiler
* @return int
**/
function drop()
{
$out = parent::drop();
$this->setprofilinglevel(2);
return $out;
}
示例13: tearDown
/**
* @return void
*/
public function tearDown()
{
if (isset($this->database)) {
$this->database->drop();
}
}
示例14: testDrop
public function testDrop()
{
$r = $this->object->drop();
$this->assertEquals(true, (bool) $r['ok'], json_encode($r));
}
示例15: removeMongoDb
public function removeMongoDb(\MongoDB $db)
{
$db->drop();
}