listCollections() 공개 메소드

Get a list of collections in this database
public listCollections ( array $options = [] ) : MongoCollection[]
$options array
리턴 MongoCollection[] Returns a list of MongoCollections.
 /**
  * Removes all the collections from the mongo database.
  * Hopefully this is only ever called on the scriptureforge_test database.
  */
 public function clean()
 {
     foreach ($this->db->listCollections() as $collectionInfo) {
         if ($collectionInfo->getName() != 'system.indexes') {
             $collection = $this->db->selectCollection($collectionInfo->getName());
             $collection->drop();
         }
     }
 }
 /**
  * Evaluates the constraint for parameter $other. Returns TRUE if the
  * constraint is met, FALSE otherwise.
  *
  * @param mixed $other Value or object to evaluate.
  * @return bool
  */
 public function evaluate($other)
 {
     $exists = false;
     $collections = $this->db->listCollections();
     $collectionNames = array();
     foreach ($collections as $collection) {
         $collectionNames[] = $collection->getName();
     }
     return !\in_array($other, $collectionNames);
 }
예제 #3
0
 public function testListCollections()
 {
     $ns = $this->object->selectCollection('system.namespaces');
     for ($i = 0; $i < 10; $i++) {
         $c = $this->object->selectCollection("x{$i}");
         $c->insert(array("foo" => "bar"));
     }
     $list = $this->object->listCollections();
     for ($i = 0; $i < 10; $i++) {
         $this->assertTrue($list[$i] instanceof MongoCollection);
         if (!preg_match("/5\\.1\\../", phpversion())) {
             $this->assertTrue(in_array("phpunit.x{$i}", $list));
         }
     }
 }
예제 #4
0
 /**
  * Delete the database with all documents, it will be recreated on
  * next access.
  *
  * @return void
  */
 public function resetStorage()
 {
     $collectioNames = $this->database->listCollections();
     foreach ($collectioNames as $collectionName) {
         $this->database->dropCollection($collectionName);
     }
 }
 /**
  * @return array
  */
 public function getTableList()
 {
     $collections = $this->dbcon->listCollections();
     $output = array();
     foreach ($collections as $coll) {
         $output[] = $coll->getName();
     }
     return $output;
 }
예제 #6
0
 /**
  * Gets a list of database collections
  * @return array
  */
 public function listCollections()
 {
     $collections = array();
     $MongoCollectionObjects = $this->mongo->listCollections();
     foreach ($MongoCollectionObjects as $collection) {
         $collection = substr(strstr((string) $collection, '.'), 1);
         $collections[$collection] = $this->mongo->selectCollection($collection)->count();
     }
     ksort($collections);
     return $collections;
 }
예제 #7
0
파일: MDb.php 프로젝트: Briareos/rockmongo
 /**
  * List collections in a DB
  *
  * @param MongoDB $db DB
  * @return array<MongoCollection>
  */
 static function listCollections(MongoDB $db)
 {
     $server = MServer::currentServer();
     $names = array();
     $query = $db->execute("function (){ return db.getCollectionNames(); }", array());
     if ($query["ok"]) {
         $names = $query["retval"];
     } else {
         $colls = $db->listCollections(true);
         foreach ($colls as $coll) {
             $names[] = $coll->getName();
         }
     }
     $ret = array();
     foreach ($names as $name) {
         if ($server->shouldHideCollection($name)) {
             continue;
         }
         if (preg_match("/^system\\./", $name)) {
             continue;
         }
         $ret[] = $name;
     }
     sort($ret);
     //system collections
     if (!$server->uiHideSystemCollections()) {
         foreach ($names as $name) {
             if ($server->shouldHideCollection($name)) {
                 continue;
             }
             if (preg_match("/^system\\./", $name)) {
                 $ret[] = $name;
             }
         }
     }
     $collections = array();
     foreach ($ret as $v) {
         if ($v === "") {
             //older MongoDB version (maybe before 1.7) allow empty collection name
             continue;
         }
         $collections[] = $db->selectCollection($v);
     }
     return $collections;
 }
예제 #8
0
 /**
  * Wrapper method for MongoDB::listCollections().
  *
  * @see http://php.net/manual/en/mongodb.listcollections.php
  * @return array
  */
 public function listCollections()
 {
     return $this->mongoDB->listCollections();
 }
예제 #9
0
 /**
  * listCollections.
  */
 public function listCollections($includeSystemCollections = false)
 {
     $this->time->start();
     $return = parent::listCollections($includeSystemCollections);
     $time = $this->time->stop();
     $this->log(array('type' => 'listCollections', 'time' => $time));
     return $return;
 }
예제 #10
0
 /**
  * listCollections.
  */
 public function listCollections()
 {
     $this->time->start();
     $return = parent::listCollections();
     $time = $this->time->stop();
     $this->log(array('type' => 'listCollections', 'time' => $time));
     return $return;
 }
 /**
  * Removes all the collections from the mongo database.
  * Hopefully this is only ever called on the scriptureforge_test database.
  */
 public function clean()
 {
     foreach ($this->db->listCollections() as $collection) {
         $collection->drop();
     }
 }
예제 #12
0
 /**
  * Returns a list of the collections in the database.
  *
  * @return array
  */
 public function listTables()
 {
     return $this->_db->listCollections();
 }