drop() public method

Drops this collection
public drop ( ) : array
return array Returns the database response.
 /**
  * @access protected
  */
 protected function setUp()
 {
     $m = new Mongo();
     $db = new MongoDB($m, "phpunit");
     $this->object = $db->selectCollection('c');
     $this->object->drop();
 }
Esempio n. 2
0
 /**
  * @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();
 }
Esempio n. 3
0
 /**
  * {@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;
 }
    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');
    }
Esempio n. 5
0
/**
 * 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('');
}
Esempio n. 6
0
 /**
  * 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;
 }
Esempio n. 7
0
 /**
  * @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());
 }
 /**
  * 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;
 }
Esempio n. 9
0
 /**
  * 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;
 }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
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);
    }
}
Esempio n. 12
0
 /**
  * Drops the files and chunks collections
  *
  * @return array - The database response.
  */
 public function drop()
 {
     $this->chunks->drop();
     parent::drop();
 }
Esempio n. 13
0
 /**
  * Run a truncate statement on the table.
  */
 public function truncate()
 {
     $result = $this->collection->drop();
     return 1 == (int) $result->ok;
 }
Esempio n. 14
0
 /**
  * Tear-down operations performed after each test method
  *
  * @return void
  */
 public function tearDown()
 {
     if ($this->mongoCollection) {
         $this->mongoCollection->drop();
     }
 }
Esempio n. 15
0
 protected function tearDown()
 {
     if (!is_null($this->userCollection)) {
         $this->userCollection->drop();
     }
 }
Esempio n. 16
0
<?php

error_reporting(E_ALL);
// 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) {
    echo "Removing {$colname}...\n";
    $col = new MongoCollection($db, $colname);
    $col->drop();
    $col->deleteIndexes();
    $col2name = $colname . "_agg";
    $col2 = new MongoCollection($db, $col2name);
    $col2->drop();
    $col2->deleteIndexes();
}
Esempio n. 17
0
 /**
  * drop.
  */
 public function drop()
 {
     $this->time->start();
     $return = parent::drop();
     $time = $this->time->stop();
     $this->log(array('type' => 'drop', 'time' => $time));
     return $return;
 }
Esempio n. 18
0
 /**
  * 物理删除数据集合
  */
 public function physicalDrop()
 {
     return parent::drop();
 }
 public function tearDown()
 {
     parent::tearDown();
     // clear mongo db
     $this->collection->drop();
 }
 public function clear()
 {
     $this->index->drop();
 }
Esempio n. 21
0
 /**
  * Purges the cache deleting all items within it.
  *
  * @return boolean True on success. False otherwise.
  */
 public function purge()
 {
     $this->collection->drop();
     $this->collection = $this->database->selectCollection($this->definitionhash);
 }
Esempio n. 22
0
 public function deleteCollection($collectionName)
 {
     $Collection = new MongoCollection($this->mongodb, $collectionName);
     try {
         #içeriği güncelleyelim.
         $Collection->drop();
         $result = 'Collection Başarılı bir şekilde silinmiştir.';
     } catch (MongoCursorException $e) {
         die('Collecion Silme işlemi yaparken teknik bir sorunla karşılaşıldı ' . $e->getMessage());
     }
     return $result;
 }
Esempio n. 23
0
 /**
  */
 public function clear()
 {
     $this->_db->drop();
 }
Esempio n. 24
0
 /**
  * Drop
  *
  * @return int
  */
 public function drop()
 {
     $return = $this->collection->drop();
     $this->lastInsertValue = 0;
     return $return['ok'];
 }
Esempio n. 25
0
 /**
  * {@inheritDoc}
  */
 public function flush()
 {
     $this->collection->drop();
 }
Esempio n. 26
0
 public function dropCollection()
 {
     $this->_collection->drop();
 }
Esempio n. 27
0
 /**
  * Drops the collection.
  *
  * @see Collection::drop()
  * @return array
  */
 protected function doDrop()
 {
     return $this->mongoCollection->drop();
 }
Esempio n. 28
0
<?php

$connection = new MongoClient("mongodb://*****:*****@ds039504.mongolab.com:39504/thetop");
$mongodb = $connection->selectDB('thetop');
$collection = new MongoCollection($mongodb, 'NJ');
$collection->drop();
$results = shell_exec('GET http://api.wunderground.com/api/cfe632a32ad965c6/conditions/q/NJ/Andover.json');
$arrayCode = json_decode($results, true);
$mongo_array = array("city" => $arrayCode["current_observation"]["display_location"]["city"], "temp" => $arrayCode["current_observation"]["temp_f"], "weather" => $arrayCode["current_observation"]["weather"], "wind" => $arrayCode["current_observation"]["wind_string"]);
var_dump($mongo_array);
$connection = new MongoClient("mongodb://*****:*****@ds039504.mongolab.com:39504/thetop");
$mongodb = $connection->selectDB('thetop');
$collection = new MongoCollection($mongodb, 'NJ');
$collection->insert(array($mongo_array));
$results = shell_exec('GET http://api.wunderground.com/api/cfe632a32ad965c6/conditions/q/NJ/Atlantic_City.json');
$arrayCode = json_decode($results, true);
$mongo_array = array("city" => $arrayCode["current_observation"]["display_location"]["city"], "temp" => $arrayCode["current_observation"]["temp_f"], "weather" => $arrayCode["current_observation"]["weather"], "wind" => $arrayCode["current_observation"]["wind_string"]);
var_dump($mongo_array);
$connection = new MongoClient("mongodb://*****:*****@ds039504.mongolab.com:39504/thetop");
$mongodb = $connection->selectDB('thetop');
$collection = new MongoCollection($mongodb, 'NJ');
$collection->insert(array($mongo_array));
$results = shell_exec('GET http://api.wunderground.com/api/cfe632a32ad965c6/conditions/q/NJ/Belmar.json');
$arrayCode = json_decode($results, true);
$mongo_array = array("city" => $arrayCode["current_observation"]["display_location"]["city"], "temp" => $arrayCode["current_observation"]["temp_f"], "weather" => $arrayCode["current_observation"]["weather"], "wind" => $arrayCode["current_observation"]["wind_string"]);
var_dump($mongo_array);
$connection = new MongoClient("mongodb://*****:*****@ds039504.mongolab.com:39504/thetop");
$mongodb = $connection->selectDB('thetop');
$collection = new MongoCollection($mongodb, 'NJ');
$collection->insert(array($mongo_array));
$results = shell_exec('GET http://api.wunderground.com/api/cfe632a32ad965c6/conditions/q/NJ/Caldwell.json');
Esempio n. 29
0
 function eliminarColeccion($TABLA)
 {
     try {
         $DB = $this->CONEXION->innet;
         $COLECCION = new MongoCollection($DB, "temporal" . $TABLA);
         $RESULTADO = $COLECCION->drop();
     } catch (Exception $e) {
         $this->LOG->registraLog("Generica", $e->getMessage(), "No es posible eliminar la coleccion " . $TABLA);
         return "";
     }
     return "";
 }
Esempio n. 30
0
 public function drop()
 {
     return $this->_collection->drop();
 }