Learn the "why" behind slow queries and how to fix them in our 2-Part Webinar.
Register now >
Docs Menu
Docs Home
/ /

MongoDB\Collection::getDatabaseName()

MongoDB\Collection::getDatabaseName()

このコレクションを含むデータベースの名前を返します。

function getDatabaseName(): string

このコレクションを string として含むデータベースの名前。

次の例では、 testデータベース内のzipsコレクションのデータベース名が返されます。

<?php
$collection = (new MongoDB\Client)->test->zips;
echo $collection->getDatabaseName();

出力は次のようになります。

test
  • MongoDB\Collection::getCollectionName()

  • MongoDB\Collection::getNamespace()

戻る

getCollectionName()

項目一覧