本文整理汇总了PHP中MongoDB::listCollections方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDB::listCollections方法的具体用法?PHP MongoDB::listCollections怎么用?PHP MongoDB::listCollections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB
的用法示例。
在下文中一共展示了MongoDB::listCollections方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clean
/**
* 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();
}
}
}
示例2: evaluate
/**
* 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: testListCollections
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: resetStorage
/**
* 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);
}
}
示例5: getTableList
/**
* @return array
*/
public function getTableList()
{
$collections = $this->dbcon->listCollections();
$output = array();
foreach ($collections as $coll) {
$output[] = $coll->getName();
}
return $output;
}
示例6: listCollections
/**
* 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: listCollections
/**
* 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: listCollections
/**
* Wrapper method for MongoDB::listCollections().
*
* @see http://php.net/manual/en/mongodb.listcollections.php
* @return array
*/
public function listCollections()
{
return $this->mongoDB->listCollections();
}
示例9: listCollections
/**
* 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: listCollections
/**
* listCollections.
*/
public function listCollections()
{
$this->time->start();
$return = parent::listCollections();
$time = $this->time->stop();
$this->log(array('type' => 'listCollections', 'time' => $time));
return $return;
}
示例11: clean
/**
* 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: listTables
/**
* Returns a list of the collections in the database.
*
* @return array
*/
public function listTables()
{
return $this->_db->listCollections();
}