« Collection::dropIndex
Collection::find »

Collection::existsInDatabase

(No version information available, might only be in Git)

Collection::existsInDatabase — コレクションがデータベースに存在するかをチェックする

説明

public function mysql_xdevapi\Collection::existsInDatabase(): bool

コレクションオブジェクトが、データベース(スキーマ)内のコレクションを参照しているかを調べます。

パラメータ

この関数にはパラメータはありません。

戻り値

コレクションがデータベースに存在していれば true を返します。 そうでなければ、false を返します。

2つのカラム (doc と _id) で定義されたテーブルは、 コレクションと見なされます。 MySQL 8.0.21 以降では、doc, _id, _json_schema の3つのカラムで構成されたテーブルが コレクションと見なされます。 これに対してカラムを追加すると、 existsInDatabase() はコレクションとは見なさなくなります。

例

例1 mysql_xdevapi\Collection::existsInDatabase() の例

<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");
$session->sql("DROP DATABASE IF EXISTS addressbook")->execute();
$session->sql("CREATE DATABASE addressbook")->execute();

$schema = $session->getSchema("addressbook");
$create = $schema->createCollection("people");

// ...

$collection = $schema->getCollection("people");

// ...

if (!$collection->existsInDatabase()) {
    echo "The collection no longer exists in the database named addressbook. What happened?";
}
?>
関連キーワード:
コレクション   Collection   existsInDatabase   データベース   mysql   xdevapi   schema   session   addressbook   チェック   カラム   collection   テーブル   execute   people   dropIndex   find   information   available   スキーマ   MySQL   json   構成   getSession   mysqlx
関連する関数・ページ:
mysql-xdevapi-collection.getname   class.mysql-xdevapi-collection   mysql-xdevapi-collection.dropindex   mysql-xdevapi-collection.count   mysql-xdevapi-collection.getschema   mysql-xdevapi-collection.remove