drop() public method

Drops this database
public drop ( ) : array
return array Returns the database response.
 public function tearDown()
 {
     if ($this->db instanceof \MongoDB) {
         $this->db->drop();
     }
     parent::tearDown();
 }
コード例 #2
0
 public function tearDown()
 {
     $this->database->dropCollection('testCollection');
     $this->database->drop();
     if (Mongo::getInstance()) {
         Mongo::getInstance()->destroy();
     }
 }
コード例 #3
0
    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
0
ファイル: Connection.php プロジェクト: hexcores/mongo-lite
 /**
  * Drop the database
  *
  * @return boolean
  */
 public function drop()
 {
     $ok = $this->db->drop();
     if (1 == (int) $ok['ok']) {
         return true;
     }
     return false;
 }
コード例 #5
0
ファイル: model.php プロジェクト: doganomer/RidderFinal
 /**
  * Drops a database
  */
 public function dropDb()
 {
     $this->mongo->drop();
     return;
     if (!isset($this->_db)) {
         $this->_db = $this->_mongo();
     }
     $this->_db->dropDB($this->mongo);
 }
コード例 #6
0
ファイル: Mongo.php プロジェクト: MacFJA/apix-cache
 /**
  * {@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
0
ファイル: MongoDB.php プロジェクト: ravikathaitarm01/fluenz1
 /**
  * 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
0
ファイル: Database.php プロジェクト: alcaeus/mongodb
 /**
  * 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
0
 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
0
ファイル: LoggableMongoDB.php プロジェクト: mongator/mongator
 /**
  * drop.
  */
 public function drop()
 {
     $this->time->start();
     $return = parent::drop();
     $time = $this->time->stop();
     $this->log(array('type' => 'drop', 'time' => $time));
     return $return;
 }
コード例 #11
0
ファイル: EMongoDB.php プロジェクト: phiphi1992/alongaydep
 /**
  * Drop the current DB.
  * @since v1.0
  */
 public function dropDb()
 {
     $this->_mongoDb->drop();
 }
コード例 #12
0
ファイル: mongo.php プロジェクト: Mumcio/bookmark-manager
 /**
  *	Intercept native call to re-enable profiler
  *	@return int
  **/
 function drop()
 {
     $out = parent::drop();
     $this->setprofilinglevel(2);
     return $out;
 }
コード例 #13
0
ファイル: TestCase.php プロジェクト: rickyrobinett/morph
 /**
  * @return void
  */
 public function tearDown()
 {
     if (isset($this->database)) {
         $this->database->drop();
     }
 }
コード例 #14
0
 public function testDrop()
 {
     $r = $this->object->drop();
     $this->assertEquals(true, (bool) $r['ok'], json_encode($r));
 }
コード例 #15
0
ファイル: Bootstrap.php プロジェクト: johnmicahmiguel/yodaphp
 public function removeMongoDb(\MongoDB $db)
 {
     $db->drop();
 }
