本文整理汇总了PHP中Mongo::dropDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Mongo::dropDB方法的具体用法?PHP Mongo::dropDB怎么用?PHP Mongo::dropDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mongo
的用法示例。
在下文中一共展示了Mongo::dropDB方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDropDB
public function testDropDB()
{
$m = new Mongo();
$mem = memory_get_usage(true);
for ($i = 0; $i < 10000; $i++) {
$m->dropDB("phpunit");
}
$this->assertEquals($mem, memory_get_usage(true));
$db = $m->selectDB("phpunit");
for ($i = 0; $i < 10000; $i++) {
$m->dropDB($db);
}
}
示例2: tearDown
protected function tearDown()
{
if (!empty($this->_connectionString) && extension_loaded('mongo')) {
$this->_model = null;
$connection = new \Mongo($this->_connectionString);
$connection->dropDB($this->_dbName);
}
}
示例3: dropDb
/**
* Drops a database
*/
public function dropDb()
{
$this->mongo->drop();
return;
if (!isset($this->_db)) {
$this->_db = $this->_mongo();
}
$this->_db->dropDB($this->mongo);
}
示例4: dropDatabase
/** @proxy */
public function dropDatabase($database)
{
if ($this->eventManager->hasListeners(Events::preDropDatabase)) {
$this->eventManager->dispatchEvent(Events::preDropDatabase, new EventArgs($this, $database));
}
$this->initialize();
$result = $this->mongo->dropDB($database);
if ($this->eventManager->hasListeners(Events::postDropDatabase)) {
$this->eventManager->dispatchEvent(Events::postDropDatabase, new EventArgs($this, $result));
}
return $result;
}
示例5: testDropDB
public function testDropDB()
{
$this->object->connect();
$c = $this->object->selectCollection("temp", "foo");
$c->insert(array('x' => 1));
$this->object->dropDB("temp");
$this->assertEquals($c->findOne(), NULL);
$db = $this->object->selectDB("temp");
$c->insert(array('x' => 1));
$this->object->dropDB($db);
$this->assertEquals($c->findOne(), NULL);
}
示例6: testDropDB
public function testDropDB()
{
$this->object->connect();
$c = $this->object->selectCollection("temp", "foo");
$result = $c->db->command(array("ismaster" => 1));
if (!$result['ismaster']) {
$this->markTestSkipped("can't test writes on slave");
return;
}
$c->insert(array('x' => 1));
$this->object->dropDB("temp");
$this->assertEquals($c->findOne(), NULL);
$db = $this->object->selectDB("temp");
$c->insert(array('x' => 1));
$this->object->dropDB($db);
$this->assertEquals($c->findOne(), NULL);
}
示例7: clean
/**
* Clean some cache records (protected method used for recursive stuff)
*
* Available modes are :
* \Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
* \Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
* \Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
* ($tags can be an array of strings or a single string)
* \Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
* ($tags can be an array of strings or a single string)
* \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
* ($tags can be an array of strings or a single string)
*
* @param string $dir Directory to clean
* @param string $mode Clean mode
* @param array $tags Array of tags
* @throws \Zend_Cache_Exception
* @return boolean True if no problem
*/
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = [])
{
switch ($mode) {
case \Zend_Cache::CLEANING_MODE_ALL:
return $this->_conn->dropDB($this->_options['dbname']);
break;
case \Zend_Cache::CLEANING_MODE_OLD:
return $this->_collection->remove(['expire' => ['$lt' => time()]]);
break;
case \Zend_Cache::CLEANING_MODE_MATCHING_TAG:
return $this->_collection->remove(['t' => ['$all' => $tags]]);
break;
case \Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
return $this->_collection->remove(['t' => ['$nin' => $tags]]);
break;
case \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
return $this->_collection->remove(['t' => ['$in' => $tags]]);
break;
default:
\Zend_Cache::throwException('Invalid mode for clean() method');
break;
}
}