本文整理汇总了PHP中MongoCollection::drop方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCollection::drop方法的具体用法?PHP MongoCollection::drop怎么用?PHP MongoCollection::drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection::drop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @access protected
*/
protected function setUp()
{
$m = new Mongo();
$db = new MongoDB($m, "phpunit");
$this->object = $db->selectCollection('c');
$this->object->drop();
}
示例2: initialize
/**
* @test
*/
public function initialize()
{
$this->collection->drop();
$author = new Author('kirk');
$user = new Netizen($author);
$user->setProfile(new \Trismegiste\SocialBundle\Security\Profile());
$this->repository->persist($user);
$source = new SmallTalk($author);
$this->repository->batchPersist([$source, $source, $source]);
$this->assertCount(4, $this->collection->find());
return (string) $user->getId();
}
示例3: clear
/**
* {@inheritdoc}
*/
public function clear($key = null)
{
if (!$key) {
$this->collection->drop();
return true;
}
if ($this->collection instanceof \MongoDB\Collection) {
$this->collection->deleteMany(['_id' => new \MongoDB\BSON\Regex("^" . preg_quote(self::mapKey($key)), '')]);
} else {
$this->collection->remove(['_id' => new \MongoRegex("^" . preg_quote(self::mapKey($key)))], ['multiple' => true]);
}
return true;
}
示例4: testEnsureIndex
public function testEnsureIndex() {
$this->object->ensureIndex('foo');
$idx = $this->object->db->selectCollection('system.indexes');
$index = $idx->findOne(array('name' => 'foo_1'));
$this->assertNotNull($index);
$this->assertEquals($index['key']['foo'], 1);
$this->assertEquals($index['name'], 'foo_1');
$this->object->ensureIndex("");
$index = $idx->findOne(array('name' => '_1'));
$this->assertEquals(null, $index);
// get rid of indexes
$this->object->drop();
$this->object->ensureIndex(null);
$index = $idx->findOne(array('name' => '_1'));
$this->assertEquals(null, $index);
$this->object->ensureIndex(array('bar' => -1));
$index = $idx->findOne(array('name' => 'bar_-1'));
$this->assertNotNull($index);
$this->assertEquals($index['key']['bar'], -1);
$this->assertEquals($index['ns'], 'phpunit.c');
}
示例5: drop_demo
/**
* Demonstrate logging on collection.drop().
*
* @param \MongoCollection $collection
* The demo collection.
* @param \Psr\Log\LoggerInterface $logger
* The logger instance.
*/
function drop_demo(MongoCollection $collection, LoggerInterface $logger)
{
$logger->debug("Dropping {$collection}");
$logger instanceof TimingLoggerInterface && $logger->startLap();
$collection->drop();
$logger->debug('');
}
示例6: purge
/**
* Purges the cache deleting all items within it.
*
* @return boolean True on success. False otherwise.
*/
public function purge()
{
if ($this->isready) {
$this->collection->drop();
$this->collection = $this->database->selectCollection($this->definitionhash);
}
return true;
}
示例7: initialize
/**
* @test
*/
public function initialize()
{
$this->collection->drop();
$author = [];
foreach (['kirk', 'spock', 'mccoy'] as $nick) {
$author[] = new Author($nick);
}
$source = new SmallTalk($author[0]);
$this->repository->persist($source);
$rep[0] = new Repeat($author[1]);
$rep[0]->setEmbedded($source);
$this->repository->persist($rep[0]);
$rep[1] = new Repeat($author[2]);
$rep[1]->setEmbedded($rep[0]);
$this->repository->persist($rep[1]);
$this->assertCount(3, $this->collection->find());
}
示例8: dropResultSet
/**
* Drop the collection created by MapReduce
* @return Array
*/
public function dropResultSet()
{
if (!isset($this->collection)) {
$this->collection = new MongoCollection($this->mongoDB, $this->_response["result"]);
}
$db_response = $this->collection->drop();
$this->collection = NULL;
return $db_response;
}
示例9: delete
/**
* Delete collection
*
* @return \Sokil\Mongo\Collection
* @throws \Sokil\Mongo\Exception
*/
public function delete()
{
$status = $this->_mongoCollection->drop();
if ($status['ok'] != 1) {
// check if collection exists
if ('ns not found' !== $status['errmsg']) {
// collection exist
throw new Exception('Error deleting collection ' . $this->getName() . ': ' . $status['errmsg']);
}
}
return $this;
}
示例10: initDbWithOnePublishingWithReportedComment
protected function initDbWithOnePublishingWithReportedComment()
{
$author = [];
foreach (['kirk', 'spock', 'mccoy'] as $nick) {
$author[] = new Author($nick);
}
$doc = new SmallTalk($author[0]);
$comm = new Commentary($author[1]);
$comm->report($author[2]);
$comm->report($author[0]);
$doc->attachCommentary($comm);
$this->coll->drop();
$this->repo->persist($doc);
}
示例11: testreg
function testreg()
{
// connect
$m = new MongoClient();
// select a database
$db = $m->selectDB('trend');
// select a collection (analogous to a relational database's table)
$colnames = ['housesale', 'aptsale', 'flatsale', 'houserent', 'aptrent', 'flatrent'];
foreach ($colnames as $colname) {
$col2name = $colname . "_reg";
$col2 = new MongoCollection($db, $col2name);
// Let's remove all first
$col2->drop([]);
// add agg information
mkreg($db, $colname);
}
}
示例12: drop
/**
* Drops the files and chunks collections
*
* @return array - The database response.
*/
public function drop()
{
$this->chunks->drop();
parent::drop();
}
示例13: truncate
/**
* Run a truncate statement on the table.
*/
public function truncate()
{
$result = $this->collection->drop();
return 1 == (int) $result->ok;
}
示例14: tearDown
/**
* Tear-down operations performed after each test method
*
* @return void
*/
public function tearDown()
{
if ($this->mongoCollection) {
$this->mongoCollection->drop();
}
}
示例15: tearDown
protected function tearDown()
{
if (!is_null($this->userCollection)) {
$this->userCollection->drop();
}
}