« Schema::dropCollection
Schema::getCollection »

Schema::existsInDatabase

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

Schema::existsInDatabase — データベースに存在するかをチェックする

説明

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

現在のオブジェクト(スキーマ、テーブル、コレクション、またはビュー)が、 スキーマオブジェクト内に存在しているかを調べます。

パラメータ

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

戻り値

スキーマ、コレクション、テーブル、またはビューがスキーマに存在していれば true そうでなければ false を返します。

例

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

<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");

$session->sql("DROP DATABASE IF EXISTS food")->execute();
$session->sql("CREATE DATABASE food")->execute();
$session->sql("CREATE TABLE food.fruit(name text, rating text)")->execute();

$schema = $session->getSchema("food");
$schema->createCollection("trees");

// ...

$trees = $schema->getCollection("trees");

// ...

// Is this collection still in the database (schema)?
if ($trees->existsInDatabase()) {
    echo "Yes, the 'trees' collection is still present.";
}

上の例の出力は、 たとえば以下のようになります。

Yes, the 'trees' collection is still present.
関連キーワード:
Schema   trees   existsInDatabase   session   mysql   xdevapi   スキーマ   food   schema   データベース   チェック   execute   collection   still   getCollection   テーブル   コレクション   text   present   dropCollection   information   available   ビュー   getSession   mysqlx
関連する関数・ページ:
mysql-xdevapi-schema.getcollection   mysql-xdevapi-schema.construct   mysql-xdevapi-schema.dropcollection   mysql-xdevapi-schema.createcollection   class.mysql-xdevapi-schema   mysql-xdevapi-schema.getname