MongoDBCollection-getCollectionName.txt 913 Bytes
Newer Older
1 2 3 4 5 6
========================================
MongoDB\\Collection::getCollectionName()
========================================

.. default-domain:: mongodb

7 8 9 10 11 12
.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 1
   :class: singlecol

13 14 15 16 17
Definition
----------

.. phpmethod:: MongoDB\\Collection::getCollectionName()

18 19
   Returns the name of this collection.

20 21 22 23
   .. code-block:: php

      function getCollectionName(): string

24 25
Return Values
-------------
26

27
The name of this collection as a string.
28

29 30 31
Example
-------

32
The following returns the collection name for the ``zips`` collection in the
33
``test`` database.
34 35 36 37 38

.. code-block:: php

   <?php

39
   $collection = (new MongoDB\Client)->test->zips;
40

41 42 43
   echo $collection->getCollectionName();

The output would then resemble::
44 45

   zips
46

47 48
See Also
--------
49

50 51
- :phpmethod:`MongoDB\\Collection::getDatabaseName()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`