本文整理匯總了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;
}
示例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;
}
示例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;
}