當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MongoDB::getCollectionNames方法代碼示例

本文整理匯總了PHP中MongoDB::getCollectionNames方法的典型用法代碼示例。如果您正苦於以下問題:PHP MongoDB::getCollectionNames方法的具體用法?PHP MongoDB::getCollectionNames怎麽用?PHP MongoDB::getCollectionNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MongoDB的用法示例。


在下文中一共展示了MongoDB::getCollectionNames方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: listCollections

 /**
  * List collections in a DB
  * 
  * @param MongoDB $db DB
  * @return array<MongoCollection>
  */
 static function listCollections(MongoDB $db)
 {
     $server = MServer::currentServer();
     $names = array();
     try {
         $names = $db->getCollectionNames(true);
     } catch (Exception $e) {
     }
     $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;
 }
開發者ID:myurasov,項目名稱:rockmongo,代碼行數:46,代碼來源:MDb.php

示例2: getTableNames

 public function getTableNames($schema = null, $refresh = false, $use_alias = false)
 {
     if ($refresh || empty($this->tableNames) && null === ($this->tableNames = $this->getFromCache('table_names'))) {
         /** @type TableSchema[] $names */
         $names = [];
         $tables = $this->dbConn->getCollectionNames();
         foreach ($tables as $table) {
             $names[strtolower($table)] = new TableSchema(['name' => $table]);
         }
         // merge db extras
         if (!empty($extrasEntries = $this->getSchemaExtrasForTables($tables, false))) {
             foreach ($extrasEntries as $extras) {
                 if (!empty($extraName = strtolower(strval($extras['table'])))) {
                     if (array_key_exists($extraName, $tables)) {
                         $names[$extraName]->fill($extras);
                     }
                 }
             }
         }
         $this->tableNames = $names;
         $this->addToCache('table_names', $this->tableNames, true);
     }
     return $this->tableNames;
 }
開發者ID:rajeshpillai,項目名稱:df-mongodb,代碼行數:24,代碼來源:MongoDb.php

示例3: _listCollections

 /**
  * 獲取數據庫中的文檔列表
  * @param MongoDB $db DB
  * @return array<MongoCollection>
  */
 public function _listCollections(MongoDB $db)
 {
     //獲取所有文檔列表
     $names = array();
     try {
         //$names = $db->execute('function (){ return db.getCollectionNames(); }');	//生產線不支持js格式mongo指令
         $names = $db->getCollectionNames();
     } catch (Exception $e) {
         echo $e->errorMessage();
         exit;
     }
     //獲取非係統文檔
     $ret = array();
     $inlay_tabse = Yii::app()->params['inlay_tabse'];
     foreach ($names as $name) {
         //屏蔽掉係統文檔和item
         if (preg_match("/^(system\\.|auto|file\\.)/", $name)) {
             continue;
         }
         $ret[$name] = isset($inlay_tabse[$name]) ? $inlay_tabse[$name] : $name;
     }
     //拆分item表
     $dsmap = CardDs::model()->getDBDSMap();
     //獲取遊戲表對應
     foreach ($dsmap as $dv) {
         foreach ($dv['list'] as $tv) {
             $ret['item_' . $dv['en_name'] . '_' . $tv['en_name']] = '數據表_' . $dv['name'] . '_' . $tv['name'];
         }
     }
     $names = $ret;
     return $names;
 }
開發者ID:chenyongze,項目名稱:d-a-m,代碼行數:37,代碼來源:DumpController.php


注:本文中的MongoDB::getCollectionNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。