本文整理汇总了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;
}