コード例 #16
0
ファイル: main.php プロジェクト: nian2go/fatfree
 function m2()
 {
     $this->set('title', 'M2 Mapper');
     $this->expect(is_null($this->get('ERROR')), 'No errors expected at this point', 'ERROR variable is set: ' . $this->get('ERROR.text'));
     $this->expect(extension_loaded('mongo'), 'MongoDB extension available', 'MongoDB extension is not active - unable to continue');
     if (extension_loaded('mongo')) {
         $this->set('QUIET', TRUE);
         try {
             $db = new MongoDB(new Mongo('mongodb://*****:*****@product->_id}}', 'M2 MongoID sync issue');
             $this->expect($product->item == 111 && $product->description == 'Coca Cola' && $product->quantity == 4, 'M2 saved - database update succeeded', 'Database update failed');
             $product->copyTo('POST');
             $this->expect($this->get('POST.item') == 111 && $this->get('POST.description') == 'Coca Cola' && $this->get('POST.quantity') == 4, 'M2 properties copied to framework variable', 'Unable to copy M2 properties to framework variable');
             $_POST['description'] = 'Pepsi';
             $product->copyFrom('POST');
             $this->expect($product->item == 111 && $product->description == 'Pepsi' && $product->quantity == 4, 'M2 properties populated by framework variable', 'Unable to fill M2 properties with contents of framework variable');
             $this->set('POST.item', 999);
             $this->set('POST.description', 'Pepsi');
             $this->set('POST.quantity', 11);
             $product->copyFrom('POST', 'item|quantity');
             $this->expect($product->item == 999 && $product->description == 'Pepsi' && $product->quantity == 11, 'M2 properties populated by selected fields in framework variable', 'Unable to fill M2 properties with contents of framework variable');
             $product->reset();
             $this->expect($product->dry(), 'M2 reset completed', 'M2 should be dry');
             $product->item = 222;
             $product->description = 'Mobile Phone';
             $product->quantity = 9;
             $this->expect(!$product->dry(), 'M2 rehydrated manually', 'M2 should hydrated by now');
             $product->save();
             $this->expect(isset($product->_id), 'MongoID for new object assigned: ' . $product->_id, 'M2 MongoID sync issue');
             $this->expect(!$product->dry(), 'M2 expected to remain hydrated', 'M2 should not be dry');
             $product->load(array('item' => 111));
             $this->expect(is_object($product->_id) && $product->_id == $id, 'MongoID of first object correct: ' . $product->_id, 'M2 MongoID sync issue');
             $this->expect($product->item == 111 && $product->description == 'Coca Cola' && $product->quantity == 4, 'First record still there', 'First record is missing');
             $product->load(array('item' => 222));
             $this->expect($product->item == 222 && $product->description == 'Mobile Phone' && $product->quantity == 9, 'Second record found', 'Second record is missing');
             $product->load(array('item' => 111));
             $product->erase();
             $product->load(array('item' => 111));
             $this->expect($product->dry(), 'First record deleted', 'First record still exists');
             $product->load(array('item' => 222));
             $this->expect($product->item == 222 && $product->description == 'Mobile Phone' && $product->quantity == 9, 'Second record still there', 'Second record is missing');
             $product->reset();
             $product->item = 111;
             $product->description = 'Lots of dough';
             $product->quantity = 666;
             $product->save();
             $product->load(array('quantity' => array('$gt' => 0)), array('item' => TRUE));
             $this->expect($product->found() == 2, 'New record added - multirecord criteria specified for loading', 'New record was not added');
             $product->skip(1);
             $this->expect(!$product->dry(), 'One more record expected to be retrieved', 'M2 is dry');
             $this->expect($product->item == 222 && $product->description == 'Mobile Phone' && $product->quantity == 9, 'Forward navigation', 'Forward navigation failed');
             $product->skip(-1);
             $this->expect($product->item == 111 && $product->description == 'Lots of dough' && $product->quantity == 666, 'Backward navigation', 'Backward navigation failed');
             $product->skip(-1);
             $this->expect($product->dry(), 'M2 is dry when navigating before the start of the record set', 'Navigation failure');
             $this->set('QUIET', TRUE);
             $product->skip(-1);
             $this->expect(!is_null($this->get('ERROR')), 'Navigating past dry state triggers an error', 'Navigation error handling issue');
             $this->set('QUIET', FALSE);
             $this->clear('ERROR');
             $product->load(array('quantity' => array('$gt' => 0)), array('item' => TRUE));
             $product->skip(2);
             $this->expect($product->dry(), 'M2 is dry when navigating beyond the end of the record set', 'Navigation failure');
             $this->set('QUIET', TRUE);
             $product->skip();
             $this->expect(!is_null($this->get('ERROR')), 'Navigating past dry state triggers an error', 'Navigation error handling issue');
             $this->set('QUIET', FALSE);
             $this->clear('ERROR');
         }
     }
     echo $this->render('basic/results.htm');
 }
コード例 #17
0
 public function tearDown()
 {
     if ($this->db !== null) {
         $this->db->drop();
     }
 }